# Slack

Replies to Slack mentions and DMs, scoped to the thread, via the Slack Web API.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown variants are available by appending `.md` to any URL or sending an `Accept: text/markdown` header. An agent skill is available at [/.well-known/agent-skills/site-skill.md](/.well-known/agent-skills/site-skill.md).



<DocsBaseSwitcher base="mastra" agent="slack-agent" />

<AgentPreview
  agent="slack-agent"
  framework="mastra"
  inputFields="[
  {
    name: &#x22;message&#x22;,
    label: &#x22;Message&#x22;,
    placeholder: &#x22;@bot what's the status of the deploy?&#x22;,
    type: &#x22;text&#x22;,
  },
]"
/>

## Summary [#summary]

The **Slack Agent** turns your agent into a Slack bot. It answers mentions and
direct messages, keeps each conversation scoped to its thread, and replies with
Slack formatting. Reach for it to put an assistant where your team already works —
an on-call helper, a docs bot, or a triage assistant.

## Installation [#installation]

<CodeTabs>
  <TabsList>
    <TabsTrigger value="cli">
      Command
    </TabsTrigger>

    <TabsTrigger value="manual">
      Manual
    </TabsTrigger>
  </TabsList>

  <TabsContent value="cli">
    ```bash
    npx shadcn@latest add @agentcn/mastra/slack-agent
    ```
  </TabsContent>

  <TabsContent value="manual">
    <Steps>
      <Step>
        Install the following dependencies:
      </Step>

      ```bash
      npm install @mastra/core
      ```

      <Step>
        Copy and paste the following code into your project.
      </Step>

      <ComponentSource src="registry/mastra/slack-agent/config.ts" title="config.ts" />

      <ComponentSource src="registry/mastra/slack-agent/instructions.md" title="instructions.md" />

      <ComponentSource src="registry/mastra/slack-agent/tools/post_message.ts" title="tools/post_message.ts" />

      <Step>
        Update the import paths to match your project setup.
      </Step>
    </Steps>
  </TabsContent>
</CodeTabs>

## Composition [#composition]

```text
├── config.ts             # Agent definition (model + config)
├── instructions.md       # Slack reply style + threading instructions
└── tools/
    └── post_message.ts   # Posts a (threaded) Slack message
```

## Customization [#customization]

* **Verify signatures.** Add Slack request-signature verification in your event
  route before invoking the agent.
* **Add more actions.** Add tools for reactions, file uploads, or opening modals.
* **Scope memory by thread.** Key agent sessions on `thread_ts` for clean context.
* **Swap the model.** Edit `config.ts`.
