Use Slack notifications
Last Update: Sep 2024 • Est. Read Time: 6 MINIf your team uses Slack, you can set up a Kustomer workflow to notify a channel whenever a new chat message comes in. This article will walk you through the steps to create a workflow so that you never miss another inbound chat from a customer.
Who can access this feature? | |
User types | Admins can create workflows. |
In this article
Prerequisites
Before following this guide, we recommend that you already be comfortable with the basics of using Workflows: Workflows Overview
You will need to have an active Slack account, and have an understanding of using webhooks and working with developer APIs. These two documents cover necessary background information that will be applied in this walkthrough:
- Slack API: Sending messages using Incoming Webhooks
- Kustomer API: Calling a REST API within a Workflow
Find your Slack Webhook URL
Before you can begin the setup process in Kustomer, you'll need to create an incoming webhook in Slack. To set this up, follow these steps from the Slack API: Sending messages using Incoming Webhooks.
When this setup is complete, make note of your webhook URL; you'll need this later on in the setup process in the Kustomer settings. Your Slack webhook URL will be formatted like this:
https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
Create the Workflow
Now, you'll open up Kustomer. The first step will be to create the workflow.
- Go to Settings > Platform > Workflows.
- Select Add Workflow.
- The New Workflow modal will appear. Fill out the Workflow Title; you can leave the Description field blank because our code snippet will provide this for you.
- Select Create to save the workflow and begin working in the Workflow Editor.
Enter the Workflow JSON code
You will then use the Workflow Editor to paste in a workflow code supplied below. This JSON code will take care of most of the workflow creation, aside from a few placeholder values that you'll need to update manually.
- In the Workflow Editor, use the Workflow Optionsto select Edit Workflow JSON.
- A modal appears where you can edit the code for this workflow directly. Select and delete the current JSON code.
- Copy this code block, and paste it into the JSON text field in your Workflow Editor:
{ "description": "Posts to Slack whenever a message is created with message conversation details.", "name": "slack", "steps": [ { "id": "eeWBChdww", "transitions": [ { "meta": { "name": "Email or SMS?" }, "condition": { "values": [ { "values": [ "/#steps.1.channel", "email" ], "op": "contains" }, { "values": [ "/#steps.1.channel", "sms" ], "op": "contains" } ], "op": "or" }, "target": "cSS3Gw1fV" } ] }, { "appVersion": "kustomer-^1.2.1", "params": { "identifier": "/#steps.1.customer" }, "action": "kustomer.customer.find", "id": "cSS3Gw1fV", "transitions": [ { "condition": { "values": [ true ], "op": "true" }, "target": "VIK9f-WHk" } ] }, { "appVersion": "kustomer-^1.2.1", "params": { "id": "/#steps.1.conversation" }, "action": "kustomer.conversation.find-by-id", "id": "VIK9f-WHk", "transitions": [ { "meta": { "name": "Inbound?" }, "target": "eH6zZmIOm", "condition": { "op": "eq", "values": [ "/#steps.1.direction", "in" ] } } ] }, { "appVersion": "kustomer-^1.2.1", "params": { "headers": { "Content-Type": "application/json" }, "uri": "SLACKHOOKHERE", "method": "POST", "json": true, "data": { "attachments": [ { "fallback": "New message in Kustomer for conversation: {{steps.VIK9f-WHk.name}}", "pretext": "New message in Kustomer for conversation {{steps.1.conversation}}", "title": "Go to conversation", "title_link": "https://ORGNAME.kustomerapp.com/app/conversations/{{steps.1.conversation}}", "color": "#D00000", "fields": [ { "title": "Event", "value": "Outbound Message Created", "short": false }, { "title": "Customer Name", "value": "/#steps.cSS3Gw1fV.name", "short": false }, { "title": "Subject", "value": "/#steps.VIK9f-WHk.name", "short": false }, { "title": "Conversation Status", "value": "/#steps.VIK9f-WHk.status", "short": false }, { "title": "Message Direction", "value": "/#steps.1.direction", "short": false }, { "title": "Message Body", "value": "/#steps.1.preview", "short": false } ] } ], "username": "Kustomer", "channel": "#CHANNELNAME" } }, "action": "kustomer.rest-api.json", "id": "eH6zZmIOm", "transitions": [] } ], "trigger": { "transitions": [ { "meta": { "name": "Filter imported messages" }, "condition": { "values": [ "/#steps.1.importedAt" ], "op": "dne" }, "target": "eeWBChdww" } ], "eventName": "kustomer.message.create", "id": "1", "appVersion": "kustomer-^1.2.1" } }
- On the following lines, update the placeholder strings as follows:
- line 83:
SLACKHOOKHERE
- The webhook URL from Slack, which you located earlier. - line 92:
ORGNAME
- Your Kustomer org subdomain. - line 129:
#CHANNELNAME
- The Slack channel where you want notifications to be posted.
- line 83:
- Select Update to dismiss the JSON editor and save the changes to this workflow.
- If there are any other changes to this workflow that you'd like to make, you can do so now. When you're finished, Save and exit the Workflow Editor.
When you're ready to activate this workflow, use the toggle in the Workflow Settings to switch it on or off.