The new Slack platform and the features described below are in beta and under active development.

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. Instead, they're automatically triggered when a certain event happens.

Supported events

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

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
message_posted A message was sent to a channel. Note: a filter is required to listen for this event. 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_channel A user joined a public or private channel channels:read groups:read
user_joined_team A new member has joined users:read
user_left_channel A user left a public or private channel channels:read groups:read
We'll continue to add more triggerable events in the future. Stay tuned!

Avoid infinite loops

Your app can respond to events and be the cause of events. This can create situations where your app gets stuck in a loop.

For example, if your app listens for all message_posted events in a channel and then posts its own message in response, it'll keep posting messages forever! That's why the message_posted event requires a filter.

Carefully construct a filter to prevent boundless behavior. If your app does get stuck in an infinite loop, you can delete the trigger and the behavior will cease.

Create an event trigger

Triggers can be added to workflows in two ways:

  • You can add triggers with the CLI. These static triggers are created only once. You create them with the Slack CLI, attach them to your app's workflow, and that's that. The trigger is defined within a trigger file.

  • You can add triggers at runtime. These dynamic triggers are created at any step of a workflow so they can incorporate data acquired from other workflow steps. The trigger is defined within a function file.

Create an event trigger with the CLI

Slack CLI built-in documentation
Use slack trigger --help to easily access information on the trigger command's flags and subcommands.

The triggers you create when running locally (with the slack run command) will not work when you deploy your app in production (with the slack deploy command). You'll need to create any triggers again with the CLI.

Create the trigger file

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.

Create a TypeScript trigger file within your app's folder with the following form:

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

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

export default trigger;

Your TypeScript payload consists of the parameters needed for your own use case. 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",
    },
  }

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"

If you have not used slack triggers create to create a trigger prior to running slack run, you will receive a prompt in the CLI to do so.

Create an event trigger at runtime

Your app needs to have the triggers:write scope to use a trigger at runtime. Include the scope within your app's manifest.

The logic of a runtime trigger lies within a function's TypeScript code. Within your functions folder, you'll have the functions that are the steps making up your workflow. Within this folder is where you can create a trigger within the relevant <function>.ts file.

When you create a runtime trigger, you can leverage inputs acquired from functions within the workflow. Provide the workflow definition to get additional typing for the workflow and inputs fields.

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
});

Your TypeScript payload consists of the parameters needed for your own use case. Below is a function file with an example TypeScript payload for an event trigger. This specific TypeScript payload is for creating an event trigger that listens for a reaction_added event in a specific channel:

// functions/example_function.ts
import { DefineFunction, Schema, SlackFunction } from "deno-slack-sdk/mod.ts";
import { ExampleWorkflow } from "../workflows/example_workflow.ts";

export const ExampleFunctionDefinition = DefineFunction({
  callback_id: "example_function_def",
  title: "Example function",
  source_file: "functions/example_function.ts",
});

export default SlackFunction(
  ExampleFunctionDefinition,
  ({ inputs, client }) => {

  const triggerResponse = await client.workflows.triggers.create<typeof ExampleWorkflow.definition>({
    type: "event",
    name: "Reactji response",
    description: "responds to a specific reactji",
    workflow: `#/workflows/${ExampleWorkflow.definition.callback_id}`,
    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",
      },
    }
  });

  // ...

Parameters

Field Description Required
type The type of trigger: event Required
name The name of the trigger Required
workflow Path to workflow that the trigger initiates Required
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

Interactivity, and thus the interactivity parameter, is not supported with event triggers. Use a link trigger to take advantage of interactivity.

The Event object

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

The 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. See below.

Each type of event has unique sub-properties within the data property. You can pass these values on to your workflows. See the example below the event types.

Event types
{
  "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"
  }
}
{
  "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",
  }
}
{
  "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,
  }
}
{
  "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",
  }
}
{
  "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",
  }
}
{
  "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"
  }
}
{
  "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"
  }
}
{
  "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"
  }
}
{
  "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 added
{
  "team_id": "T0123ABC",
  "enterprise_id": "E0123ABC",
  "event_id": "Ev0123ABC",
  "event_timestamp": 1630623713,
  "type": "event",
  "data": {
    "event_type": "slack#/events/emoji_changed",
    "subtype": "add",
    "name": "picard_facepalm",
    "value": "https://my.slack.com/emoji/picard_facepalm/abc123.gif"
  }
}
Emoji removed
{
  "team_id": "T0123ABC",
  "enterprise_id": "E0123ABC",
  "event_id": "Ev0123ABC",
  "event_timestamp": 1630623713,
  "type": "event",
  "data": {
    "event_type": "slack#/events/emoji_changed",
    "subtype": "remove",
    "names": ["picard_facepalm"],
  }
}
Emoji renamed
{
  "team_id": "T0123ABC",
  "enterprise_id": "E0123ABC",
  "event_id": "Ev0123ABC",
  "event_timestamp": 1630623713,
  "type": "event",
  "data": {
    "event_type": "slack#/events/emoji_changed",
    "subtype": "rename",
    "old_name": "picard_facepalm",
    "new_name": "captain_picard_facepalm",
    "value": "https://my.slack.com/emoji/picard_facepalm/abc123.gif"
  }
}
{
  "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"
  }
}
{
  "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"
  }
}
{
  "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
  }
}
{
  "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
        }
      }
    }
  }
}
{
  "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
  }
}
{
  "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"
  }
}
{
  "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"
  }
}
{
  "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"
  }
}
{
  "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,
    }
  }
}
{
  "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
    },
  }
}
{
  "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
  }
}
{
  "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"
  }
}
{
  "team_id": "T0123ABC",
  "enterprise_id": "E0123ABC",
  "event_id": "Ev0123ABC",
  "event_timestamp": 1630623713,
  "type": "event",
  "data": {
    "event_type": "slack#/events/user_joined_team",
    "user": { ... }
  }
}

The data returned in the event response object can be passed along to workflows. In this example, we take the user_id, channel_id, and message_ts from the reaction_added event's response object and pass them along to the joy_workflow in the inputs field.

{
  type: "event",
  name: "Joy reactji event trigger",
  description: "Joy reactji trigger",
  workflow: "#/workflows/joy_workflow",
  inputs: {
    user: {
      value: "{{data.user_id}}", // Pulled from event response body and passed into the workflow
    },
    channel: {
      value: "{{data.channel_id}}", // Pulled from event response body and passed into the workflow
    },
    message_ts: {
      value: "{{data.message_ts}}" // Pulled from event response body and passed into the workflow
    }
  },
  event: {
    event_type: "slack#/events/reaction_added",
    channel_ids: ["C123ABC456"]
  }
}

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.

You can use filters to prevent your app from responding to events it causes, which would potentially cause an infinite loop of responses.

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.

Event trigger response

The response will have a property called ok. If true, then the trigger was created, and the trigger property will be populated.

Your response will include a trigger.id; be sure to store it! You use that to update or delete the trigger if need be. Perhaps consider storing it in a Datastore.

Manage access to an event trigger

A newly created trigger is accessible to anyone inside the workspace by default. You can manage who can access the trigger using the access Slack CLI command.

Grant access

Required Flag Description Example Argument
--grant A switch to grant access
--trigger-id The trigger_id of the desired trigger Ft123ABC

Set one of the following flags to grant access to different groups. If no flag is selected you will be prompted to select a group within the Slack CLI.

Flag Description Example Argument
--app-collaborators A switch to grant access to all app collaborators
--channels The channel IDs of channels to be granted access C123ABC, C456DEF
--everyone A switch to grant access to all workspace members
--organizations The enterprise IDs of organizations to be granted access E123ABC, E456DEF
--users The user ID of users to be granted access U123ABC, U456DEF
--workspaces The team IDs of workspaces to be granted access T123ABC, T456DEF

You can combine types of named entities (channels, organizations, users, and workspaces) in a single command. For example, the following command grants access to the trigger FtABC123 for channel C123ABC, organization E123ABC, user U123ABC and workspace T123ABC:

slack trigger access --trigger-id Ft123ABC --channels C123ABC --organizations E123ABC --users U123ABC --workspaces T123ABC --grant

Revoke access

Required Flag Description Example Argument
--revoke A switch to revoke access
--trigger-id The trigger_id of the desired trigger Ft123ABC

Set one of the following flags to revoke access to different groups. If no flag is selected you will be prompted to select a group within the Slack CLI.

Flag Description Example Argument
--channels The channel IDs of channels whose access will be revoked C123ABC, C456DEF
--organizations The enterprise IDs of organizations whose access will be revoked E123ABC, E456DEF
--users The user IDs of users whose access will be revoked U123ABC, U456DEF
--workspaces The team IDs of workspaces whose access will be revoked T123ABC, T456DEF

The following example command revokes access to the trigger FtABC123 for users U123ABC and U456DEF and channels C123ABC and C456DEF.

slack trigger access --trigger-id FtABC123 --users U123ABC, U456DEF --channels C123ABC, C456DEF --revoke

Update an event trigger

Update a trigger with the CLI

Make an update to a pre-existing trigger with the CLI by using the slack trigger update command. Provide the same payload you used to create the trigger in its entirety, in addition to the trigger ID.

slack trigger update --trigger-id Ft123ABC --trigger-def "path/to/trigger.ts"

Update a trigger at runtime

You can update a runtime trigger, but the trigger must be updated in its entirety. Use the same structure as client.workflows.triggers.create() but for client.workflows.triggers.update with the additional trigger_id parameter.

const triggerId = "FtABC123";
const response = await client.workflows.triggers.update<typeof ExampleWorkflow.definition>({
  trigger_id: triggerId,
  type: "<specific-trigger-type>",
  name: "My trigger",
  workflow: "#/workflows/myworkflow",
  inputs: {
    input_name: {
      value: "value",
    }
  }
});
// Error handling example in your custom function
if (response.error) {
  const error = `Failed to update a trigger (id: ${triggerId}) due to ${repsonse.error}`;
  return { error };
}

Delete an event trigger

Delete a trigger with the CLI

You can delete a trigger with the slack trigger delete command.

slack trigger delete --trigger-id FtABC123

Delete a trigger at runtime

Deleting a runtime trigger deletes that specific trigger created in one instance of the workflow. This means that you'll need to have stored the trigger_id created for that instance. Your app will continue to be able to create triggers until you remove the relevant code.

You can delete a runtime trigger by using client.workflows.triggers.delete().

const response = await client.workflows.triggers.delete({
   trigger_id: "FtABC123"
});
// Error handling example in your custom function
if (response.error) {
  const error = `Failed to delete a trigger due to ${response.error}`;
  return { error };
}