Slack
Step-by-step guide to set up Slack as a destination in RudderStack
Last updated
Was this helpful?
Step-by-step guide to set up Slack as a destination in RudderStack
Last updated
Was this helpful?
Slack is a popular business communication platform that lets you organize all your business-related chats by specific topics, groups, or direct messaging.
RudderStack supports Slack as a destination where you can send your event data seamlessly.
Find the open source transformer code for this destination in the GitHub repository.
Before configuring Slack as a destination in RudderStack, verify if the source platform is supported by Slack by referring to the table below:
Connection Mode
Web
Mobile
Server
Device mode
-
-
-
Cloud mode
Supported
Supported
Supported
To know more about the difference between cloud mode and device mode in RudderStack, refer to the RudderStack Connection Modes guide.
Once you have confirmed that the platform supports sending events to Slack, perform the steps below:
From your RudderStack dashboard, add the source. Then, from the list of destinations, select Slack.
Assign a name to the destination and click on Next.
To successfully configure Slack as a destination, you will need to configure the following settings:
Event Name: Enter the event name or the regex to match the RudderStack event name.
Event Channel: Enter the name of the Slack channel where the event will be sent. You can specify #channel_name
or @user_name
.
Regex Matching: Enable this setting if the event name in the first parameter is a regular expression.
RudderStack adds the global g
parameter implicitly. Hence, you need not add it with the regex.
Identify Template: Specify the template that you want the identify
event to be transformed to before it is sent to Slack. The default template is shown below:
Here, the traits key and value are the key-value pairs in the traits
object of the identify
event payload.
The name
field in the template is determined from either of the following:
traits.name
traits.firstName + traits.lastName
traits.username
properties.email
traits.email
User userId
Anonymous user anonymousId
Note that only the traits listed in the Whitelisted Traits section are considered to be a part of the identify template. The rest of them are sent to Slack.
Event Name: Enter the event name or the regex to match the RudderStack event name.
Event Template: Specify the template for the above event names matching the regex. The default template is as shown:
Here, name
is determined in the same way as described in the Identify Template section above.
Regex Matching: Enable this setting if the event name is a regex in the first parameter.
Webhook URL: Enter your Slack's incoming webhook URL.
To obtain the webhook URL, follow the below steps:
Click on your Slack workspace name, then go to Administration > Manage Apps.
Search for Incoming webhooks in the Slack app directory and add it to Slack by clicking on Add to Slack.
Select a channel where you want to post the messages forwarded by the webhook and click on Add Incoming webhooks integration.
Finally, copy the webhook URL and enter it in the RudderStack dashboard.
RudderStack supports Handlebar expression by leveraging the handlebars.js
library for including the variables into your dynamic Slack messages.
The following table lists the variables you can select in your template messages:
{{name}}
Identity of the user in the priority listed above.
{{event}}
Event name, that is, product viewed
or user login
.
{{<key_1>}}
or{{properties.<key_1>}}
Any of 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>}}
Any of the trait values from the event's traits object.
The values returned by the {{variable}}
are HTML-escaped. For example, if a variable
has a &
in its value then it will be returned as &
. 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:
{{variable}}
"Marcia & Jan"
"Marcia & Jan"
{{{variable}}}
"Marcia & Jan"
"Marcia & Jan"
Refer to the Handlebar document for more information on the escaped content.
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 as shown:
As a result, you will see this message Identified Alex Keener with name: Alex Keener email: alex@example.com country: USA
in your configured Slack channel.
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, like {{name}} performed {{event}} with {{properties.key1}} {{properties.key2}}
and the following track call, after being identified as above:
As a result, you will see the message Alex Keener performed test_event with test_val1 test_val2 test_val3
in your configured Slack channel.
For queries on any of the sections covered in this guide, you can contact us or start a conversation in our Slack community.