Slack
Slack can trigger both kinds of managed agent automation:
- Instruction automation: map a Slack channel to a Space. The managed agent responds to Slack messages and 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
Section titled “Before you start”- Connect Slack in Type.
- Invite the Type app to the Slack channel.
With instructions
Section titled “With instructions”An instruction automation maps a Slack channel to a channel in a Space. Messages from Slack go into the correct Type context. The managed agent can post updates or respond in Slack.
Map a Slack channel to a Space
Section titled “Map a Slack channel to a Space”- Open Space settings → Automations.
- Select the Slack channel.
- Select the Type channel for the work from that Slack channel.
- Select which Slack messages trigger a response from the managed agent. Use the table in the next section.
Choose when the managed agent responds
Section titled “Choose when the managed agent responds”| Mode | Use when |
|---|---|
| @mentions | The managed agent must stay quiet until someone asks for it. |
| Channel messages | New posts and @mentions must trigger the managed agent. |
| Every message | The managed agent must respond to channel posts and to thread replies. |
To let people mention a Space-specific handle, for example @sales-operations, see Enable Slack User Groups for AI Mentions.
Write channel instructions
Section titled “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.
Ask the managed agent from Slack
Section titled “Ask the managed agent from Slack”People can mention Type in a connected Slack channel. They can ask a question and continue their work in Slack.
The response can use the Space’s thread context, memory, skills, and approved connections. For example, a person in a Marketing Slack channel can ask about Shopify products. That person does not have to open a different tool or start from an empty prompt.
Stop a response
Section titled “Stop a response”To stop a response that is in progress, add the 🛑 (:octagonal_sign:) or :stop: reaction. Add the reaction to your Slack message or to the reply from Type.
Type then keeps any partial response, clears the working status, and stops the active run.
Bring the team into Type gradually
Section titled “Bring the team into Type gradually”Slack is frequently the easiest place to start. Map the Slack channels that your team uses now. Post useful updates there, and let people ask Type for help.
When the work needs more depth, open the linked thread in Type. There, the team has a dedicated place to prompt together and run work in parallel. The team can also examine tool calls and make documents or apps.
With code
Section titled “With code”A code automation runs your TypeScript when a Slack event occurs. This example makes a code automation that replies in a Slack thread when a message contains a keyword.
Before you write the code
Section titled “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
Section titled “Reply to a keyword”import { type AutomationContext, type AutomationDeployment, replyInSlackThread, type SlackMessageEvent,} from "@type-dot-com/sdk/automations";import { err } from "neverthrow";
const slack = "orgint_abc123"; // the Slack connection
export const deployment = { subscriptions: { onDeployFailed: { title: "Answer deploy failures", description: "Reply with the runbook link when a message reports a failed deploy", source: { kind: "integration", connectionId: slack, events: ["message"], resources: { channel: ["C0123456789"] }, }, match: { "slack.message": { contains: "deploy failed" } }, }, },} satisfies AutomationDeployment;
export default class { async onDeployFailed(ctx: AutomationContext, event: SlackMessageEvent) { const sent = await replyInSlackThread(ctx, event, { connectionId: slack, text: "Runbook: https://example.com/runbooks/deploys", }); if (sent.isErr()) return err(sent.error); return ctx.setOutput(sent.value); }}How the example works:
resources.channellimits the subscription to one channel.- The
slack.messagematcher passes only messages that containdeploy failed. The match is case-sensitive. replyInSlackThreadreplies under the message. If the message is already in a thread, the reply goes in that thread.ctx.setOutputrecords where the reply went.
Choose the event
Section titled “Choose the event”| Goal | events | match key |
|---|---|---|
| New messages | ["message"] | slack.message |
| Mentions of the Type app | ["app_mention"] | slack.app_mention |
| A reaction was added | ["reaction_added"] | slack.reaction_added |
| A reaction was removed | ["reaction_removed"] | slack.reaction_removed |
| The app Home tab was opened | ["app_home_opened"] | Omit match |
For all options, see the Matchers reference.
Messages from bots, edits, and deletions
Section titled “Messages from bots, edits, and deletions”By default, the slack.message matcher:
- Includes messages from other bots.
- Skips edits, deletions, and empty messages.
Type always drops messages that Type itself posted.
To change the default behavior:
- To include edits, set
includeEdits: true. - To skip bots, set
includeBotMessages: false. - To select exact subtypes, set
subtypes, for example[null, "bot_message"].
React to an emoji
Section titled “React to an emoji”subscriptions: { onApproved: { title: "Start on approval", description: "Run when someone adds a check mark", source: { kind: "integration", connectionId: slack, events: ["reaction_added"] }, match: { "slack.reaction_added": { reactions: ["white_check_mark"] } }, },},The method gets an IntegrationEvent. Slack’s fields are in event.data: user, reaction, and item ({ type, channel, ts }). The event does not include the message text.
Call other Slack tools
Section titled “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:
const tools = await ctx.tools.find({ service: "slack", organizationIntegrationId: slack });See Call Connected Apps and APIs.
Limitations
Section titled “Limitations”AI-generated responses may be inaccurate
Section titled “AI-generated responses may be inaccurate”Type 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
Section titled “Code automation limits”- The Type app must be in the channel, and the Slack app must subscribe to the event.
eqandcontainsare case-sensitive. To match text with no case sensitivity, usematch: { handler: "custom" }and check the text in code.- The local npm SDK can be older than the SDK in Type. If
SlackMessageEventorreplyInSlackThreadis missing on your computer, see SDK versions.