> For the complete documentation index, see [llms.txt](/llms.txt).
> A full single-fetch corpus is available at [llms-full.txt](/llms-full.txt).
---
title: Build a Slack deep research bot
description: Mention a bot in Slack and get a sourced research report in the thread. AGNT5 acknowledges the webhook instantly, runs three agents as checkpointed steps, and survives worker crashes mid-run.
tags: ["Slack", "Agents", "Webhooks", "Long-running", "Observability"]
date: 2026-10-14
last_verified: 2026-10-14
audience: both
---

Mention `@ResearchBot` in any channel and a sourced research report lands in the thread about 30 seconds later.

<DocsVideo
  src="/videos/cookbooks/slack-overview"
  mode="player"
  title="A user mentions ResearchBot in a Slack channel, AGNT5 acknowledges the webhook in 400 milliseconds, and about 30 seconds later a sourced report about New Delhi appears in the thread."
  caption="From mention to report. The report and run numbers are from a real run."
/>

## Why it's built this way

Slack expects an answer to its webhook within **3 seconds** and retries if it doesn't get one. A research run takes about **30 seconds**. So the bot splits the work:

- **Acknowledge immediately.** AGNT5 records the event and returns `200 OK` in under a second, so Slack never retries.
- **Research in the background.** A durable workflow runs three focused agents (scoping, research, writing) instead of one large prompt.
- **Checkpoint every step.** If the worker dies mid-run, the run resumes from the last saved step without repeating LLM calls.

## How it works

<DocsVideo
  src="/videos/cookbooks/slack-architecture"
  title="Architecture: Slack sends a webhook to the AGNT5 gateway, which starts the slack_deep_research workflow. ScopingAgent, ResearchAgent, and WritingAgent run as checkpointed steps. After a simulated crash, the finished step is restored and the run continues, then chat.postMessage posts the report to the thread."
  caption="Each agent's output is saved before the next one starts. After a crash (simulated here), finished steps restore from saved state and only the interrupted step runs again."
/>

| Step | Agent | What it does |
|---|---|---|
| `plan_research` | ScopingAgent | Turns the question into research subtopics |
| `conduct_research` | ResearchAgent | Searches Wikipedia and reads the most relevant pages |
| `write_report` | WritingAgent | Writes a Slack-formatted report with sources, then posts it to the thread |

The workflow ignores events it shouldn't answer, such as the bot's own replies and message edits, so each mention produces one report.

## Run it yourself

You need an [AGNT5 account](https://app.agnt5.com), Python 3.11+ with [uv](https://docs.astral.sh/uv/getting-started/installation/), an [OpenAI API key](https://platform.openai.com/api-keys), and a Slack workspace where you can install apps.

<Steps>
<Step title="Create the project">

```bash
agnt5 create --template python/slack_deep_research my-research-bot
cd my-research-bot && uv sync
```

</Step>
<Step title="Add your OpenAI key and deploy">

```bash
agnt5 secrets set --name OPENAI_API_KEY --type api_key
agnt5 deploy --env production
```

</Step>
<Step title="Connect Slack">

Follow the [Slack integration guide](/docs/integrations/event-sources/slack.md) to create the Slack app with the `app_mentions:read` and `chat:write` scopes and subscribe it to the `app_mention` event. In Studio, point the integration at your production deployment and the `slack_deep_research` workflow. Studio provides the bot token to the workflow; you don't add it yourself.

</Step>
<Step title="Mention the bot">

Invite the bot to a channel and ask it something: `@ResearchBot research the capital of India`. The report arrives in the thread in about 30 seconds.

</Step>
</Steps>

## Debug in Studio

Open **Studio → Events** to see each Slack event and where it was dispatched. Open **Studio → Runs** to see the run it started: every step, agent, and tool call, with its input, output, and duration.

<DocsVideo
  src="/videos/cookbooks/slack-studio"
  title="Studio's Events view: the slack.app_mention event shows Started 1 run, and its Dispatch section shows the bound component workflow: slack_deep_research. In Runs, the run shows its span tree: plan_research, conduct_research, and write_report, with each agent and tool call and its duration."
/>

| What you see | What it means |
|---|---|
| An event marked **Rejected** | The integration's deployment doesn't serve `slack_deep_research`: point the integration at the deployment you deployed |
| A run that finished in under a second | The workflow skipped the event: the bot's own reply, a message edit, or a duplicate of a mention |
| A completed run but no reply in Slack | Check the run output: `slack_post.reason` says why posting failed |
| No event in Studio | Slack isn't delivering events: check the app's event subscription and that the bot is in the channel |
| A step with near-zero duration after a restart | It was restored from its checkpoint |

## Extend it


  - [Add more tools](/docs/build/tools) — Give ResearchAgent web search alongside Wikipedia.
  - [Shape the workflow](/docs/build/workflows) — Add steps, such as follow-ups across thread replies.
  - [Promote through environments](/docs/run/environments) — Test in staging with its own Slack token, then promote.

