Create Chatter Notifications from Inbound Messages
Before you start, be sure that you've completed the following requirements:
- Complete the instructions outlined in the previous help guide: Pushing Inbound Messages and Status Updates to Salesforce.
- Create a chatter group that you can post messages to. If you are unsure about how to do this, check out the Salesforce documentation on how to set up a chatter group.
In this section of the package, we'll learn how to create a Salesforce Chatter notification when we receive an inbound message.
Create a New Process Builder Flow
In your setup home page, go to the left navbar and click on Process Automation > Process Builder.
On the "My processes" page, click on "New" in the top right corner.
In the new process modal, enter the following information:
- Process Name: SMS Chatter Notification (or custom name)
- API Name: SMS_Chatter_Notification (press tab to auto-populate)
- Description: Creates a chatter notification on inbound SMS. (optional)
- The process starts when: Select "A record changes"
Set up the Process Trigger
Now that you've created your process builder flow, we can configure it to create the chatter notification.
Start by clicking on "Add Object". Search for "Twilio" in the object finder and select "Twilio Message" as the object to trigger on.
Then, under "Start the process" make sure that you've selected "only when a record is created":
Define the Process Criteria
Now that we have our trigger set up, we need to configure out process so it only creates chatter events when inbound messages are created.
In the diamond underneath the "Twilio Message" trigger, click on "Add criteria". You'll see a side panel with the heading "Define Criteria for this Action Group" appear.
Specify the following values:
- Criteria Name: Create From Event
- Criteria for Executing Actions: Conditions are met
- Set conditions:
- Field: Choose "Created from platform event"
- Operator: Equals
- Type: Boolean
- Value: True
Once you've specified those conditions, click the blue "Save" button at the bottom of the panel.
Specify your action
Now that we have a trigger and criteria set up so that our process will only execute actions for an inbound message, we can trigger different types of events within Salesforce such as email or chatter. For this example, we'll post to a chatter group.
First, click on "Add action" in the immediate actions box. Then, specify the following values in the side-panel that appears:
- Action name: Post to Chatter (or custom)
- Post to: Select "Chatter group"
- Group: Select the group you wish to post to (in our example, it's SMS Notifications). Read this Salesforce documentation about setting up a chatter group if you do not have one configured.
For the message, click on "Merge field" and add "Number Unformatted" as well as "Body". You should end up with the following in your message field:
- New Message from {![TwilioSF__Message__c].TwilioSF__From_Number_Unformatted__c}: {![TwilioSF__Message__c].TwilioSF__Body__c}
Activate your Action and test
Click on the blue "Activate" button in the top-right corner of the process builder window. Then, try texting in to your Salesforce instance. You should see new messages arriving in your chatter group when you text in.
Need some help?
We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.