How to setup and use Slack's API for reporting
If you have access to a Slack account and would like to receive notifications from Synatic, please follow the below instructions:
Illustrated below are the steps to setup Slack API and an example of a flow that will query a buffer for Error messages each day and use Slack API to send out notifications to a Slack channel.
How to setup Slack's API
- Click on the link below and click on the green Create an App button as shown in the image below.
- Select From Scratch. Type a meaningful app name as your App Name and select the workspace. Click on Create App as per the images below.
- The App Management landing page will appear. Click on Incoming Webhooks on the left menu and toggle the Off button to Activate Incoming Webhooks as illustrated in the image below.
- The image below shows a sample Curl request. Click on Add New Webhook to Workspace button as highlighted.
- Select the Slack channel you require to post messages/notifications to and click on the green Allow button as shown in the below image.
The sample Curl request will be updated with the API URL as illustrated in the image below.
- Select OAuth & Permissions from the navigation menu on the left of the page and you will be able to view and copy your Bearer OAuth token for authentication as shown in the below page.
- Scroll to the bottom of the page to Add Scopes/Permissions for the app as highlighted in the below image. The following are the basic permissions are required for this use case:
chat:write
chat:write:public
chat:write:customize
-
Post messages to the Slack Channel. Mimic a bot sending a message to the channel as well as customizing the messages. As soon as that is completed, click on Reinstall Your App on the ribbon at the top of the page.
-
Create a flow on Synatic that will query a buffer using the Buffer Query source step and send the errors to the Slack channel using the HTTP Service destination step as per the image below.
- The Buffer Query is used to pull out all required fields stored in the Run Events Buffer, We are interested in the flow, run, and error details.
Note: When querying error logging buffers it is good practice to use alias names to reference fields since some of the field names in the buffer might clash with the object names in the current flow.
- In the Calculator step, a Slack message is created as illustrated in the below image.
- The HTTP destination step will use the Slack API to pass the message as a body to the Slack channel as illustrated in the image below. The URL is available on the Incoming webhooks from the Slack API configuration page and the Bearer token can be found on the OAuth and permission page.
The below image is the message that will be posted in the selected Slack channel.