# Slack Triggers for Managed Agent Automations

> Get an AI agent to do a task when someone tags it in Slack. Mention @Type in a channel, and a Type.com managed agent does the work and replies.

Canonical page: https://docs.type.com/automations/slack/

To get an AI agent to do a task when someone on your team tags it in Slack, connect Slack to Type.com, connect the Slack channel to a Space, and invite the Type app to the channel. Anyone in the channel can then mention `@Type` in a message or thread. A managed Claude or Codex agent does the task with the Space's shared connections and skills, such as updating a CRM record or opening a Linear issue, and replies in the Slack thread. Teammates can follow up in the thread without mentioning Type again.

Anthropic's Claude Tag and OpenAI's `@ChatGPT` also answer when someone tags them in Slack. A Type.com agent adds the Space's shared connections and skills, a choice of Claude or Codex, and automations that the same Space can run on a schedule or from other tools.

Slack can trigger both kinds of managed agent automation:

- **Instruction automation**: when someone mentions Type in a Slack channel, the managed agent follows your instructions.
- **Code automation**: run TypeScript when someone posts, mentions Type, or adds a reaction in Slack. The code can reply in the Slack thread.

Use Slack as a trigger if your team already does most of its work in Slack.

## Before you start

- Connect Slack in Type, and add the connection to the Space.
- Invite the Type app to each Slack channel. Slack sends Type events only from channels that the app is in.

## With instructions

Open **Automations → New automation** and choose **Slack** in **Trigger**. Select the Slack connection and one or more Slack channels, and write the required instructions. Select **Create automation**. The automation is enabled at once; no test message is required.

The new automation runs each time someone mentions the Type app, for example `@Type`, in a selected channel. Each mention starts a run:

1. An agent stage follows your instructions, with the Slack event as its input. Type tells the agent to treat the event as data, not as instructions.
2. A code stage records the agent's result: `completed` or `no_results`, with a short summary.

The agent works in a thread in the Space, and you can follow it in the automation's run history. It does not reply in Slack automatically. If it should answer in the Slack thread, say so in the instructions. You can later change the automation to use code, agent work, or both.

In the CLI:

```sh
type-cli automations create --space <space> --source slack --slack-channel "#support" \
  --instructions "Answer questions about the on-call schedule." --enable
```

- `--trigger mentions` (the default) runs on mentions of the Type app.
- `--trigger posts` runs on channel messages and skips replies in threads.
- `--trigger all` runs on every message, including thread replies.
- Without `--enable`, the CLI creates the automation paused.

Type.com never starts a Slack automation from its own Slack messages, unless a code automation's `slack.message` matcher sets `excludeOwnMessages: false`.

### Slack channels connected to a Space

Existing Slack channel connections of a Space appear under **Synced events** on the Space's **Automations** page. Messages from the Slack channel go into a channel of the Space, and the managed agent can respond in Slack. Each connected Slack channel has a reply mode:

| Mode | The managed agent responds to |
| --- | --- |
| **@mentions** | Mentions of Type or of the Space handle. |
| **Channel messages** | New posts in the channel. In threads, only mentions. |
| **Every message** | Every message, including thread replies. |

A new connection uses **@mentions**. Editing a connection keeps its reply mode. To change it, ask Type in the Space or in Slack, for example "only reply when you are mentioned" or "reply to every message".

In a thread where Type was directly mentioned or wrote the root message, you can follow up without another `@mention`. Type evaluates whether your reply invites an answer or action. This includes threads started by code-only automations.

To let people mention a Space-specific handle, for example `@sales-operations`, see [Enable Slack User Groups for AI Mentions](https://docs.type.com/automations/slack-user-groups/index.md).

### Follow a scheduled run in Slack

When a scheduled agent run posts a new message in a Slack channel connected to its Space through the same Slack connection, Type adds a **View in Type** link to the run's existing thread. The first new post from the run links the two threads.

Replies in Slack continue in that Type thread. Replies you write in the linked Type thread are also posted publicly in the Slack thread under your name, and Type's answers appear in Slack. Follow-up notifications come from Slack.

### Write channel instructions

Tell the managed agent:

- What the Slack channel is for.
- Which messages are important.
- When to reply in Slack.
- When to create or update a Type thread in place of a Slack reply.

### Reply while Type is working

When steering is available for your organization, a Slack thread reply that triggers Type while it is already working in that thread can join the work in progress:

- **Steer:** the reply changes or adds to the current work. Type folds it into the active turn, keeps the current harness, model, and reasoning effort, and continues in the same response. Type reacts with 👀 and 🛞.
- **Queue:** the reply is a separate task. Type answers it in its own response after the current work finishes, and reacts with 👀 and 🚂.

Only the person whose request started the current work can steer it. Replies from anyone else get their own response after the current work finishes, run with that person's own access. If Type cannot decide, the reply queues. If no turn is active, or steering is not available for your organization, the reply starts its own run.

### Stop a response

In a Slack channel connected to a Space, you can stop a response that is in progress. Add the 🛑 (`:octagonal_sign:`) or `:stop:` reaction to your Slack message or to the reply from Type. Type stops the response to that message.

## With code

A code automation runs your TypeScript when a Slack event occurs.

### Before you write the code

- Add the Slack connection to the Space.
- Get the connection ID (`orgint_...`) and the Slack channel ID (`C...`). To get the channel ID, open the channel details in Slack.

### Reply to a keyword

This automation replies in the thread when a message in one channel contains "deploy":

```ts title="src/main.ts"
import {
  automation,
  code,
  complete,
  replyInSlackThread,
  slackMessageEventSchema,
} from "@type-dot-com/sdk/automations";

// Replace with your Slack connection and channel.
const slackConnectionId = "orgint_example";
const slackChannelId = "C0123456789";

export default automation({
  // Each finished run records where the reply was posted.
  output: z.object({
    channelId: z.string(),
    threadTs: z.string(),
    ts: z.string(),
  }),

  deployment: {
    subscriptions: {
      deployQuestion: {
        title: "Answer deploy questions",
        description: "Reply in the thread when a message mentions deploy",
        source: {
          kind: "integration",
          connectionId: slackConnectionId,
          events: ["message"],
          resources: { channel: [slackChannelId] },
        },
        // Type runs this filter before your code.
        // Messages that do not match never start a run.
        match: {
          "slack.message": {
            contains: "deploy",
            subtypes: [null], // plain messages only: no edits or deletions
            includeBotMessages: false,
          },
        },
        entry: "reply",
      },
    },
  },

  stages: {
    // Reply in the thread of the message that started the run.
    reply: code({
      input: slackMessageEventSchema,
      transitions: [],
      async run({ ctx, input: message }) {
        const reply = await replyInSlackThread(ctx, message, {
          connectionId: slackConnectionId,
          text: "Deploys run on weekdays at 10:00. Status is in #releases.",
        });
        if (reply.isErr()) {
          return err(reply.error);
        }

        return complete(reply.value);
      },
    }),
  },
});
```

- `resources: { channel: [...] }` limits the subscription to these channel IDs. `channel` is the only resource filter for Slack.
- The [`slack.message` matcher](https://docs.type.com/automations/reference/matchers/index.md#slackmessage) runs before your code. Here it passes plain messages (`subtypes: [null]`) from people that contain "deploy". An event that it skips ends without running your code.
- `replyInSlackThread` replies under the message, or in the thread that the message is already in. It returns `{ channelId, threadTs, ts }` of the reply. It fails if Slack does not confirm the reply in that thread.
- Its default effect key is `slack-reply:<channel>:<message ts>`, so one message gets one reply. Pass `effectKey` to change it.

### Coordinate automations with @mentions

Slack sends a mention as both a `message` and an `app_mention` event. Automation
triggers still apply when someone mentions Type. By default, an automation runs
independently of the regular mention conversation; this is appropriate for
background work such as logging or updating a record.

For a subscription that takes responsibility for answering a new top-level
message, set `response: "conversation"` alongside `source`, `match`, and `entry`.
Use `source.events: ["message"]` and a deterministic `slack.message` matcher.
Omit `subtypes`, or use `[null, "file_share"]`, because the mention delivery may
omit the file-sharing subtype. Bot messages and edits cannot own the response.
Type checks that matcher and durably accepts the run before suppressing its
regular mention response. Either Slack event can start that run; the other event
and delivery retries reuse its receipt. Each matching subscription still runs.

This setting owns the initial response only. Replies in an existing Slack thread
keep normal conversation handling, and automation subscriptions still receive
them according to their event filters.

Instruction automations in the same channel are not suppressed. This includes a
channel with channel instructions or a reply mode explicitly set to **Channel
messages** or **Every message**. Type still answers there, so remove those
settings from a channel whose messages a code automation answers.

Conversation ownership is a commitment to handle the matching message. Put
routing eligibility in the declarative matcher, and remove code that skips a
message solely because it mentions Type. If the accepted automation later skips
or fails, Type does not start a second mention agent and repeat its side effects.
Use the automation's normal failure and recovery handling.

Custom filters, model-based conditions, and debouncing cannot claim the initial
response. They can still run as ordinary subscriptions. Their outcome is not
known when the mention needs routing.

### Test the example

`replyInSlackThread` calls the `slack_post_message` tool, so a fixture can answer it:

```json title="fixtures.json"
[
  {
    "name": "replies in the thread of a deploy question",
    "subscriptionId": "deployQuestion",
    "payload": {
      "type": "message",
      "id": "Ev0123456789",
      "resourceId": "C0123456789",
      "resourceType": "channel",
      "data": {
        "type": "message",
        "channel": "C0123456789",
        "user": "U0123456789",
        "ts": "1767225600.000100",
        "text": "When is the next deploy?"
      }
    },
    "toolResponses": [
      {
        "request": {
          "service": "slack",
          "name": "slack_post_message",
          "organizationIntegrationId": "orgint_example",
          "arguments": {
            "channel_id": "C0123456789",
            "thread_ts": "1767225600.000100",
            "text": "Deploys run on weekdays at 10:00. Status is in #releases."
          }
        },
        "response": {
          "content": [],
          "structuredContent": {
            "status": "sent",
            "channelId": "C0123456789",
            "ts": "1767225601.000200",
            "threadTs": "1767225600.000100"
          }
        }
      }
    ],
    "expectedOutput": {
      "channelId": "C0123456789",
      "threadTs": "1767225600.000100",
      "ts": "1767225601.000200"
    }
  },
  {
    "name": "skips a message without the keyword",
    "subscriptionId": "deployQuestion",
    "payload": {
      "type": "message",
      "id": "Ev0123456790",
      "resourceId": "C0123456789",
      "resourceType": "channel",
      "data": {
        "type": "message",
        "channel": "C0123456789",
        "user": "U0123456789",
        "ts": "1767225700.000100",
        "text": "Lunch at noon?"
      }
    },
    "toolResponses": []
  }
]
```

See [Test Automations](https://docs.type.com/automations/testing/index.md).

### Slack events

A Slack subscription can use these `events`: `message`, `app_mention`, `reaction_added`, and `reaction_removed`. Each event arrives in this envelope:

- `type`: the Slack event type, for example `message`.
- `id`: the Slack event ID.
- `resourceType`: `channel`, and `resourceId`: the channel ID.
- `data`: the Slack event object, for example `channel`, `user`, `text`, `ts`, and `thread_ts`.

When you omit `schema`, a native Slack matcher gives the entry stage a ready-made event type. Use the matching schema as the stage's `input`:

| `events` | `match` | Entry stage `input` |
| --- | --- | --- |
| `["message"]` | `slack.message` | `slackMessageEventSchema` |
| `["app_mention"]` | `slack.app_mention` | `slackAppMentionEventSchema` |
| `["reaction_added"]` | `slack.reaction_added` | `slackReactionAddedEventSchema` |
| `["reaction_removed"]` | `slack.reaction_removed` | `slackReactionRemovedEventSchema` |

Other subscriptions get the generic `IntegrationEvent` envelope, with `data` unchecked. To check `data`, set `schema` on the subscription.

With `slack.message`, `data.ts` is always present, unless you select the `message_deleted` subtype. See [Events](https://docs.type.com/automations/reference/events/index.md#slack-events) for the fields.

### Start on a reaction

This automation posts in the Space when someone adds ✅ to a message:

```ts title="src/main.ts"
import {
  automation,
  code,
  complete,
  slackReactionAddedEventSchema,
} from "@type-dot-com/sdk/automations";

const slack = "orgint_example"; // the Slack connection
const space = "ch_example"; // this Space

export default automation({
  output: z.object({ messageId: z.string() }),
  deployment: {
    subscriptions: {
      onApproved: {
        title: "Record approvals",
        description: "Post in the Space when someone adds a check mark",
        source: {
          kind: "integration",
          connectionId: slack,
          events: ["reaction_added"],
          resources: { channel: ["C0123456789"] },
        },
        match: { "slack.reaction_added": { reactions: ["white_check_mark"] } },
        entry: "record",
      },
    },
  },
  stages: {
    // Post a note in the Space for each check mark.
    record: code({
      input: slackReactionAddedEventSchema,
      transitions: [],
      async run({ ctx, input: event }) {
        const approvedMessage = event.data.item.ts ?? "unknown";

        const sent = await ctx.write.sendMessage(
          {
            channelId: space,
            content: `Slack user ${event.data.user} approved message ${approvedMessage}.`,
          },
          { effectKey: `approval:${event.id}` },
        );
        if (sent.isErr()) {
          return err(sent.error);
        }

        return complete({ messageId: sent.value.messageId });
      },
    }),
  },
});
```

The reaction event has `user`, `reaction`, and `item` (`{ type, channel, ts }`) in `data`. It does not include the text of the message. The matcher skips reactions that Type added.

`replyInSlackThread` also accepts `reaction_added` events. It reads the reacted message to find its parent thread before replying, and does not post if that read fails. [Reaction fixtures](https://docs.type.com/automations/reference/sdk/index.md#helpers) must include the read response as well as the post response.

Only one enabled, unexpired code automation can use the same emoji and channel on a Slack connection. If a save or enable operation reports an overlap, choose a different emoji or channel, or edit or pause the other automation. Omitting an emoji or channel filter matches all emojis or channels for this check.

### Answer an automation's questions

A staged automation can use an `ask` stage to wait for a person. Questions from an agent stage can also pause its work. When a Slack message, mention, or reaction starts the run, Type.com posts these questions in the triggering Slack thread.

Use **Answer question** to answer each field, or reply in the thread. A plain thread reply supplies the same free-form text to every question. The automation continues after Type accepts the answer.

If the same Slack thread has pending questions in more than one Type workspace, use **Answer question** on the intended question. A plain reply leaves those questions pending.

To answer, you must have an active Type account linked to your Slack account and access to the task thread. Replies from anyone else leave the question pending. You can also answer in Type.

### Reply with an agent

When a Slack message, mention, or reaction starts the run and the automation's Slack connection has full access:

- The last agent stage's final response is posted once in the triggering thread, with a **View in Type** link to the full run. You don't need a code stage to deliver it.
- Other agent stages stay in Type. Use [`thread: "trigger"`](#keep-a-staged-agent-in-the-triggering-thread) to stream a stage's whole run into the thread instead.
- Questions from `ask` stages and agents are posted in the thread.
- Slack shows Type working in the thread while the run is in progress.

A run that has no `ask` stage, no last agent stage, no `thread: "trigger"` stage, and has not replied to the triggering thread stays out of Slack. Slack shows no working status, and agent questions stay in Type. Use this for automations that watch a channel and report elsewhere, such as triaging customer messages into an internal channel.

To reply with the agent's answer, make the agent the last stage: omit `onResult` and set `output: z.string()`. Its final response is posted in the thread and becomes the run's output. The automation's root `output` must also accept a string:

```ts
review: agent({
  input: reviewInput,
  output: z.string(),
  instructions: "Review the pull requests. Your final response is posted in the Slack thread.",
}),
```

If the agent should sometimes not reply, use a structured output such as `z.object({ reply: z.string().nullable() })` with `onResult`, and post `reply` from the code stage with `replyInSlackThread` only when it is set. Don't also tell the agent to post in Slack.

### Keep a staged agent in the triggering thread

Type automatically places a terminal agent stage or an `ask` stage in the Type thread linked to its Slack reply destination. A successful code-stage reply to the triggering Slack thread also establishes that destination for subsequent stages. Type verifies the exact connection, channel, and thread; reading a message or posting elsewhere does not establish a destination.

The Slack connection must have full access, the Slack channel must be connected to the automation's Space, and the Type thread must already exist. Automatic placement shows the agent's work in that Type conversation. It preserves Slack delivery: internal stage commentary stays in Type, questions go to Slack, and terminal answers are posted once.

Use `agent({ thread: "trigger", ... })` to establish placement before a reply destination is known and stream that stage's progress into Slack. Use `agent({ thread: "separate", ... })` to keep a stage in its own Type task thread, even after another stage attached. This override does not change the stage's Slack delivery.

If that thread has an active turn, an open question, or another attached automation, the agent uses its own task thread. Later agent and question stages follow the same choice for that run unless an agent stage uses `thread: "separate"`. An attached run releases the thread when it completes, is cancelled, or needs attention.

### Call other Slack tools

`replyInSlackThread` covers replies. For other Slack actions, find the tool. Then call it with `ctx.read.call` or `ctx.write.call`:

```ts
const tools = await ctx.tools.find({ service: "slack", organizationIntegrationId: slack });
```

See [Call Connected Apps and APIs](https://docs.type.com/automations/call-integrations/index.md).

## Limitations

### AI-generated responses may be inaccurate

Type.com uses a large language model to generate responses. Its responses may be inaccurate, incomplete, or misleading. Review and verify important information before you rely on it or take action.

### Code automation limits

- The Type app must be in the channel, and the Slack app must subscribe to the event.
- `eq` and `contains` are case-sensitive. To match text with no case sensitivity, use `match: { handler: "custom" }`, set `schema: slackMessageEventSchema`, and check the text in code. Without a built-in matcher, edits, deletions, and other subtypes also reach your code.
- Type drops its own Slack messages before any matcher or code runs, unless the `slack.message` matcher sets `excludeOwnMessages: false`.
- The local npm SDK can be older than the SDK in Type. If `SlackMessageEvent` or `replyInSlackThread` is missing on your computer, see [SDK versions](https://docs.type.com/automations/reference/sdk/index.md#which-sdk-version-runs-your-code).

## FAQ

### How do I get an AI agent to do a task when someone on my team tags it in Slack?

Connect Slack to Type.com, add the Slack connection to a Space, and invite the Type app to the channel. When someone mentions @Type in that channel or a thread, a managed agent does the task with the Space's connected tools and skills and replies in the Slack thread.

### Can the agent act in other tools from Slack?

Yes. The managed agent uses the connections and skills of the Space, so a Slack mention can read or update the tools the Space is connected to, such as GitHub, Linear, or your CRM, and then reply in the thread.

### Who can tag the agent?

Anyone in a Slack channel that the Type app is in can mention it. Responses in a connected channel use the effective permissions of the person who triggered them, so connecting a channel doesn't give anyone broader access.

### Does the agent see private channels?

Only the channels that the Type app has been invited to. Slack sends Type events only from channels that the app is in.
