The new Slack platform is in beta. Your feedback is most welcome.

Event Triggers

Invoke a Workflow when a specific event happens in Slack

Event Triggers are another type of automatic Trigger, in that they don't require manual activation. They won't be triggered on their own, however. Instead, they're automatically triggered when a certain event happens.

Your app needs to have the proper scopes to use Event Triggers. Include these scopes within your app's manifest.

There are two steps to setting up an Event Trigger:

  1. Define the Trigger
  2. Create the Trigger, either via the CLI or at runtime

Supported events

These are the events that are currently supported for using with Event Triggers:

Supported Event Description Required Scopes
app_mentioned Subscribe to only the message events that mention your app or bot app_mentions:read
channel_archived A channel was archived channels:read
channel_created A channel was created channels:read
channel_deleted A channel was deleted channels:read
channel_renamed A channel was renamed channels:read
channel_shared A channel has been shared with an external workspace channels:read groups:read
channel_unarchived A channel was unarchived channels:read
channel_unshared A channel has been unshared with an external workspace channels:read groups:read
dnd_updated Do not Disturb settings changed for a member dnd:read
emoji_changed A custom emoji has been added or changed emoji:read
user_joined_channel A user joined a public or private channel channels:read groups:read
user_left_channel A user left a public or private channel channels:read groups:read
message_posted A message was sent to a channel channels:history groups:history im:read mpim:read
message_metadata_posted Message metadata was posted metadata.message:read
pin_added A pin was added to a channel pins:read
pin_removed A pin was removed from a channel pins:read
reaction_added A member has added an emoji reaction to an item reactions:read
reaction_removed A member removed an emoji reaction reactions:read
shared_channel_invite_accepted A shared channel invite was accepted conversations.connect:manage
shared_channel_invite_approved A shared channel invite was approved conversations.connect:manage
shared_channel_invite_declined A shared channel invite was declined conversations.connect:manage
shared_channel_invite_received A shared channel invite was sent to a Slack user conversations.connect:read
user_joined_team A new member has joined users:read

We'll continue to add more triggerable events in the future. Stay tuned!

1. Define the Trigger

A Trigger contains a Typescript payload with the following parameters:

Parameters

Field Description Required
type The type of Trigger: event
name The name of the Trigger
workflow Path to Workflow that the Trigger initiates
description The description of the Trigger
inputs The inputs provided to the Workflow. Can use with the event response object
event Contains the Event Object. See below

The Event object

Field Description Required
event_type The type of event
channel_ids An array of event-related channel ID strings
filter See Trigger Filters
team_ids An array of event-related team ID strings

Event response object

An event's response object will contain additional information about that specific event instance.

Property Description
team_id A unique identifier for the workspace/team where this event occurred.
enterprise_id A unique identifier for the enterprise where this event occurred.
event_id A unique identifier for this specific event, globally unique across all workspaces.
event_timestamp A UNIX timestamp in seconds indicating when this event was dispatched.
type An identifier showing the event type
data Contains additional information dependent on event type

Each type of event has unique sub-properties within the data property. You can pass these values on to your Workflows.

app_mentioned
{
         "team_id": "T0123ABC",
         "enterprise_id": "E0123ABC",
         "event_id": "Ev0123ABC",
         “event_timestamp”: 1643810217.088700,
         “type”: “event”,
         “data”: {
              "event_type": “slack#/events/app_mentioned",
              “user_id:”: “U0123ABC”,
              “text”: "<@U0LAN0Z89> is it everything a river should be?",
              “channel_id”: "C0123ABC”,
             "channel_type": "public/private/im/mpim",
              “channel_name”: “cool-channel”
         }
}
channel_archived
{
         "team_id": "T0123ABC",
         "enterprise_id": "E0123ABC",
         "event_id": "Ev0123ABC",
         "event_timestamp": 1630623713,
         "type": "event",
         "data": {
             "event_type": "slack#/events/channel_archived",
             “user_id”: "U0123ABC",
             “channel_id”: "C0123ABC”,
             "channel_type": "public/private/im/mpim",
         }
}
channel_created
{
         "team_id": "T0123ABC",
         "enterprise_id": "E0123ABC",
         "event_id": "Ev0123ABC",
         "event_timestamp": 1630623713,
         "type": "event",
         "data": {
             "event_type": "slack#/events/channel_created",
             “channel_id": “C0123ABC”,
             “channel_name": “fun”,
             “channel_type": “public”,
             "creator_id": "U0123ABC”
              “created": 1360782804,
         }
}
channel_deleted
{
         "team_id": "T0123ABC",
         "enterprise_id": "E0123ABC",
         "event_id": "Ev0123ABC",
         “event_timestamp”: 1643810217.088700,
         “type”: “event”,
         “data”: {
             "event_type": “slack#/events/channel_deleted",
              "channel_id": "C0123ABC",
              "channel_type": "public/private/im/mpim",
              "channel_name": "project_planning",
              "user_id": "U0123ABC",
         }
}
channel_renamed
{
         "team_id": "T0123ABC",
         "enterprise_id": "E0123ABC",
         "event_id": "Ev0123ABC",
         “event_timestamp”: 1643810217.088700,
         “type”: “event”,
         “data”: {
             "event_type": “slack#/events/channel_renamed",
             "user_id": "U0123ABC",
             "channel_id": "C0123ABC",
              "channel_type": "public/private/im/mpim",
              "channel_name": "project_planning",
         }
}
channel_shared
{
         "team_id": "T0123ABC",
         "enterprise_id": "E0123ABC",
         "event_id": "Ev0123ABC",
         “event_timestamp”: 1643810217.088700,
         “type”: “event”,
         “data”: {
              "event_type": “slack#/events/channel_shared",
              “connected_team_id”: “E0123ABC”
              “channel_id”: "C0123ABC”,
             "channel_type": "public/private/im/mpim",
              “channel_name”: “cool-channel”
         }
}
channel_unarchived
{
         "team_id": "T0123ABC",
         "enterprise_id": "E0123ABC",
         "event_id": "Ev0123ABC",
         “event_timestamp”: 1643810217.088700,
         “type”: “event”,
         “data”: {
              "event_type": “slack#/events/channel_unarchived",
             “user_id”: "U0123ABC",
             “channel_id”: "C0123ABC”,
             "channel_type": "public/private/im/mpim",
              “channel_name”: “cool-channel”
         }
}
channel_unshared
{
         "team_id": "T0123ABC",
         "enterprise_id": "E0123ABC",
         "event_id": "Ev0123ABC",
         “event_timestamp”: 1643810217.088700,
         “type”: “event”,
         “data”: {
              "event_type": “slack#/events/channel_unshared",
              “disconnected_team_id”: “E0123ABC”,
              “is_ext_shared”: false,
              “channel_id”: "C0123ABC”,
             "channel_type": "public/private/im/mpim",
              “channel_name”: “cool-channel”
         }
}
dnd_updated
{
         "team_id": "T0123ABC",
         "enterprise_id": "E0123ABC",
         "event_id": "Ev0123ABC",
         "event_timestamp": 1630623713,
         "type": "event",
         "data": {
             "event_type": "slack#/events/user_updated_dnd",
             "user_id": "U0123ABC",
             "dnd_status": {
                  "dnd_enabled": true,
                  "next_dnd_start_ts": 1450387800,
                  "next_dnd_end_ts": 1450423800
             }
         }
}
emoji_changed
{
         "team_id": "T0123ABC",
         "enterprise_id": "E0123ABC",
         "event_id": "Ev0123ABC",
         "event_timestamp": 1630623713,
         "type": "event",
         "data": {
             "event_type": "slack#/events/emoji_changed",
             “subtype”: “remove”,  // remove, rename, add
             “names”: [“picard_facepalm”],
             "message_ts" : "1361482916.000004"
         }
}
user_joined_channel
{
         "team_id": "T0123ABC",
         "enterprise_id": "E0123ABC",
         "event_id": "Ev0123ABC",
         "event_timestamp": 1630623713,
         "type": "event",
         "data": {
             "event_type": "slack#/events/user_joined_channel",
             "user_id": "U0123ABC",
             "channel_id": "C0123ABC",
             "inviter_id": "U0123ABC",
             "channel_type" : "public/private/im/mpim"
         }
}
user_left_channel
{
         "team_id": "T0123ABC",
         "enterprise_id": "E0123ABC",
         "event_id": "Ev0123ABC",
         "event_timestamp": 1630623713,
         "type": "event",
         "data": {
             "event_type": "slack#/events/user_left_channel",
             "user_id": "W0123ABC",
             "channel_id": "C0123ABC",
             "channel_type" : "public/private/im/mpim"
         }
}
message_posted
{
         "team_id": "T0123ABC",
         "enterprise_id": "E0123ABC",
         "event_id": "Ev0123ABC",
         "event_timestamp": 1630623713,
         "type": "event",
         "data": {
             "event_type": "slack#/events/message_posted",
             "channel_type": "public/private/im/mpim",
             "channel_id": "C0123ABC",
             "user_id": "U0123ABC",
             "text": "Hello world",
             "message_ts": "1355517523.000005",
             "thread_ts": "1355517523.000006", // Nullable
         }
}
message_metadata_posted
{
         "team_id": "T0123ABC",
         "enterprise_id": "E0123ABC",
         "event_id": "Ev0123ABC",
         “event_timestamp”: 1630623713,
         “type”: “event”,
         “data”: {
              "event_type": “slack#/events/message_metadata_posted",
              "app_id": "A0123ABC",
              "user_id": "U0123ABC",
              "channel_id": "C0123ABC",
              "message_ts": "1630708981.000001”
              "metadata": {
                  "event_type": "incident_created",
                  "event_payload": {
                     “incident”: {
                          "id": 123,
                          "summary": "Someone tripped over",
                          "sev": 1
                      }
                  }
            } 
    }
pin_added
{
         "team_id": "T0123ABC",
         "enterprise_id": "E0123ABC",
         "event_id": "Ev0123ABC",
         “event_timestamp”: 1643810217.088700,
         “type”: “event”,
         “data”: {
             "event_type": “slack#/events/pin_added",
              "channel_id": "C0123ABC",
              “user_id” "U0123ABC”,
              "channel_type": "public/private/im/mpim",
              "channel_name": "project_planning",
             “message_ts”: 1360782804.083113
         }
}
pin_removed
{
         "team_id": "T0123ABC",
         "enterprise_id": "E0123ABC",
         "event_id": "Ev0123ABC",
         “event_timestamp”: 1643810217.088700,
         “type”: “event”,
         “data”: {
              "event_type": “slack#/events/pin_removed",
              "user_id": "U0123ABC",
              "channel_id": "C0123ABC",
              "channel_type": "public/private/im/mpim",
              "channel_name": "project_planning",
             “message_ts”: “1360782804.083113”
            
         }
}
reaction_added
{
         "team_id": "T0123ABC",
         "enterprise_id": "E0123ABC",
         "event_id": "Ev0123ABC",
         “event_timestamp”: 1630623713,
         “type”: “event”,
         “data”: {
             "event_type": “slack#/events/reaction_added",
             “user_id”: "U0123ABC",
             "message_ts”: "1535430114.000100”,
             "channel_id”: "C0123ABC",
             "reaction": "joy"
         }
}
reaction_removed
{
         "team_id": "T0123ABC",
         "enterprise_id": "E0123ABC",
         "event_id": "Ev0123ABC",
         “event_timestamp”: 12345,
         “type”: “event”,
         “data”: {
             "event_type": “slack#/events/reaction_removed",
             “user_id”: "U0123ABC",
             "message_ts”: "1535430114.000100”,
             "channel_id”: "C0123ABC",
             "reaction": "thumbsup"
         }
}
shared_channel_invite_accepted
{
"team_id": "T0123ABC",
"enterprise_id": "E0123ABC",
"event_id": "Ev0123ABC",
“event_timestamp”: 1643810217.088700,
“type”: “event”,
“data”: {
"event_type": “slack#/events/shared_channel_invite_accepted",
"approval_required": false,
  "invite": {
    "id": "I028YDERZSQ",
    "date_created": 1626876000,
    "date_invalid": 1628085600,
    "inviting_team": {
      "id": "T12345678",
      "name": "Corgis",
      "icon": {...},
      "is_verified": false,
      "domain": "corgis",
      "date_created": 1480946400
    },
    "inviting_user": {
    'id' => ‘U123’
    'team_id' => ‘T123’,
    'name' => ‘John Doe’,
    'display_name' => ‘John Doe’,
    'real_name' => ‘John Doe’,
    'timezone' => 'America/Los_Angeles',
    'is_bot' => false, 
    }
    },
  "recipient_email": "golden@doodle.com",
  "recipient_user_id": "U87654321"


  “channel_id”: "C12345678,
  "channel_type": "public/private/im/mpim",
  “channel_name”: test-slack-connect


  "teams_in_channel": [
    {
      "id": "T12345678",
      "name": "Corgis",
      "icon": {...},
      "is_verified": false,
      "domain": "corgis",
      "date_created": 1626789600
    }
  ],


  "accepting_user": {
    'id' => ‘U123’
    'team_id' => ‘T123’,
    'name' => ‘John Doe’,
    'display_name' => ‘John Doe’,
    'real_name' => ‘John Doe’,
    'timezone' => 'America/Los_Angeles',
    'is_bot' => false,
  }
}
}
shared_channel_invite_approved
{
  "team_id": "T0123ABC",
  "enterprise_id": "E0123ABC",
  "event_id": "Ev0123ABC",
  "event_timestamp": 1643810217.0887,
  "type": "event",
  "data": {
    "event_type": "slack#/events/shared_channel_invite_approved",
    "invite": {
    "id": "I0123ABC",
    "date_created": 1626876000,
    "date_invalid": 1628085600,
    "inviting_team": {
      "id": "T12345678",
      "name": "Corgis",
      "icon": {...},
      "is_verified": false,
      "domain": "corgis",
      "date_created": 1480946400
    },
    "inviting_user": {
    'id' => ‘U123’
    'team_id' => ‘T123’,
    'name' => ‘John Doe’,
    'display_name' => ‘John Doe’,
    'real_name' => ‘John Doe’,
    'timezone' => 'America/Los_Angeles',
    'is_bot' => false,
    },
    "recipient_email": "golden@doodle.com",
    "recipient_user_id": "U87654321"
  },
“channel_id”: "C12345678,
  "channel_type": "public/private/im/mpim",
  “channel_name”: test-slack-connect,
  "approving_team_id": "T87654321",
  "teams_in_channel": [
    {
      "id": "T12345678",
      "name": "Corgis",
      "icon": {...},
      "is_verified": false,
      "domain": "corgis",
      "date_created": 1626789600
    }
  ],
  "approving_user": {
    'id' => ‘U123’
    'team_id' => ‘T123’,
    'name' => ‘John Doe’,
    'display_name' => ‘John Doe’,
    'real_name' => ‘John Doe’,
    'timezone' => 'America/Los_Angeles',
    'is_bot' => false,
  },
  }
}
shared_channel_invite_declined
{
  "team_id": "T0123ABC",
  "enterprise_id": "E0123ABC",
  "event_id": "Ev0123ABC",
  "event_timestamp": 1643810217.0887,
  "type": "event",
  "data": {
      "event_type": "slack#/events/shared_channel_invite_declined",
      "invite": {
    "id": "I0123ABC",
    "date_created": 1626876000,
    "date_invalid": 1628085600,
    "inviting_team": {
      "id": "T12345678",
      "name": "Corgis",
      "icon": {...},
      "is_verified": false,
      "domain": "corgis",
      "date_created": 1480946400
    },
    "inviting_user": {
    'id' => ‘U123’
    'team_id' => ‘T123’,
    'name' => ‘John Doe’,
    'display_name' => ‘John Doe’,
    'real_name' => ‘John Doe’,
    'timezone' => 'America/Los_Angeles',
    'is_bot' => false,    },
    "recipient_email": "golden@doodle.com"
  },
“channel_id”: "C12345678,
  "channel_type": "public/private/im/mpim",
  “channel_name”: test-slack-connect,
  "declining_team_id": "T87654321",
  "teams_in_channel": [
    {
      "id": "T12345678",
      "name": "Corgis",
      "icon": {...},
      "is_verified": false,
      "domain": "corgis",
      "date_created": 1626789600
    }
  ],
  "declining_user": {
    'id' => ‘U123’
    'team_id' => ‘T123’,
    'name' => ‘John Doe’,
    'display_name' => ‘John Doe’,
    'real_name' => ‘John Doe’,
    'timezone' => 'America/Los_Angeles',
    'is_bot' => false,
  },
  }
}
shared_channel_invite_received
{
  "team_id": "T0123ABC",
  "enterprise_id": "E0123ABC",
  "event_id": "Ev0123ABC",
  "event_timestamp": 1643810217.0887,
  "type": "event",
  "data": {
  "event_type": "slack#/events/shared_channel_invite_received",
  "invite": {
      "id": "I0123ABC",
      "date_created": 1626876000,
      "date_invalid": 1628085600,
      "inviting_team": {
        "id": "T12345678",
        "name": "Corgis",
        "icon": {...},
        "is_verified": false,
        "domain": "corgis",
        "date_created": 1480946400
      },
      "inviting_user": {
    'id' => ‘U123’
    'team_id' => ‘T123’,
    'name' => ‘John Doe’,
    'display_name' => ‘John Doe’,
    'real_name' => ‘John Doe’,
    'timezone' => 'America/Los_Angeles',
    'is_bot' => false,
      },
      "recipient_user_id": "U87654321"
    },
    “channel_id”: "C12345678,
  "channel_type": "public/private/im/mpim",
  “channel_name”: test-slack-connect,47639900
  }
}
user_joined_team
{
         "team_id": "T0123ABC",
         "enterprise_id": "E0123ABC",
         "event_id": "Ev0123ABC",
         "event_timestamp": 1630623713,
         "type": "event",
         "data": {
             "event_type": "slack#/events/user_joined_team",
              "user": {
                …
             }   
         }
}

Trigger filters

Trigger Filters allow you to define a set of conditions for a Trigger which must be true in order for the Trigger to trip. For example, you might want to have a reaction_added Trigger that only triggers if the reaction was a :eyes: reaction, and not on any other reaction.

Trigger Filters are implemented by inserting a filter payload within your trigger object. The payload takes the form of an object containing blocks of conditional logic.

The logical condition within each block can be one of two types:

  • Conditional expressions (e.g. x < y)
  • Boolean logic (e.g. x AND y)

Conditional expression blocks need a single statement key with a string containing the comparison block. Values from the inputs payload can be referenced within the comparison block:

    filter: {
      version: 1, 
      root: {
        statement: "{{data.reaction}} == sunglasses"
      }
    }

Boolean logic blocks are made up of two key:value pairs:

  • An operator key with a string containing the comparison operator
  • An inputs key with the child blocks

The child blocks then contain additional logic. In this case, it's two conditional expression blocks:

    filter: {
      version: 1, 
      root: {
        operator: "OR"
        inputs: [{
          statement: "{{data.reaction}} == sunglasses"
        }, 
        {
          statement: "{{data.metadata.event_payload.incident_type}} == 'security'"
        }],
      }
    }

Nested logic blocks
You can use the same boolean logic to create nested boolean logic blocks. It's boolean logic all the way down - up to a maximum of 5 nested blocks, that is.

With your desired filter designed, set it within your trigger object.

Example TypeScript payload

The following is a TypeScript payload for creating an Event Trigger that listens for a reaction_added event in a specific channel:

  type: "event",
  name: "Reactji response",
  description: "responds to a specific reactji",
  workflow: "#/workflows/myWorkflow",
  event: {
    event_type: "slack#/events/reaction_added",
    channel_ids: ["C123ABC456"],
    filter: {
      version: 1, 
      root: {
        statement: "{{data.reaction}} == sunglasses"
      }
    }
  },
  inputs: {
    stringtoSend: {
      value: "how cool is that",
    },
    channel: {
      value: "C123ABC456",
    },
  }

2. Create the Event Trigger

There are two ways to create an Event Trigger. You can:

Create an Event Trigger with the CLI

To create an Event Trigger with the CLI, you'll need to create a trigger file. The trigger file contains the payload you used to define your Trigger.

TypeScript trigger files take the following form:

import { Trigger} from “deno-slack-api/types.ts”;

const trigger : Trigger<typeof ExampleWorkflow.definition> = {
  // your TypeScript payload 
}

export default trigger;

Once you have created a trigger file, use the following command to create the Event Trigger:

slack trigger create --trigger-def "path/to/trigger.ts"

Create an Event Trigger at runtime

Create an Event Trigger at runtime using the client.workflows.triggers.create method within the relevant Function file.

const triggerResponse = await client.workflows.triggers.create<typeof ExampleWorkflow.definition>({
  // your TypeScript payload
});