Centro Support Center

Contact Us

Using Salesforce Platform Events and Flow to create interactive Slack Messages

This article will describe how to set up custom Slack messages with actionable buttons using Salesforce Flows and Platform Events. 

Need assistance setting up in your org and workspace or customizing for your needs? Send us a note: support@centro.rocks

There are many use cases these tools can be the foundation to create. Here's a few examples of what's possible:

This article will be covering the following basic use case and should serve to illustrate implementation details. 

Goal: Our company Lakeview creates an implementation project when closing a deal, but the account owner often forgets to do so. The implementation is determined to be very important for customer satisfaction and later renewals. For this project, when an Opportunity closes, prompt the Opportunity Owner in Slack to create a new Project record. Notify the team the Project has been created, with a link to the newly created record. Here's a GIF of the finished result:

Prerequisites & Customizations

The flow will perform the following:

Steps:

  1. Stub out an Autolaunched Flow: Our flow will need to use the Pause element in order to wait for a button event from Slack. Remember that the Pause element is only available on certain types of Flows. The Pause element does not appear in a Record-Triggered flow, for example. In this case, we'll use Process Builder to trigger off the Closed Won event on the Opportunity object, which will then invoke the AutoLaunched flow.

  2. Create Flow variables: Create the following Text variables, making sure to make the Variable available as in Input outside the flow. Here's an example of one of the variables:Add any element to the flow, then Save the flow as "SlackCreateProject". That way it'll appear in Process Builder.

  3. Create a Process Builder for Closed Won: Use the Opportunity as the base object, then for Add Criteria, set to "Opportunity Stage = Closed Won". Now, for the Immediate Action, pick Flow, then select the Flow you just created. Set the Flow variables as follows:Note that the SlackMemberID is a custom field on the User Object. See this article for associating Slack Member IDs to Salesforce User records.

  4. Create the Slack Message Action: Add a Centro Slack Action after the start of the Flow. This element will be used to notify the #Sales channel a new opportunity has closed, and expose a button in the Slack message to Create a Project.
    - Set the Slack channel to post to as #sales
    - Update the custom message. Include the variable varSlackMember ID that was set in the Process Builder in the previous step.
    - Enable Post Record Details, and set to the variable varOpportunityID. This will post the opportunity compact layout.
    - Add a button. Label it ":gear: Create Project", then check to Publish as Platform Event. This will allow the button press to show up as a Salesforce Platform event. Optionally check Delete Message if you want to prevent multiple button presses. 

  5. Add the Pause Element. Since we can't predict when the button in Slack will be pressed, we need to Pause the flow until that happens. Create it as shown. Create a new Pause Configuration labeled "Project Click". Set the Resume Event a Platform Event Message is received. Choose the Platform Event as Centro Action. Make the conditions as the field Centro__Value__c as the Label you gave the button in step 4, in this case ":gear: Create Project". Add the field Centro__Interview__Guid__c to be the Flow's Interview GUID. That way, only this particular Flow will be able to fire the subsequent events: 

  6. Get the Account Fields. We'll want to name the new Project as the Account name, so we need to reach up from the Opportunity to the Account. Configure as follows:

  7. Create a new Project. Now we need to create the new project record as promised when the Slack user pressed the button. Configure as follows (note we are setting Lookup fields on the newly created Project record such as Account and Opportunity since the Project record is expecting them to be set). Also, be aware we want to store the Project ID in a variable to use in our next Slack message:
  8. Send Slack Message with Project Details: Now we want to alert the users in Slack the new Project Record is available. Add another Centro Message Action, and configure as follows: Note that we want to use the new Project ID to display the newly created Project details, and a button to click to review the new Project. Instead of a Platform Event, we're using a URL. Note that you must merge in the Project ID, and customize the base URL for your Salesforce org.

  9. Test. All done! Now time to test. Make sure the Flow and Process Builder is Activated, and trip an Opportunity to Closed Won. You should see the following:Pressing the button will result in:Pressing the Open Project Record button:


Success! You've:

Need assistance setting up in your org and workspace or customizing for your needs? Send us a note: support@centro.rocks