Slack

Send your event data from RudderStack to Slack.

Slack is a popular business communication platform that lets you organize all your business-related chats by specific topics, groups, or direct messaging.

Find the open source transformer code for this destination in the GitHub repository.

Connection compatibility

Destination info
  • Status: Generally Available
  • Supported sources: Android, iOS , Web, Unity, AMP , Cloud, Warehouse, React Native , Flutter, Cordova, Shopify
  • Refer to it as SLACK in the Integrations object.

Connection modes
SourceCloud modeDevice modeHybrid mode
AMPsupportednot supportednot supported
Androidsupportednot supportednot supported
Cloudsupportednot supportednot supported
Cordovasupportednot supportednot supported
Fluttersupportednot supportednot supported
iOSsupportednot supportednot supported
React Nativesupportednot supportednot supported
Shopifysupportednot supportednot supported
Unitysupportednot supportednot supported
Warehousesupportednot supportednot supported
Websupportednot supportednot supported
Supported message types
SourceIdentifyPageTrackScreenGroupAlias
Cloud mode
Supported sourcessupportednot supportedsupportednot supportednot supportednot supported

Get started

Once you have confirmed that the source platform supports sending events to Slack, follow these steps:

  1. From your RudderStack dashboard, add a source. Then, from the list of destinations, select Slack.
  2. Assign a name to the destination and click Continue.

Connection settings

To successfully configure Slack as a destination, you will need to configure the following settings:

Event channel settings

Use the following settings to send an event to a particular Slack channel:

SettingDescription
Type of incoming webhooksSelect the API from the dropdown that RudderStack uses to send data to the particular Slack channel:

SettingDescription
LegacyRudderStack maps the channel based on the Event Channel Name setting. This method may be deprecated soon.
Modern (through app)RudderStack maps the channel based on the Event Channel Webhook setting.
Event NameEnter the event name or regex to match the RudderStack event name. For example, the regex ^slack\.events\.[a-zA-Z_]+$ matches strings like:

  • slack.events.message
  • slack.events.reaction_added
  • slack.events.user_typing
info
If an event matches a regex, then RudderStack uses the corresponding Event Channel Webhook and Event Template (if specified).
Event Channel WebhookEnter the webhook URL of the Slack channel where RudderStack sends the above event. This is a required field if you have set Type of incoming webhooks setting to Modern.

Note: To get the URL for Event Channel Webhook setting, make sure to:

  1. Create a Slack app with the Incoming Webhooks feature.
  2. Authorize the app to post to your specified Slack channel.
See Sending messages using Incoming Webhooks for more information.
Event Channel NameEnter the Slack channel’s name where RudderStack should send the above event using the legacy method. You can specify #channel_name or @user_name.

Note: If not specified, RudderStack sends the events to the Slack channel associated with the incoming webhook URL (see Webhook URL setting below).
Regex MatchingTurn on this setting if you are specifying a regular expression in the Event Name setting.

info
RudderStack adds the global g parameter implicitly. Hence, you need not add it with the regex.

Identify template settings

SettingDescription
Identify TemplateSpecify the template used to transform the identify event before sending it to Slack. RudderStack uses the following default template:

Identified {{name}} <traits_key>:<traits_value> <traits_key2>:<traits_value2> ….


Note: Here, the traits key and value are the key-value pairs in the traits object of the identify event payload.

RudderStack determines the {{name}} field in the above template from either of the following:

  • traits.name
  • traits.firstName + traits.lastName
  • traits.username
  • properties.email
  • traits.email
  • userId
  • anonymousId
warning
RudderStack considers only the traits listed in the Allowlisted Traits setting as a part of the identify template and ignores any other traits.

Event template settings

Use the following settings to transform an event before sending it to Slack:

SettingDescription
Event NameEnter the event name or regex to match the RudderStack event name. For example, the regex ^slack\.events\.[a-zA-Z_]+$ matches strings like:

  • slack.events.message
  • slack.events.reaction_added
  • slack.events.user_typing
Event TemplateSpecify the template used to transform the above event.

Note: RudderStack uses the following template by default and determines name similar to the Identify Template setting described above.

{{name}} did {{event}}
Regex MatchingTurn on this setting if you are specifying a regular expression in the Event Name setting.

Incoming webhook URL settings

info
RudderStack sends all the events to the channel associated with the incoming webhook URL by default.
SettingDescription
Webhook URLEnter your Slack’s incoming webhook URL. See the FAQ section for more information on obtaining this URL.

Other settings

SettingDescription
Allowlisted TraitsSpecify the user traits you want to allowlist.

Note: If not specified, RudderStack sends all the user traits to Slack.
Denylisted EventsEnter the events to add to your denylist, causing RudderStack to drop these events.
Consent management settingsConfigure the consent management settings for the specified source by choosing the Consent management provider from the dropdown and entering the relevant consent category IDs. See Consent Management in RudderStack for more information on this feature.

Handlebar expressions

RudderStack supports Handlebar expression by leveraging the handlebars.js library for including the variables into your dynamic Slack messages.

Accessible Variables

The following table lists the variables you can select in your template messages:

Handlebar expressionOutput
{{name}}Identity name of the user in the priority order listed above.
{{event}}Event name, for example, Product Viewed or user login.
{{key_1}}
{{properties.key_1}}
The property values from the event’s properties object.
{{propertiesList}}JSON stringified version of your properties object.
{{traits}}JSON stringified version of your traits object.
{{traitsList.key_1}}The trait values from the event’s traits object.

Escaped content

The values returned by {{variable}} are HTML-escaped. For example, if a variable has a & in its value then it will be returned as &amp;. To avoid this behavior, you can use the triple curly braces instead of double, like {{{variable}}} instead of {{variable}}. This will stop the handlebars from escaping a value if there is one, as shown in the following example:

ExpressionVariableResult
{{variable}}"Marcia & Jan""Marcia &amp; Jan"
{{{variable}}}"Marcia & Jan""Marcia & Jan"

For more information on the escaped content, refer to the Handlebar guide.

Identify

The identify call lets you identify a visiting user and associate them to their actions. It also lets you record the traits about them like their name, email address, etc.

A sample identify call for a template, like Identified {{name}} with {{traits}}, is shown below:

rudderanalytics.identify("1hKOmRA4el9Zt1WSfVJIVo4GRlm", {
  name: "Alex Keener",
  email: "alex@example.com",
  country: "USA",
});

For the above event, you will see the message Identified Alex Keener with name: Alex Keener email: alex@example.com country: USA in your configured Slack channel.

Track

The track call lets you record the user events, that is, the actions your users perform, along with any properties associated with these actions.

A sample track call for a template {{name}} performed {{event}} with {{properties.key1}} {{properties.key2}} after the user is identified is as follows:

rudderanalytics.track("test_event", {
  "key1": "test_val1",
  "key2": "test_val2",
  "key3": "test_val3"
})

For the above snippet, you will see the message Alex Keener performed test_event with test_val1 test_val2 test_val3 in your configured Slack channel.

FAQ

How do I obtain the incoming webhook URL?

To obtain the webhook URL, follow the below steps:

  1. Click your Slack workspace name, then go to Administration > Manage Apps.
  2. Search for Incoming webhooks in the Slack app directory and add it to Slack by clicking on Add to Slack.
  3. Select a channel where you want to post the messages forwarded by the webhook and click Add Incoming webhooks integration.
Slack connection settings
  1. Finally, copy the webhook URL and enter it in the RudderStack dashboard.
Slack connection settings

Why am I getting Slack messages for all the incoming events in one channel?

By default, RudderStack sends all the events to the Slack channel associated with the incoming webhook URL (Webhook URL setting in the RudderStack dashboard).

To get specific events in a particular channel, make sure you specify the mappings using the Event Name and Event Channel settings.


Questions? Contact us by email or on Slack