Event Target for Slack
This event target receives CloudEvents over HTTP and sends them to Slack using the Slack Web API.
Prerequisites
A Slack user that can manage applications is required to configure the target.
Create the Slack Target Integration
Create the Slack target integration in 2 steps:
- Configure the Slack App Bot.
- Create the Slack Target.
Configure the Slack App
- Create a new Slack App
- From Basic Information, Features and functionality, select the
Permissions
pane. - At Bot Token scopes add
chat:write
. - From
Install App
menu follow steps to deploy to your workspace. - Copy the Bot OAuth Access token, it should begin with
xoxb-...
Create the Slack Target
From TriggerMesh, open the Bridge creation screen and add a Target of type Slack
.
In the Target creation form, provide a name for the event Target, and add the following information:
- Slack Secret: Reference a TriggerMesh secret containing a Slack API token
After clicking the Save
button, the console will self-navigate to the Bridge editor. Proceed by adding the remaining components to the Bridge.
After submitting the bridge, and allowing some configuration time, a green check mark on the main Bridges page indicates that the bridge with the Slack Target was successfully created.
For more information about using the Slack API, please refer to the documentation.
Events
CloudEvents consumed by this target must be of one of these types:
com.slack.webapi.chat.postMessage
com.slack.webapi.chat.scheduleMessage
com.slack.webapi.chat.update
Data for each of them must be a JSON message as expected by the Slack API:
Example
Post message:
curl -v http://slack-target:8080 \
-X POST \
-H "Content-Type: application/json" \
-H "Ce-Specversion: 1.0" \
-H "Ce-Type: com.slack.webapi.chat.postMessage" \
-H "Ce-Source: awesome/instance" \
-H "Ce-Id: aabbccdd11223344" \
-d '{"channel":"C01112A09FT", "text": "Hello from Triggermesh!"}'
Schedule message:
curl -v http://slack-target:8080 \
-X POST \
-H "Content-Type: application/json" \
-H "Ce-Specversion: 1.0" \
-H "Ce-Type: com.slack.webapi.chat.scheduleMessage" \
-H "Ce-Source: awesome/instance" \
-H "Ce-Id: aabbccdd11223344" \
-d '{"channel":"C01112A09FT", "text": "Hello from scheduled Triggermesh!", "post_at": 1593430770}'