Salesforce Messaging
Messaging lets your company have conversations with customers in the ways that are most convenient for your customers—on their mobile devices using messaging apps such as SMS text messaging and Facebook Messenger. Agents can respond in the Service Console, where they can access all the benefits of Digital Engagement at their fingertips.
Text Messaging
To setup text messaging you first need messaging license from salesforce. License name is "Messaging User". Once you have license you have to go in setup(make sure to use lightning and click on service setup) to enable messaging. Go in service setup and search for messaging.Click on messaging settings and toggle the button and enable messaging in your organization.
After enable click on "New Channel" button. It will ask you log a case with salesforce so they can assign a channel number(phone number) to your org. This number will be used by your org to send messages to customers.
You can use text, messenger and whatsapp messages in our scenario we will discuss about text messages.
Use Case
In this article we will perform a use case that when order status is changed system should pick up contacts of the account the order is associated to and send them status of order. This is like the same use case when we place an order with amazon and get order status updates text messages.
Messaging Setup
Once salesforce replies you back with a phone number assigned to your org you have to start configuring system.First of all go on your user record and scroll down to license permission and then assign yourself messaging user license.
Then create messaging user permission set as per this link and assign it to your user. Once these two step are down you will be able to edit channel configurations to setup opt in and opt out communications.
Note:As in my use case we are not using omni channel but we still have to configure complete setup of omni channel otherwise text messaging will not receive opt in and opt out communications.
Go in set up and search for omni channel setting and click the checkbox and enable omni channel.
Now from setup search for presence configuration and create a presence configuration.
Now from setup search for presences statuses and click on new button.Create new presence status "Messaging" and select messaging channel in it.
Now from setup search for routing configuration and click new button.Create a new routing configuration and
Routing Configuration Name = Messaging Routing
Routing Priority = 1
Routing Model = Most Available
Now from setup search for service channel and click new. Create anew service channel.
Name = Messaging
developer name = sfdc_livemessage
Object = Messaging Session
Create a queue with name messaging queue and add following objects
Order
Contact
Account
Messaging User
Messaging Session
Routing Configuration = Messaging Routing(the one you created above)
Add system admin profile in this queue. Now edit channel in routing type select queue based routing and in queue lookup selects your messaging queue.Add opt in and opt out communication as per below and leave all the other things blank and save the channel configurations.
Opt in: You have opted in to receive sales order update texts
Opt out: You have opted out for all sales order update texts
Process Builder
Now to send text messages automatically once order status is updated we will create a process builder.
From setup search process builder and click new. Select Order object and add a criteria Ischanged(Status) then on action choose flow. Pass order id to flow
Flow
Create an auto launched flow
Flow name = Order Status Message
Get Records
Get order records from the id passed by flow as per below image
Get Records
Get account contact relation data using order object account. In this way we can get all the contacts of account.As shown in image
Decision
Check if no contacts are found then stop the flow if contacts are found then Loop around them.As per image
Get Records
Get messaging user record of contact as per image.
Decision
Check if messaging user record is already exist for this contacts or not. As per image
Action
If messaging user record exist then send text.As per image
Create Messaging User Record
If messaging user record does not exist then create a messaging user record.Note: Make sure that when you create messaging user record then platform key and messaging user name should be same and platform key should have +1 in phone number otherwise system will create duplicate records.
Note: messaging user record of one phone number can be configured on one channel