Slack and Salesforce Integration – Part 2

In my previous post, I demonstrated how to access Slack from Salesforce. I shared an example showing how to use Slack Webhooks and ProcessBuilder to automatically post messages to Slack channels when specific events happen in Salesforce (for example, when the status of an opportunity changes).

In this post, I cover the other side of the integration. I’ll demonstrate how to access Salesforce from Slack using Slash Commands. As an example of this integration scenario, I’ll share three Slash commands:

  • /pipeline [number to show]: Show the top Salesforce opportunities in the Slack UI
  • /contact [searchkey]: Search contacts by name from the Slack UI
  • /case [subject:description]: Create a case from the Slack UI

Watch the video below to see these commands in action in Slack:

/pipeline and /case are “in channel” commands: the response is visible to all members of the channel. /contact is “ephemeral”: the response is only visible to the user that issued the command .


To perform this integration, I wrote a lightweight Node.js app that acts as a message broker between Slack and Salesforce. When the Node.js application receives a request from Slack, it checks whether the token provided with the request is valid: if it matches the Slack token (generated when the slash command was created), a REST service is invoked to perform the requested action in Salesforce. If the token is not valid, an error is returned to the Slack client.

Follow the steps below to install this integration in your own environment:

Step 1: Create the Slash Commands

In Slack, create the three Slash Commands defines as follows:

Command URL Method Custom Name
/pipeline POST Top Opportunities
/contact POST Salesforce Contacts
/case POST Salesforce cases
You can change the URLs later if you are not sure what your app name will be. The important thing at this point is to generate the token for each command.

Step 2: Deploy your Instance of the Node.js App

The easiest way to deploy your instance of the Node.js App is to click Deploy to Heroku button, and fill in the deployment wizard. You need to provide the username and password of an integration user in Salesforce. If you are testing this in a Developer Edition, you can enter your own credentials. For each command, you also need to provide the token generated when you created the command in Step 1.

  1. Make sure you are logged in to the Heroku Dashboard
  2. Click the Button below to deploy the application on Heroku.


Your own instance of the application is automatically deployed.

Make sure you understand the security implications before deploying the application in a production environment

Source Code

The source code for the Node.js application is available in this repository.

  • Pingback: Slack and Salesforce Integration | Christophe Coenraets()

  • good of nice bloge

  • dan

    Thanks Christophe, this is great stuff.

    Quick question regarding the client secret in heroku- can you offer some guidance around setting up the new app from Salesforce? Not sure what I should be building in order to generate a new client secret.

  • En güzel ortamda en güzel eğitimler en kaliteli hocalar ile en’lerin kulubu olan ruyaavcısı ekibi ile gerçekleştirilmektedir. Güzel sanatlara hazırlıkta bir numaralı adresiniz olan kurumumuz mezun ettiği öğrencilerden aldığı olumlu sonuçlar ve çevrelerindeki yönlendirmeler ile bizlere en çok referans olan şahıslardır. Atölyemizi incelemek için size bir telefon kadar yakınız. İster Avcılar isterseniz Esenyurt iki şubemiz ile haftanın yedi iş günü sizlere hizmet vermekteyiz. Avcılarda metrobüse yürüme mesafesinde olan resim kursu muz Size bir adım kadar yakın… Bakırköy resim kursu ile kalitenin farkına atölyemizde varacaksınız.

  • Great article, why do you use Heroku and not expose a REST apex web service on Salesforce directly? Security, scale, other?

    • Lai Thomas ChangJiang

      That is the same I am wondering… Can slack command call Apex Rest Webservice directly?

  • My Heroku log keeps coming up with this:

    2016-05-12T18:03:17.284619+00:00 app[web.1]: TypeError: Cannot read property ‘instance_url’ of undefined
    2016-05-12T18:03:17.284662+00:00 app[web.1]: at Connection._apiRequest (/app/node_modules/nforce/index.js:905:17)
    2016-05-12T18:03:17.284713+00:00 app[web.1]: at IncomingMessage.emit (events.js:179:7)


  • There are a number of drivers which contribute towards the residential real estate in India; these are highlighted in the illustration below. We have already discussed the housing shortfall which is one of the key drivers; the second most important factor is the Indian diaspora, which tends to get overlooked. If the real estate sector in India is able to initiate some confidence building measures in the coming years, it would go a long way in tapping this huge potential market.

    Real Estate Property In india

  • Pingback: Slack and Salesforce Integration: Authentication | Christophe Coenraets()

  • Jessica Meyer

    I keep receiving an error from Slack that says “Visit this URL to login to Salesforce:” and when I visit that URL, “error=redirect_uri_mismatch&error_description=redirect_uri%20must%20match%20configuration”

    Having never set something up like this, am I missing something obvious? I added a connected app in salesforce and wasn’t sure what to set the callback URL.

    • John Krech

      I get the same error – did you ever find a fix?

      • Jessica Meyer

        Unfortunately I had to drop the project for awhile, so no, but I’d love to pick it back up after awhile so if you have any updates do share! :)

    • Jaya Prakash Kommu

      I got this error when my redirect url in salesforce connected app was incorrect. Check if your call back url in salesforce app is similar to this:

      • rihanna

        this worked for me! Thanks!

  • rihanna

    Is there any way to have a command that searches for cases? Similarly to the /contacts command?

  • Victor

    Is it possible to pass more parameters when using the slash command to create a case? Let’s say I want the case to be associated with with an account and contact when created from slack. Is it possible to enter this parameters from slack?

  • Anupam Shrivastava

    Hello there. I am unable to create custom integration on slack so I created an app there and creating slash commands. But I am unable to get any token so what should be copied to Heroku Config Var?

  • aura

    I keep getting the error . “Darn – that slash command didn’t work (error message: `502_service_error`). Manage the command at slash-command-case. ” has anyone encountered this?

  • tom271

    Well written post, in this post you are moving very important issues.

  • shravya ch

    Hey, Can i post a message back from private channel into Salesforce with this integration ?

  • Aycan Demir

    islami sohbet
    yabancı sohbet
    islami Chat
    Gabile giriş
    Gabile mobil
    Gabile sohbet
    Gay sohbet
    Gay sohbet
    Sohbet Cinsel
    Gabile mobil
    Cinsel Sohbet
    Gabile chat
    Gabile mobil
    bedava chat
    bilecik sohbet bilecik halkına en iyi sohbet ortami sunulmaktadir..
    alanya sohbet kaliteli sohbet sitemiz sizler içndir
    sakarya sohbet Sakaryanin En iyi Elit Sohbet sitesi sizinledir
    samsun chat Samsun Sohbet farkini ücretsiz sitemizde yaşayin
    webmaster forumu Türkiyenin en iyi webmaster forum sitesine sizlerde davetlisinizdir!
    sohbet bursa Türkiyenin en iyi sohbet bursa sitesine sizlerde davetlisinizdir!
    Van Sohbet Vandaki En iyi Sohbet Sitesi Sizinledir
    Kalbim chat Kalbimdeki En iyi bedava sohbet sitesi
    Gay chat Gaylar ile Bedava Sohbet Ede bilirsiniz
    Tam chat