Salesforce - Slack Integration

Overview:

The client had a requirement to integrate slack Account of the Organization Team to their Salesforce instance. They need to post the Contacts and Tasks information from Salesforce to Slack. Main challenge is to post task details by same username in Slack who has the ownership of the tasks.

Solution / Approach:

We have used the Slack API to post the data of Salesforce Tasks and Contact’s object to Slack. We can Post the data in different channels of Slack by different Channels Id. The business logic to select channel has also been implemented in Salesforce instance. Within this integration multiple users can also post the data in the slack.

Right now we are posting Task’s Description, related Contact Name as a hyperlink, with concatenation of some other custom fields.

When a task is created in Salesforce, the system will check all the fields that are needed to be concatenated, if these fields contains value then all details will get posted in Slack with same username who has ownership of Task in Salesforce. Slack Channel is been selected by implementing some business logic.

Authentication is also provided for new user to come and configure their instance in Slack by just filling basic details on a Visualforce page.

Below are the screenshots of our implemented functionality:

Record in Salesforce:
slack integration

Authentication of Multiple Users in Salesforce:

The authentication page will authenticate the Salesforce instance with Slack. In the page user need to provide the following parameters:

  • Channel Name
  • Token
  • Email of your Salesforce User

After entering the above details the User will get authenticated to Slack. Below is the Screenshot of our Authenticate page:

slack integration

Posted record in Slack:
slack integration

Conclusion

We accomplished following functionalities:

  • Fetch the data of Task and its Contact from the Salesforce and post by concatenate to Slack.
  • Post the data in the Slack as comments with the related hyperlinks to redirect it to Salesforce records.
  • Business logic to select Slack Channel is been implemented. Based on the data in the task fields post is pasted in particular channel of Slack.
  • Any number of users can post the data into same Channel with the help of Channel Id.
  • Implemented the app logic for different user to post in single app in any of the channel

Resources

The base URI for API resource is: https://api.slack.com/docs/oauth