Send a Slack message Action
  • 13 Sep 2022
  • 7 Minutes to read
  • Dark
    Light

Send a Slack message Action

  • Dark
    Light

When building an Automation, you may choose the "Send a Slack message" action. When the automation runs successfully: a corresponding Slack message will be sent to the specified Slack channel, or user(s), containing the message you customized during the automation configuration process.

Setup

After you have configured your base in the manner you choose, you can then begin configuring your automation. For this example, we will be setting up an automation that sends a notification to a channel in Slack when a project, in our Project Tracker template, is completed.

First, we will set up a trigger to fire when a project enters a "Completed" view. In our Project Tracker base, we have created a filter that only allows projects from a completed checkbox field to enter the "Completed" view. To do this, choose the corresponding table and view within the base and test the trigger.

6615975016471whenrecordentersviewexampleconfigprojecttracker.jpg

After testing successfully, we can move onto setting up the action. To set up the "Send a Slack message" action click the blue "+ Add Action" button. Then, click on the "Send a Slack message" option. This will bring up a window with configuration options. If it is your first time creating this action, then you may need to "Manage connected accounts" or "Connect new account" before proceeding.

6615995210263slacksendmessageactionconfigaccountmenu.jpg

Sending a Slack Message

You can then choose to either statically send a slack message to the same channel or user(s) every time, or you can dynamically message different channels or users for each automation run. Valid inputs can be email addresses, channel names , or Slack conversation IDs.

You can access the static channels and users available to your account by selecting from option(s) included in the drop-down menu:

6616021151511slackconfigselectstaticchannel.jpg

Dynamically messaging channels and users

You can dynamically configure where a message will be sent by clicking on the cogwheel next to the "Channel" input. You can input channel names by prepended the channel's name with a "#", (e.g. #general instead of general).

6616012074263slacksendmessageactionconfigdynamicchannel.gif

You can also dynamically input email address(es) to send individuals direct messages via Slackbot:

6616021965975slacksendmessageconfiginsertdynamicdirectmessage.gif

If you are inputting multiple inputs, ensure they are all separated with a comma. Note that Slack messages will be sent to each of the inputs individually via Slackbot. For example, if multiple email addresses are provided, we will send a Slackbot DM to each of those people, and will not create a group DM.

@Mentioning Slack users

To @mention other Slack users in a message, you can either insert the user name associated with their Slack account or you can insert the individual Slack user's ID. Using either of the methods listed below, particular users can be mentioned statically (every slack message sent) or dynamically (via a formula). To dynamically be able to Directly message (DM) a user check out the section above.

@Mention using a user name

To mention a Slack user in the body of a message you'll want to insert their name within brackets like the example below. Slack has its own documentation on this and it's worth pointing out that user names are different than display names.

<@first.last>
NOTE

If you are experiencing difficulties @mentioning a particular user via their user name, then we recommend using the user ID method discussed below.

@Mention using Slack user's ID

As mentioned in Slack's API reference webpage, you can manually retrieve a specific user's ID by clicking on the overflow button in their Slack profile and choosing the " Copy member ID "option, as shown in the screenshot.

360087552293autoSlackID.png

Now that you have the member ID (a unique combination of letters and numbers) you can add this to the body of your Slack message automation in the action step using this format:

<@ U012345678> 

Dynamic @mentioning

If you want a Slack message's body to dynamically @mention particular users based upon the record being referenced in Airtable, then you'll want to set up a formula to output the user's user name or member ID. In the example below, a particular collaborator's Slack member ID is being referenced via a lookup field. We then concatenate the member ID with the proper formatting in the formula.

CONCATENATE("<@", {Slack member id lookup}, ">")

Next, you'll need to insert this formula field's value into your Slack message action. In this example, we insert the value from the trigger record (Step 1 ) as a dynamic greeting so that the collaborator associated with the record in Airtable is appropriately tagged in Slack.

4415140837911slackmentiondynamicmessage.gif

You can insert a clickable URL, or hyperlink, into your automation's Slack messages by wrapping the URL with brackets like this:

<https://www.airtable.com>

If you'd prefer the link to show as hyperlinked text then use the following syntax:

<https://www.airtable.com|Airtable>

The result would appear as Airtable rather than https://www.airtable.com.

There are two options to choose from in your automation:

  1. Dynamic URLs - URLs inserted from an Airtable record in a previous step of the Automation using the blue plus sign. (Shown in green below. The arrow indicates the record where the URL is coming from.)
  2. Static URLs - URLs that are typed into the "Message" box. These URLs will remain static/stay the same across every automated Slack message sent. (Shown in orange and matching the <https://www.airtable.com|Airtable> example above.)

4418382944535slackmessageautomationstaticdynamiclinks.jpg

The result in Slack looks like this:

4418382970647slackmessageautomationresult.jpg

More options

By clicking the "Show more options" dropdown you can customize the automation's Slackbot name and icon to give your messages a little more flair:

6615998635799slacksendamessageactionconfigmoremoreoptions.jpg

You can also choose to furl or unfurl any links you may send in your slack message by toggling the checkbox:

4411966593175ContentCalendarContentpipeline-Airtable2021-11-01at95459AM.jpg

You can now set up your message to include custom information including text, emojis, and information from records in Airtable. If you'd like to send all of the information about a single record via a slack message you can insert a record "as a list" as shown below:

4414658836247addrecordtoslack.gif

This will send a message with your record's information neatly formatted:

4414635890071sentmessage.jpg

Testing and previewing the Slack message

After getting all of the necessary pieces of your Slack message set up, it's time to test the action. You'll have the options to "Generate a preview" and "Run as configured." Generating a preview allows you to see what the result will essentially look like in Slack. This will not result in the actual message being sent. Choosing "Run as configured" will send the message out and allow you to run the test. It's good practice to warn the channel or individual that will receive the message to ignore the test message created. Remember that a successful test is necessary to turn the automation on.

5154614874263automationsSlackMessageActionPreviewOrTest03312022.gif

The Slack message preview will be altered based on the way you set up the automation action to run. In the example below, you can see that we've added some text and hyperlinks to the body of the message. Clicking "Generate a preview" causes the preview pop-up to appear.

5154872758039automationsSlackMessageActionPreview03312022.gif

A few things to note:

  • Messages will appear as being sent from Airtable unless you fill in the "Bot name" field under "Show more options."
  • Bot icons added under the "Show more options" menu will not appear in previews.
  • To render properly, URLs must begin with the "https://" or "http://" prefix.

If the test runs successfully, then it's a good idea to double-check in Slack to make sure everything looks the way you want it to. If so, you can now turn on the automation so that your custom Slack message sends out each time it is triggered in Airtable. If the test does not run successfully, then check out our troubleshooting article for some tips.

6616013295255turnautomationon.gif

OAuth scopes and security

Authentication

The next step in the setup process will bring you to a "Connected Accounts" configuration window within Airtable.

360083017413autoAddSlackAccount.gif

If you encounter an error during login, you may need to get in touch with your IT department or check your Slack account settings to enable this integration. After successfully connecting your Slack account to Airtable you can proceed with configuring the action.

NOTE

There is no separate plugin or app that needs to be installed on the user’s Slack instance. The data that we retrieve from Slack's API is transmitted securely via HTTPS and will not be used for any purpose other than the "Send a Slack message" automation.

Slack scopes

For our Slack message action Automation we rely on a few different pieces in their API in order to integrate the two services together. There are a few additional details in the FAQs section below that may be useful if you have additional concerns.

Scope nameScope purpose
channels:readList public Slack channels
groups:readList private Slack channels
users:readList of users and certain metadata
chat:write.botPost to Slack as a bot
chat:write.publicSend messages to channels @your_slack_app isn't a member of

For more information about Slack's scopes we recommend checking out their support documentation here.


FAQs

Can I format my Slack messages?

We recommend referencing this support article from Slack that lists the various ways that you can format your Slack message correctly.

Is Slack data stored on Airtable servers?

We fetch channel and people metadata from Slack in order to render a dropdown list of options in the Slack automation action. We don’t store this list anywhere. It’s fetched and displayed in the UI but does not persist in storage. However, when the user selects a channel/user, we do need to store the ID of the selected channel/user. We don’t store anything else.

What content/info you all would be able to view in addition to channel names, people and emails?

We only show/process the name and ID of each channel/user.


Was this article helpful?