Skip to content

Slack source

This event source uses the Slack Events API through a bot user to ingest events into TriggerMesh.

With tmctl:

tmctl create source slack

On Kubernetes:

apiVersion: sources.triggermesh.io/v1alpha1
kind: SlackSource
metadata:
  name: sample
spec:
  # optional, making sure we are receiving events on behalf of Slack
  signingSecret:
    value: XXXXXXXXXXXXXXXXXX

  # optional, making sure the events are being sent for this integration
  appID: AXXXXXXXXX

  sink:
    ref:
      apiVersion: eventing.triggermesh.io/v1alpha1
      kind: RedisBroker
      name: triggermesh

Events produced have the following attributes:

  • type com.slack.events
  • source Team ID (Slack workspace)
  • Schema of the data attribute: com.slack.events.json

Event data example:

{
  "blocks": [
    {
      "block_id": "ws9ME",
      "elements": [
        {
          "elements": [
            {
              "text": "waving hello ",
              "type": "text"
            },
            {
              "type": "user",
              "user_id": "U015NKH6R6G"
            }
          ],
          "type": "rich_text_section"
        }
      ],
      "type": "rich_text"
    }
  ],
  "channel": "C01112A09FT",
  "channel_type": "channel",
  "client_msg_id": "9fc2ed3e-c823-4dcf-be6b-4d788ab0beea",
  "event_ts": "1592732675.009400",
  "team": "TA1J7JEBS",
  "text": "waving hello \u003c@U015NKH6R6G\u003e",
  "ts": "1592732675.009400",
  "type": "message",
  "user": "UT8LFLXR8"
}

See the Kubernetes object reference for more details.

Prerequisite(s)

  • A Slack user that can manage applications is required to configure the source.

Create the Slack Source Integration

Deploy the Slack source in 3 steps:

  1. Deploy the Slack source, retrieve exposed endpoint at TriggerMesh.
  2. Configure Slack App to send events to the Slack Source endpoint.
  3. (optional) Modify the Slack Source to add Signing Secret and AppID from the configured App.

Deploy Slack Source

Create an instance of the Slack Source with TriggerMesh.

Copy the URL for the exposed service.

Configure Slack Events API App

  1. Create a new [Slack App][slack-app]

Slack app

  1. From Basic Information, Features and functionality, select Event Subscriptions

Features and functionality

  1. Slide the Enable Events selector to on and write the Slack source exposed URL at the Request URL box. A request with a verification challenge will be sent and when the Slack source adapter answer it will be validated and a green check will be shown.

Request URL verified

  1. At the Subscribe to bot events section select the bot events that will be sent on behalf of this integration and then press Save Changes at the bottom of the page.. Refer to Slack documentation on which ones to use, as a hint the we think these 3 could be useful for different scenarios:

  2. app_mention will send an event when the App is mentioned.

  3. message.im will send an event when sending a direct message to the App.
  4. message.channels an event will be sent for each message at a channel where the App is invited.

Subscribe

  1. At Install App section click on Install App to Workspace

Install to workspace

  1. (Optional)Return to the application's Basic Information and take note of App ID and Signing Secret

    Retrieve info

You will now have a working integration. Any Slack action that matches the configured event subscription will be sent to the Slack Source and from there to the sink.