Send the metric results to a Slack channel
You can integrate Synerise with Slack using a dedicated node to build a variety of business scenarios. One of them is building a workflow that sends messages to a Slack channel based on metrics, expressions, reports or any other analyses created in Synerise.
This particular use case reuses a metric (which is a part of an analytical dashboard) that counts the number of customers who signed up for the video call the day before. The message to the channel contains information with the value of the metric.
Prerequisites
- Create an incoming webhook in Slack.
- Implement an event that you want to use in the metric whose result will be sent in a message to a Slack channel.
form.submit
event which we will later used in the metric. Learn more about other ways to implement events using web SDK, mobile SDK or API.Process
Create a metric in Synerise
In this step, we will create a metric whose result will be later sent in the Slack message. The configuration is exemplary, it may vary depending on your implementation of events.
- In Synerise, go to Analytics > Metrics > New metric.
- Leave the metric kind at default (Simple).
- Leave the metric type at default (Event)
- From the Choose event dropdown list, select the form.submit event.
- As the event parameter, select the formType.
- As a logical operator, select Equal (String).
- In the text field, enter
videocall
.
Create a workflow in Synerise
In this part of the process, you will create a workflow that sends a message to a Slack channel with the number of customers who signed up for a video call. The message will contain the metric result and the link to the analytical dashboard that contains the metric.
- In Synerise, go to Automation > Workflows > New workflow.
- Start with the Scheduled Run node. In the configuration of the node:
- Set the Run trigger option to all time.
- Select the Everyday tab.
- Select the time zone.
- Select the time when the workflow will be launched.
- Confirm by clicking Apply.
Configure Slack Integration node
In this step, you will configure the settings of the outgoing integration that sends the message to a Slack channel.
Create a connection
- On the Scheduled Run node, click THEN.
- From the dropdown list, select Slack > Send Channel Message.
- In the configuration of the node:
- If you already create a connection, select the connection from the list.
- If you haven’t created any connection yet:
- At the bottom of the dropdown list, click Add connection.
- In the Incoming Webhook URL field, enter the incoming webhook URL you created as a part of prerequisites.
- Click Next.
- In the Connection name field, enter the name for the connection you created.
- Click Apply.
Result: A connection is created and selected.
Define the integration parameters
-
In the Type of message field, choose interactive message (JSON).
-
Below add JSON body of message which should be sent to Slack channel.
{ "blocks": [ { "type": "section", "text": { "type": "mrkdwn", "text": "Number of people signed in for the videocall: `{% metricsvar metric_id:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX %}{{ metric_result }}{% endmetricsvar %}`\nNumber of people having the videocall today: `{% metricsvar metric_id:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX %}{{ metric_result }}{% endmetricsvar %}`" }, "accessory": { "type": "button", "text": { "type": "plain_text", "text": "check dashboard", "emoji": true }, "url": "https://app.synerise.com/spa/modules/dashboards/analytics/dashboards/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" } } ] }
In the JSON body:
- Insert the ID of the metric you created in the previous step.
- Optionally, if you want to refer users to the analytical dashboard, for the
url
parameter, insert the link to the dashboard. If you choose not to, remove theaccessory
object from the JSON body.
-
Confirm by clicking Apply.
-
Add the End node.
-
Launch the workflow by clicking Save&Run.
Result: The message is sent to the Slack channel.