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

# Slack

> Ask, save, and search your Cognee memory from Slack.

Connect Slack to Cognee so your team can query and grow the knowledge graph without leaving a channel or DM. Once a workspace is connected, anyone in it can run `/cognee-ask` to search memory, save a message to memory with the **Remember this** shortcut, and review answers before sharing them with the rest of the channel.

<Info>
  This integration is for self-hosted Cognee deployments — you create and own the Slack app, so it lives entirely inside your own Slack workspace and your own Cognee backend. There is no shared, Cognee-managed Slack app.
</Info>

## Why Use This Integration

* **Ask from anywhere in Slack**: `/cognee-ask <question>` searches your memory and replies privately, with a **Share** button to post the question + answer to the channel once you've checked it.
* **Save context on the fly**: the **Remember this** message shortcut stores any Slack message into Cognee memory, tagged with the channel and author.
* **Per-user, not per-workspace**: each Slack member links their own Cognee account (`/cognee-link <api_key>`), so answers and saved memories respect the same permissions they'd have via the API or SDK.
* **Self-hosted, no middleman**: your Slack app talks directly to your Cognee backend. No data passes through a third-party relay.

## Prerequisites

* A running Cognee backend reachable over HTTPS from the public internet (Slack will not call `localhost`). For local development, use a tunnel like [ngrok](https://ngrok.com/); for production, this is your deployment's normal public domain.
* A Cognee account with an API key for each Slack member who wants to link their account.

## Setup

### 1. Create the Slack App

1. Go to [api.slack.com/apps](https://api.slack.com/apps) → **Create New App** → **From scratch**.
2. Name it (e.g. "Cognee") and pick the workspace you're installing it into for development.

Everything below is configured on this app's page.

### 2. Bot Token Scopes

**OAuth & Permissions → Scopes → Bot Token Scopes** — add:

| Scope           | Why                                                                         |
| --------------- | --------------------------------------------------------------------------- |
| `commands`      | Receive slash commands                                                      |
| `chat:write`    | Post replies and DMs                                                        |
| `im:write`      | Open a DM to deliver ephemeral responses                                    |
| `channels:read` | List public channels for the per-channel allowlist on the Integrations page |

<Info>
  Deliberately no `channels:history` — bulk channel ingestion isn't part of this integration (see [external data sources](/cognee-cloud/connections/external-data-sources) for pulling Slack history via `dlt` instead). Slack's non-Marketplace rate limits on history reads (1 request/minute as of 2025) make it impractical here anyway.
</Info>

### 3. OAuth Redirect URL

**OAuth & Permissions → Redirect URLs** — add exactly:

```
https://<your-backend-domain>/api/v1/integrations/slack/callback
```

This must byte-match what your backend sends, which comes from `SLACK_REDIRECT_URI` in step 6 — copy the same value into both places.

### 4. Slash Commands

**Slash Commands → Create New Command** — add both:

| Command        | Request URL                                           | Short Description                 |
| -------------- | ----------------------------------------------------- | --------------------------------- |
| `/cognee-ask`  | `https://<your-backend-domain>/api/v1/slack/commands` | Ask your Cognee memory a question |
| `/cognee-link` | `https://<your-backend-domain>/api/v1/slack/commands` | Link your Slack account to Cognee |

### 5. Event Subscriptions & App Home

1. **Event Subscriptions** → toggle on → Request URL: `https://<your-backend-domain>/api/v1/slack/events`
2. Under **Subscribe to bot events**, add `app_home_opened`.
3. **App Home** → enable the **Home Tab**.

### 6. Interactivity & Shortcuts

1. **Interactivity & Shortcuts** → toggle on → Request URL: `https://<your-backend-domain>/api/v1/slack/interactive`
2. Under **Shortcuts** → **Create New Shortcut** → **On messages**:
   * Name: `Remember this`
   * Callback ID: `remember_this` (must match exactly — this is how Cognee's handler recognizes it)

### 7. Configure Cognee

Copy the app's credentials into your backend's `.env` (**Basic Information** for the first three):

```bash theme={null}
SLACK_CLIENT_ID="..."          # OAuth & Permissions > Basic Information
SLACK_CLIENT_SECRET="..."      # OAuth & Permissions > Basic Information
SLACK_SIGNING_SECRET="..."     # Basic Information > App Credentials
SLACK_REDIRECT_URI="https://<your-backend-domain>/api/v1/integrations/slack/callback"
SLACK_FRONTEND_BASE_URL="https://<your-frontend-domain>"
```

Restart the backend so it picks up the new values.

### 8. Install and Connect

1. **Install App** (in the Slack app's sidebar) to add it to your workspace.
2. In the Cognee UI, go to **Integrations** and click **Connect Slack** — this runs the OAuth install and links the workspace to your Cognee account.
3. In Slack, run `/cognee-link <api_key>` (from your Cognee account's **API Keys** settings) so your own messages resolve to your own Cognee user.
4. Try `/cognee-ask What does Cognee do?` — you should get a private reply with a **Share** button.

## Multiple Environments

Slack apps are tied to one set of OAuth credentials and one Redirect URL each. If you run more than one Cognee deployment (local dev, staging, production), create a **separate Slack app per environment** rather than editing one app's config back and forth — each environment gets its own `SLACK_CLIENT_ID`/`SLACK_CLIENT_SECRET`/`SLACK_SIGNING_SECRET`/`SLACK_REDIRECT_URI`. This avoids local testing ever breaking a shared staging or production connection.

For local development with a tunnel, a reserved/static ngrok domain means you only register the Redirect URL once — it keeps working across every `ngrok http` restart instead of changing each time.

<Info>
  This is separate from how many Slack **workspaces** one deployment can serve: any number of different teams can each connect their own workspace to the same Cognee deployment through the same "Connect Slack" OAuth flow — that's already multi-tenant by design and needs no extra setup per workspace.
</Info>

## Troubleshooting

1. **"redirect\_uri did not match any configured URIs"** (shown by Slack, during **Connect Slack**): the `redirect_uri` your backend sent (from `SLACK_REDIRECT_URI`) isn't byte-identical to an entry under **OAuth & Permissions → Redirect URLs**. Slack enforces an exact match as a security measure — add the missing URL there, or fix `SLACK_REDIRECT_URI` to match one already registered.
2. **Slash commands/events return 401**: `SLACK_SIGNING_SECRET` in `.env` doesn't match the app's **Basic Information → App Credentials** value, so Cognee's `X-Slack-Signature` check rejects the request. Recheck the value and restart the backend.
3. **Slack shows "dispatch\_failed" instead of a reply**: the Slash Command's Request URL is missing or wrong — it must point at `/api/v1/slack/commands`, not `/api/v1/slack/events` or `/api/v1/slack/interactive`. If the URL is correct but you see ``Command `/some-command` is not yet supported.`` instead, that command was registered in the Slack App but isn't one of the two Cognee implements (`/cognee-ask`, `/cognee-link`).
4. **"This Slack workspace is not connected to Cognee"**: the OAuth install (**Connect Slack** in the Cognee UI) hasn't completed for this workspace yet, or the connection was later disconnected/revoked.

## Related

<CardGroup cols={2}>
  <Card title="External Data Sources" icon="database" href="/cognee-cloud/connections/external-data-sources">
    Pull Slack channel history in bulk via dlt, instead of the live bot.
  </Card>

  <Card title="Cloud Integrations UI" icon="puzzle" href="/cognee-cloud/ui/integrations">
    Where "Connect Slack" lives in the Cognee UI.
  </Card>
</CardGroup>
