> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect an agent to Slack

> Create a Slack app for a deployed agent, hand its credentials to the platform, and talk to the agent in channels, threads and DMs.

At the end of this guide you can mention your agent in a Slack channel, keep the conversation going in the thread it answers in, and DM it. The CLI does the platform side. You create the Slack app in your browser, from a manifest the CLI writes for you.

## Before you start

* The CLI is installed and signed in: `jaccard auth status` shows your organization. See [Install and sign in](/docs/get-started/install.md).
* The agent is deployed and exposed, which is the default. Slack sends events to the agent's URL, so an agent deployed with `--no-expose` can't be connected.
* You can create apps in the Slack workspace. Some workspaces allow only admins to: ask for the **Create apps** permission, or for an admin to approve the app.

Run every command below in the agent's project folder.

## Connect

**1. Start channel add**

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
jaccard channel add slack
```

The command resolves the agent, writes the Slack app manifest, and stops at the credential prompts:

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
==> 1/5 resolving my-agent
    request url  https://my-agent-acme.jaccard.app/eve/v1/slack
==> 2/5 wrote slack-app-manifest.yaml
    create the app from it at https://api.slack.com/apps (From a manifest) and install it to the workspace
==> 3/5 credentials
Signing Secret (Basic Information > App Credentials, hidden):
```

Leave the prompt waiting and open a browser for the next two steps.

**2. Create the Slack app from the manifest**

1. Open [api.slack.com/apps](https://api.slack.com/apps) and click **Create New App**.
2. Choose **From a manifest**.
3. Pick the workspace the agent should live in and click **Next**.
4. Switch the editor to **YAML**, replace its contents with the contents of `slack-app-manifest.yaml`, and click **Next**.
5. Review the summary and click **Create**.

Slack opens the new app's **Basic Information** page. The manifest names the app after the agent, enables a bot user, turns on the Messages tab so people can DM it, and subscribes it to mentions, channel messages and DMs with the matching scopes.

**3. Install the app to the workspace**

On **Basic Information**, under **Install your app**, click **Install to Workspace** and then **Allow**. If the button is missing, open **OAuth & Permissions** in the sidebar and click **Install to Workspace** there.

Installing is what creates the bot token. The next step cannot finish without it.

**4. Paste the two credentials**

Back in the terminal, give the CLI what it asked for, in this order:

1. **Signing Secret**. On **Basic Information**, under **App Credentials**, click **Show** next to **Signing Secret**, copy it, and paste it at the prompt. It is a 32-character value.
2. **Bot User OAuth Token**. Open **OAuth & Permissions**. Under **OAuth Tokens**, copy the **Bot User OAuth Token**, which starts with `xoxb-`, and paste it at the second prompt.

The prompts are hidden, so nothing shows while you paste. After each one the CLI echoes a masked copy so you can tell the paste landed:

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
Signing Secret (Basic Information > App Credentials, hidden):
    signing secret ******** (32 characters)
Bot User OAuth Token (OAuth & Permissions, xoxb-..., hidden):
    token          xoxb-****mnop (57 characters)
    workspace      Acme Corp (T0123456)
    bot user       U0123456
==> 4/5 applying the channel
    channel      Ready
==> 5/5 wrote agent/channels/slack.ts; a deploy is needed to ship it
next:
  1. jaccard deploy                      # ships agent/channels/slack.ts
  2. in the app's Event Subscriptions, retry the Request URL until it shows "Verified"
  3. invite @my-agent to a channel and mention it, or send it a DM
```

The CLI checks the token with Slack before storing anything, so a wrong token fails here, not later. The credentials are stored on the platform, not in your project or in `jaccard env`.

> [!WARNING]
>
> Paste the **Bot User OAuth Token**, not the **App-Level Token** that Basic Information also offers. App-level tokens start with `xapp-` and are only for Socket Mode. The CLI refuses them with a message naming the right page. A **User OAuth Token** (`xoxp-`) is refused too.

**5. Deploy the channel file**

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
jaccard deploy
```

The deploy ships `agent/channels/slack.ts`, which `channel add` wrote into the project. Until it finishes, the agent can't answer Slack.

Commit `agent/channels/slack.ts`, since it's part of the agent. `slack-app-manifest.yaml` is only needed to create or update the app, so committing it is up to you.

**6. Verify the Request URL**

Slack checks the Request URL by posting a challenge to it, and the agent answers only once the deploy above is serving.

1. In the app's settings, open **Event Subscriptions**.
2. Next to the **Request URL**, click **Retry**. It should change to **Verified**. If it does not, wait for the deploy to finish and retry.
3. If Slack shows a **Save Changes** button, click it.

You can confirm from the terminal too:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
jaccard channel get slack
```

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
phase      Ready
url        https://my-agent-acme.jaccard.app/eve/v1/slack
reachable  yes (HTTP 200)
```

`reachable  no` with a 404 means the running image does not have the channel file yet.

**7. Talk to the agent**

* **In a channel**: invite the bot with `/invite @my-agent`, then mention it: `@my-agent summarise last week's signups`. The agent replies in a thread under your message. Keep asking in that thread without mentioning it again.
* **By DM**: open the app from **Apps** in the Slack sidebar, or click its name and choose **Message**. Every top-level DM starts a new conversation. Follow-ups go in the thread under the agent's reply.
* **Files**: the bot has `files:read` and `files:write`, so it can read attachments you share and upload its own.

Channel messages that do not mention the agent and are not in a thread it has joined are ignored, so the bot can sit in a busy channel without answering everything.

## What the channel file does

`channel add` writes this file. The hooks decide which Slack messages reach the agent:

```ts agent/channels/slack.ts theme={"theme":{"light":"github-light","dark":"github-dark"}}
import { slackChannel } from "eve/channels/slack";

// Admit only mentions and joined threads, or the bot answers every channel message.
export default slackChannel({
  onDirectMessage() {
    return { auth: null };
  },
  async onMessage(ctx, message) {
    if (message.author?.isBot) return null;
    return ctx.isBotMentioned() || (await ctx.isSubscribed()) ? { auth: null } : null;
  },
});
```

* `onDirectMessage` runs for DMs and admits all of them.
* `onMessage` runs for every channel message the app receives. It admits a message that mentions the bot, or one in a thread the agent already has a conversation in (`isSubscribed()`), and drops the rest, including messages from other bots.
* Returning an object sends the message to the agent. Returning `null` drops it.

Edit the file to change the rules, for example to restrict who can invoke the agent or to load earlier thread messages as context. eve's [channel documentation](https://eve.dev/docs/channels/overview) covers the hooks and their options. Once the file differs from what `channel add` wrote, `channel rm` leaves it in place rather than deleting it.

## Private channels

The default app receives public channel messages only. To let the agent follow threads in private channels:

1. Add `message.groups` to `settings.event_subscriptions.bot_events` and `groups:history` to `oauth_config.scopes.bot` in `slack-app-manifest.yaml`.
2. In the app's settings, open **App Manifest**, paste the updated manifest, and save.
3. Reinstall the app: **OAuth & Permissions**, **Reinstall to Workspace**, **Allow**. New scopes take effect only after a reinstall. The bot token stays the same, so the platform needs nothing.

`jaccard channel manifest slack` prints the default manifest again if you want to start over from it.

## Rotate the credentials

If you regenerate the signing secret or reinstall the app with a new token, run `jaccard channel add slack` again and paste the new values. The command keeps your manifest and channel file, replaces the stored credentials, and restarts the agent so the new values take effect. The output says `channel      updated`.

## Disconnect

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
jaccard channel rm slack
jaccard deploy
```

`rm` removes the channel and its credentials from the platform and deletes `agent/channels/slack.ts` if it is still the file `channel add` wrote. The deploy ships the agent without the channel. The Slack app is yours: delete it from [api.slack.com/apps](https://api.slack.com/apps) under **Basic Information**, **Delete App**, or keep it for later.

## Troubleshooting

| What you see | What it means | What to do |
| - | - | - |
| `no agent named <name>; deploy it first` | The CLI could not find the agent in your organization. | Deploy the agent, or pass `--agent <name>` if the project directory is not named after it. |
| `<name> is not exposed, so Slack cannot reach it` | The agent was deployed with `--no-expose`. | Redeploy without `--no-expose`. |
| `that is an app-level token (xapp-)` | You pasted the App-Level Token from Basic Information. | Paste the **Bot User OAuth Token** from **OAuth & Permissions**. |
| `the token passed auth.test but names no bot user` | The token is valid but is not a bot token. | Install the app to the workspace, then use the `xoxb-` token from **OAuth & Permissions**. |
| `Slack rejected the bot token: invalid_auth` | Slack does not recognise the token. | Reinstall the app and paste the token shown after the install. |
| `signing secret should be the 32-character value from Basic Information` | The secret was empty, truncated or something else. | Click **Show** next to **Signing Secret** under **App Credentials** and copy the whole value. |
| `channel      Invalid: …` | The platform could not make the channel usable, for example because the agent lost its hostname. | Fix what the message names and run `channel add` again. |
| **Request URL** will not verify | The deployed agent isn't serving the channel file yet, or the deploy failed. | Run `jaccard channel get slack`. Once it prints `reachable  yes`, click **Retry**. If the deploy failed, `jaccard agent get` says why. |
| "Sending messages to this app has been turned off" in Slack | The Messages tab is off, as in apps created from an older manifest. | In the app's settings, open **App Home**, turn on **Messages Tab** and **Allow users to send Slash commands and messages from the messages tab**. |
| The agent answers a mention but not the follow-ups in its thread | The channel file does not admit joined threads, or the app lacks `message.channels` and `channels:history`. | Compare `agent/channels/slack.ts` with the file above, and `slack-app-manifest.yaml` with `jaccard channel manifest slack`. After changing scopes, reinstall the app, then redeploy. |
| The agent does not answer in a private channel | The default app has no private-channel scopes. | See [Private channels](#private-channels). |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.