Cloud

slack

Connects to Slack using Socket Mode and receives events, interactions, and slash commands.

This input connects to Slack using Socket Mode. Use it to build bots that respond to Slack activity, or to stream Slack events into other systems, such as a data warehouse.

Metadata

This input adds the following metadata fields to each message:

  • type: The Socket Mode event type: events_api, interactive, or slash_commands.

input:
  label: ""
  slack:
    app_token: "" # No default (required)
    bot_token: "" # No default (required)
    auto_replay_nacks: true

See also: Examples

Fields

app_token

The app-level token, which starts with xapp-. The input uses it to open the Socket Mode connection, so it needs the connections:write scope.

Type: string

auto_replay_nacks

Whether to automatically replay rejected messages (negative acknowledgements, or nacks) at the output level. If the cause of rejections persists, leaving this option enabled can result in back pressure.

Set auto_replay_nacks to false to delete rejected messages. Disabling auto replays can greatly improve memory efficiency of high throughput streams, as the original shape of the data is discarded immediately upon consumption and mutation.

Type: bool

Default: true

bot_token

The OAuth token of your Slack bot user, which starts with xoxb-.

Type: string

Examples

Echo Slackbot

A slackbot that echo messages from other users

input:
  slack:
    app_token: "${APP_TOKEN:xapp-demo}"
    bot_token: "${BOT_TOKEN:xoxb-demo}"
pipeline:
  processors:
    - mutation: |
        # ignore hidden or non message events
        if this.event.type != "message" || (this.event.hidden | false) {
          root = deleted()
        }
        # Don't respond to our own messages
        if this.authorizations.any(auth -> auth.user_id == this.event.user) {
          root = deleted()
        }
output:
  slack_post:
    bot_token: "${BOT_TOKEN:xoxb-demo}"
    channel_id: "${!this.event.channel}"
    thread_ts: "${!this.event.ts}"
    text: "ECHO: ${!this.event.text}"