In this article, we will see how we can integrate Slack with Salesforce and vice-versa. Before we start this journey let me introduce the wonderful Slack to those who are new to it.
Slack is a messaging app for businesses and connects people to the information that they need. By bringing people together to work as one unified team, Slack transforms the way that organisations communicate. Slack helps organisations to work in a more connected, flexible, and inclusive way. You can find more info here.
By using Slack you can perform the following actions:
- Send messages and files
- Pin and save items
- Mention teammates
- Link channel names
Please see here to understand these actions more in detail.
As a prerequisite please create your new Slack workspace (i.e. your account). Then download the Slack app to your system.
Ok, but what is a workspace? A Slack workspace is made up of channels, where team members can communicate and work together.
What is a Channel? Slack organises conversations into dedicated spaces called channels. Channels bring order and clarity to work – you can create them for any project, topic, or team. With the right people and information in one place, teams can share ideas, make decisions and move work forwards.
When we say the integration of Salesforce with Slack we are talking about the bi-directional integration. This means we would need to do set up or configuration at both the Slack and Salesforce sides.
In order to achieve this, we would need to install the Salesforce app to our Slack account and then install the Slack app from app-exchange to our Salesforce account.
Let’s start with the Integration:
Step 1: Install Salesforce App To Slack
Once you have successfully created your Slack workspace, assuming you have downloaded the Slack app on your system. Open Slack and sign in to your workspace.
You may or may not see the Apps section in the left-hand sidebar. If you see that great if not then no worries, look for the Browse Slack in the sidebar.
Click on Browse Slack
You can either click directly on the Apps or set your preferences. I would recommend setting your preferences. If you do so you can manage the look and feel as well as what you see in your sidebar.
Now when you click on Apps, you will see an Apps page. Search for Salesforce and add this app to your Slack.
Select the app and click on Get it Now, you will then see a popup screen with the button Open Login Screen. Click on the button you will be navigated to another screen, click on the Allow button.
Click on the relevant button, since I am doing this in my developer account I will click on the Install here. In case you want this to happen in a sandbox click on Install in Sandbox
Install the app for the relevant set of users. A popup will be prompted to all access for the third-party websites, grant the access. The installation will start and you can see the app under Installed packages.
Step 3: Verify The Connection
Once you are done with steps 1 and 2. Let’s verify if the connection has been set up. Goto your Slack and refresh the app, you should see a notification for the Salesforce that you are connected to your Salesforce Org. Here you can see multiple notifications as I try to connect with multiple Salesforce org just part of my own exercise.
Note: Something to note here, that even if you don’t install the Slack app in your Salesforce org. You would still be able to connect the two apps, but with limited access to different sets of permissions and features.
Step 4: Search and Share Salesforce Records in Slack
Before we go ahead make sure you assign the Slack Standard User permissions set to the relevant users.
Once the above steps are accomplished, now it’s time to sure the integrations. By default, you can search the following objects using the Slack search feature:
Account, Case, Contact, Lead, Opportunity, and Task.
Click on the lightning bolt icon in the chatbox,
Click on Find and share a record
Provide the name of the record you want to search. You will see the available records or related across the above six mentioned sObjects.
Click on any of the returned records and see the details, you can also share the records across available your Slack channels
Step 5: Access to Custom objects and Other Field Searches
Now, what if we want to search for other custom objects or want to search the records based on other field values.
In order to achieve this, click on the menu icon in Salesforce and look for Slack Setup
You will see the System connections marked with a green checkbox since we have successfully sync Salesforce and Slack.
Click continue, you will see an option to add the custom objects
Note: You can add just nine fields as part of the returned record details.
Once this is done you would need to Activate the object, this can be Automatic or Manual activation.
Read the mentioned description in the Guidance section for more details and perform the needed actions. Once the object is activated it is available for search.
Step 6: Alternative Way to Search Records
So there is another way to search records, if you click again on the lightning bolt icon in the chatbox, select Salesforce you can see an option like “/salesforce [search term]”. Once you click on this option the text will be copied into the chatbox, replace the search term with the name of the record you want to search. Hit enter it will return all the matching records, here in the below example I have searched for the custom object that I have activated. You can also view the record details for the nine fields you have selected.
Step 7: Custom Alerts from Salesforce to Slack
The other thing I want to discuss from Salesforce to Slack is the alerts for the records updated/created in Salesforce. This is somewhat like creating a workflow in Salesforce where you perform certain actions when certain criteria are met for the designated object. This alert can be either on object or record level.
Step 8: Org Configuration
This part of the setup helps you to send notifications from Salesforce to Slack using Send to Slack or Slack Alerts actions.
When you click on Edit button, you will see a crenn with the Layouts of all the six primary and the custom objects you have selected. Select the layout where you want these actions to be available. Finally at the bottom you will see the Add Actions to Layouts button click, then click Next and Finish.
A new Action will be added to the selected page layout.
Navigate to any of the record for the object whose layout you have changed. You should see the Actions. Let’s click on the Send to Slack actions, a following screen will appear. Here you can provide the necessary values along with the message.
Step 9: Automation Configuration
This is where it starts to get more exciting, again click on the Edit button. A following screen will appear here you can add the message destination.
When you click on the New Message Destination, a new screen pops up. Add the relevant details and click Save.
What is does is that it creates a Message Destination Id, this is basically the unique identifier of the channel in your workspace where you want to post any message using automation in Salesforce.
We will now see how we can use this in a flow and send out message to Slack channel whenever a new record is created. we will not be using Process Builder as they will eventually be depricated.
Use an Apex Action and choose Slack: Post Message as the apex. This will ask for three parameters:
- Message Destination Id: use the unique value we just generated.
- Record Id: newly created record Id.
- Message: any custom message you can send to the Slack channel.
Note: I have global elements to store value as this just for demo purpose.
Create a new record and see the message being sent to the appropriate channel.
Step 10: Set up Alerts in Slack
Now prior to this step we have seen how we transfer traffic from Salesforce to Slack. Now let’s make some adjustments in Slack to make it intelligent to hear the events in Salesforce and share information across channels and users.
Navigate to Salesforce under Apps in the left sidebar, goto the Home tab and click on Set up My Alerts. Finally provide necessary permissions.
Step 11: Slack Channel Alerts For Salesforce Record Changes
Here we would be configuring Slack to hear any updates on the records we are interested in. So that when ever following alerts occurs, that information is displayed in the designated Slack Channel.
- An email was sent
- A call was logged
- An event happened(change to record values)
Click on the lightning bolt icon in the chat box, choose the Salesforce App and click on the Add/edit alerts for a channel.
Add the Slack channel where you want to see the alerts. Clcik on Add a record, search the record and add the relevant record from the dropdown.
Finally, click on View record and choose Add to [channel name] and select all the alerts that you want to post to your selected channel and click Save to complete the setup.
Note: This update alerts will only be for the 9 fields you have selected when we were configuring the custom object.
Step 12: Bulk Alerts
Lastly we will be talking about the bulk alerts, use bulk alerts to post updates about all the records of a particular type to your Slack channels. Use this only when your team needs all the information because too many alerts and irrelevant records can make it hard to spot the vital information and messages.
This is same as what we did in the Step 11, but here we are exposing the entire object records not just specific records of course with a different set of alerts:
- New Project Management was created
- Notify for Status Change
Again navigate to the Salesforce App under Apps. Goto the Home tab and click on the Add Bulk Alert under Advanced.
This finally completes some amount of integration. The scope of Salck to Salesforce is not just limited to the steps we have performed above, but is quite wide. We can do integration using Slack APIs to perform some advanced actions. Please the available Slack documentations here about the APIs.