Automate Slack Messages

Create Your Slack Workspace

In this step, you need a Slack workspace, as well as the email address and password you use to sign in to Slack. As you build out the integration, it’s best you use a test workspace, similar to using a Sandbox to test new Salesforce features. 

Follow these steps to create one for free.

  1. Head to
  2. You have the option to launch Slack or get started, depending on whether you already have Slack for work.
    1. If you’re new to Slack, click GET STARTED at the top of the page, then click Create a Slack workspace.
    2. If you already have a Slack account, the website might recognize your browser. In this case, click LAUNCH SLACK  at the top of the page, then select Create a Slack workspace.
  3. Follow the prompts to set up your account and new workspace.
    1. When Slack asks for the name of your company or project, enter something fun, like your pet or your favorite food.
    2. When Slack asks what you'll be using the workspace for, enter announcements and anything else you'd like to add.
    3. When you get the prompt to add people, click Skip this step, then confirm by clicking Skip Step to go right into your workspace.

You now have a new Slack workspace. To access your exact workspace address, click the disclosure arrow (1) next to your business or team name (what you named the workspace), and check out the address next to the large initials (2). It should be in this format:

new Slack workspace with user options open; number 1 is next to the disclosure arrow and number 2 is next to the company/team name; arrows point to each with a red box highlighting the slack workspace address

Create a Slack Channel for Leads

Once your workspace is set up, create a new channel in Slack for all your lead alerts.

  1. Click the + next to Channels.
  2. Select Create a channel from the dropdown.
  3. Enter leads for the channel name, then click Create.
  4. Toggle on the option to auto-add anyone who joins your workspace.
  5. Then, click Save.

Now, head back to your Trailhead Playground to finish the setup.

Create Custom Message Destinations

Custom message destinations guide alerts to your specific Slack workspace. Head back to your Trailhead Playground and open the Slack Setup app if it’s not open already. The app should indicate Automation Configuration is next. Click Continue to start.

  1. Click Sign in with Slack to open the popup and authenticate your Slack workspace.
    1. Slack may recognize your browser, in which case you only need to select the appropriate workspace and click Allow.
    2. If Slack doesn’t recognize your browser:
      1. Enter the Slack workspace and click Continue.
      2. Enter the email address and password you set up for Slack and click Sign In. If you need help finding your password, you can check out this article from Slack.
      3. Then, click Allow.
  2. Click New Message Destination and enter the following:
    1. Message Destination Name: Leads
    2. Slack Workspace: leave as-is (it should be the workspace you authenticated)
    3. Slack Channel or Person: leads
  3. Click Save.
  4. Click file icon  to the right of the message destination ID to copy it. Save in a place where you can retrieve it later. Configure Message Destinations screen in Automation Configuration, with the message destination ID highlighted by a red box and arrow
  5. Then, click Finish.

Build Automation with Process Builder

Once you've set up a message destination, build a process to automatically send new leads to Slack. 

  1. Click setup and select Setup.
  2. Enter process in Quick Find and select Process Builder.
  3. Click New to start your new automation.
  4. Enter Slack Leads for Process Name. This should automatically populate the API name, too.
  5. For The Process starts when, select A record changes.
  6. Click Save.

Automate New Leads

Set up the process so that it activates when new leads are created.

  1. Click Add Object.
  2. In the prompt, enter lead in the Find an object … field and select Lead.
  3. To start the process, make sure only when a record is created is selected.
  4. Click Save.
  5. Then, click Add Criteria.
  6. Enter Record Creation for Criteria Name.
  7. Make sure No criteria—just execute the actions! is selected.
  8. Click Save.

Add a Message for Context

Now, make the action send a message to Slack with key information and a fun message.

Process Builder with Call Apex action configuration open and Apex Variables populated

  1. Click Add Action, then enter the following information:
    1. Action Type: Apex
    2. Action Name: send to slack
    3. Apex Class: Slack: Post Message
  2. The Apex Class opens a set of field variables. This is where you add your message destination ID and other information.
    1. Record ID | Field Reference | click into Find a Field, enter lead in the search, and select Lead ID, then click Choose.
    2. Message Destination ID | ID | enter the destination ID you copied from your message destination above.
  3. Click Add Row for the last variable.
    1. Message | String | enter There’s a new lead in Salesforce!
  4. Click Save.
  5. Click Activate.
  6. Then, click Confirm.

Notice the process references a specific Apex Class, Slack: Post Message. The Salesforce for Slack package created this class. It also set up an action for Flow Builder, just in case your business needs require the use of flows. Check out Lightning Flow for more information on best use cases for each automation tool. 

OK, you’ve set up automation by building a flow. There’s only one thing you need to do now—test!

Keep learning for
Sign up for an account to continue.
What’s in it for you?
  • Get personalized recommendations for your career goals
  • Practice your skills with hands-on challenges and quizzes
  • Track and share your progress with employers
  • Connect to mentorship and career opportunities