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:

  1. Configure the Slack App Bot.
  2. Create the Slack Target.

Configure the Slack App

  1. Create a new Slack App
  2. From Basic Information, Features and functionality, select the Permissions pane.
  3. At Bot Token scopes add chat:write.
  4. From Install App menu follow steps to deploy to your workspace.
  5. 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.

Adding a Slack Target

In the Target creation form, provide a name for the event Target, and add the following information:

Slack Target form

After clicking the Save button, the console will self-navigate to the Bridge editor. Proceed by adding the remaining components to the Bridge.

Bridge overview

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.

Bridge status

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}'