Slack has become very popular in business community. And of the most powerful features of Slack is integration with all kinds of other tools. Here’s a quick guide how to simply send messages from Exponea to a channel on Slack.
Requirements
Before you start, make sure you have all these in place:
- Have an active Slack team/account (Create)
- Have an active Exponea account (Create)
- Have some custom events already in Exponea (Tracking guide)
Sample use-case: Tracking new registrations
There are many information you could send to a Slack channel. As we are in a growth stage, one of the most important performance indicators for us are new registrations. Moreover, if we see that a new user has registered, our consultants can immediately react and offer him or her support. We already tracked registration event on submit of registration form (see here), so it was easy to set up the whole thing.
- In your Exponea project select “Campaigns” > “Scenarios” > “Create new”
- Add “On event”, open it (double click) and select “Registration” event
- Add “Webhook” and connect “On event registration” to “Unnamed webhook”
Now we need URL for Slack webhook and content to be sent. Slack has nice guide about incoming webhooks and they also explain JSON in the document.
- Create a webhook URL in Slack for existing or new channel
- Open “Unnamed webhook” in a scenario, give it a name, switch to “Per Customer”
- Copy&paste the “Webhook URL” from Slack to “Endpoint URL” in Exponea
- Create a content (equivalent to “payload” in Slack)
Testing
If you save and execute scenario then after new each new registration you’ll receive a new message to your Slack channel from Slack bot.
If you need to trigger the event faster, you can do it from console on your website. Open Javascript console and type: exponea.track(‘registration’). It will trigger message in Slack.
Scheduling
You could change a flow to send message immediately. “Now” trigger would send message to all customers in Exponea. To avoid spam add “Condition” and select “email” equals “your own email”. Connect “Condition” to “Webhook” and execute scenario. Message will be sent only once and immediately.
Similarly you could schedule sending messages to once per day/week by using “Repeat trigger”. Again don’t forget to use condition and limit customers.
Content personalization
Slack comes with nice features to customize messages:
- “username”: “Exponea Registration Bot” – will change name of Slack user who sends messages
- “icon_url”: “”icon_url”: “http://cdn0.capterra-static.com/logos/150/2106461.png” – changes user’s icon
- “icon_emoji”: “:ghost:” – uses emoji as user’s icon
- “channel”: “:ghost:” – sends message to specified channels instead of to default
Exponea enables to personalise messages even further:
- Customer attribute can be used to include data about customer who triggered campaign (e.g. customer.email)
- Triggered event can be used to include attributes from event what triggered campaign (e.g. registration.source)
- Metrics can be used to include statistics about your company, e.g. # of users registered last month
Example:
{"text": "{{ event.email }} has registered on {# instance_id #}{{ aggregates['5742f3428304341843aa91fb'] }}. {# # new registrations today #}{{ metrics['57599796fb6009610c3fa35f'] }} registration today. {% if event.promo_code %} Promo code:{{ event.promo_code }}.{% endif %} {% if aggregates['5759971bfb6009610c3fa35d'] %} Source: {# UTM_Campaign #}{{ aggregates['5759971bfb6009610c3fa35d'] }}. {% endif %}", "username": "Registration", "icon_url": "http://cdn0.capterra-static.com/logos/150/2106461.png"}
Putting it all together in a scenario designer
Result will looks like this:
Quiz: What have I done wrong and why I’ve spammed our Slack channel for last two days? Answer is in a screenshot above. I will rewards the first answer (email me now) with a bottle of sweet Tokaj wine or a copy Lean Startup book. Will publish the winner’s name here. It’s still open!