The built-in app, the standalone bot, and the cloud connector are three separate Slack apps (different manifest, different scopes, different transport) — do not point one at another’s server.
Built-in Slack App
The Slack app that ships inside thecognee package, served by your own self-hosted backend. Members talk to it by mentioning @cognee in a channel the app is in, or in a direct message to the app. The person who connected the workspace picks which channels are synced into memory; @cognee <question> answers from those channels with a numbered Sources line linking back to the Slack messages it read.
Requires cognee >= 1.6.8. Earlier releases shipped a different app built on slash commands (/cognee-ask, /cognee-remember, /cognee-link, /cognee-import), a Remember entire thread shortcut and the /api/v1/slack/history/* endpoints. All of these were removed in 1.6.8. To upgrade an app created from the old manifest, recreate it from the manifest below, then disconnect and reconnect the workspace (see Reconnecting after a manifest change).
Why Use This Integration
- Ask from anywhere in Slack:
@cognee <question>answers in the thread, citing the Slack conversations it read. Ask in a DM to keep the question private. - Synced channels, not one-off imports: selected channels are synced into one dataset per workspace, and synced again every 6 hours. Edits, deletions and deselected channels are reflected in memory.
- Save what Slack never saw:
@cognee remember <text>stores a note, such as a decision from a call. - Save or retract a message: the Remember this and Forget this message shortcuts store a message in your own memory or take it back out.
- Per-user, not per-workspace: each member links their own Cognee account once with
@cognee link(Sign in with Slack), so their questions and saves use their own memory. - Self-hosted, no middleman: your Slack app talks directly to your Cognee backend. No data passes through a third-party relay.
One Slack app is installed once per workspace, but memory is per-person. A member who has not linked their account is refused rather than attributed to someone else, and is told to send
@cognee link first. The only unlinked member Cognee acts for is the Slack user who installed the app.Prerequisites
- Cognee
>= 1.6.8or adevcheckout. - A running Cognee backend and frontend reachable over HTTPS from the public internet. Slack calls the events URL, the interactivity URL and both OAuth redirect URLs, and it will not call
localhost. For local development use a tunnel (below). In production, use your deployment’s public domain. - The browser must use the same host to start the install and for the OAuth callback. The callback checks a cookie that was set when the install started, and a cookie belongs to one host. On another host the install ends in
error_invalid_state. - A Cognee account for each Slack member who wants to link their own memory.
Local Development: ngrok Tunnel
Tunnel the UI on port 3000, not the API. The UI forwards/api/v1 to the API, including Slack’s signed requests, so the UI, the API and the OAuth callbacks all share one public host. That host is what every <public-host> placeholder below refers to. Skip this section if your deployment already has a public domain.
- Install ngrok:
brew install ngrokon macOS, or download the binary from ngrok.com/download. - Authenticate once: sign up for a free account, copy your authtoken from the dashboard, and run
ngrok config add-authtoken <token>. - Start the UI with the API proxy, then the tunnel:
cognee-cli -ui, put COGNEE_DEV_API_PROXY=http://localhost:8000 in .env instead. The CLI starts the UI with that environment.
- Open the UI at
https://<public-host>. Do not uselocalhost:3000, whichcognee-cli -uiopens by itself. Connecting from there ends inerror_invalid_state, which the UI reports as an expired authorization link, so check the address bar first.
Setup
1. Create the Slack App from the Manifest
- Go to api.slack.com/apps → Create New App → From an app manifest.
- Paste the manifest below. Replace every
<public-host>with your public host and, for a real deployment, change the app name and bot name. - On the app’s Basic Information page, copy Client ID, Client Secret, and Signing Secret. You need them for
.envin step 2.
scripts/slack-app-manifest.sdk.yml, with a local-testing app name and <ngrok> as the host placeholder. Only the callback_ids are matched server-side (remember_this, forget_this). The shortcut names are yours to choose. There are no slash commands. The commands scope is still needed because the message shortcuts require it.
The bot scopes must match the list above exactly. The server requests a fixed set of scopes when a workspace connects, so adding more to the manifest does nothing. message.channels and message.groups send every message of every channel the app is in to your server. The server acts only on deletions and edits (so a synced thread or a saved copy is updated) and acknowledges the rest.
Granting the scopes does not start a sync. Nothing is read until someone selects channels. See Syncing Channels below.
2. Configure Cognee
Copy the app’s credentials into your backend’s.env:
Then bring the stack up from source:
3. Connect, Pick Channels, Link
The self-hosted Cognee UI has no Slack connect screen, so you connect the workspace and pick channels through the API. Cognee Cloud runs its own Slack app with a connect screen in the UI; see Slack in Cognee Cloud.- Log in to the Cognee UI on
https://<public-host>, then openhttps://<public-host>/api/v1/integrations/slack/startin the same browser. It sets the install cookie and redirects to Slack’s consent page. Approving it runs the OAuth exchange and stores the workspace’s bot token.POST /api/v1/integrations/slack/authorizereturns the same Slack URL as JSON, but it sets the cookie on its own response, so call it from that browser, not from a terminal. - Invite the app to each channel you want synced (
/invite @cognee). This includes public channels. - Pick the channels with
GETand thenPUT /api/v1/integrations/slack/resources(see Syncing Channels). A new connection selects nothing, and nothing syncs until channels are picked. - Each member sends
@cognee linkand opens the page it replies with, in a browser where they are logged in to Cognee (see Linking a member). - Try
@cognee What does Cognee do?in a synced channel.
Using It
Mention@cognee in a channel the app is in, or send it a direct message:
An answer is a regular message. Every other reply is ephemeral, shown only to the member who asked. A DM is always allowed. In a channel the channel allowlist applies, except to
forget, unlink and status. There are no slash commands.
A message that starts with @cognee (or another app’s mention), meaning a question or a command, is never synced into memory as channel content, and neither are DMs to the app. A message that mentions @cognee later in its text is still answered, and is synced as ordinary content.
What an Answer Reads
- In a channel, the answer is visible to everyone there, so it reads only what all of them can: the workspace’s dataset limited to that channel (when it is synced) and the selected public channels. It never reads another selected private channel or the asker’s other datasets. In a Slack Connect channel, for a guest asking, or when Slack cannot say which channels are public, it reads that channel alone.
- In a DM, it reads the selected channels the member is in, plus the member’s other datasets whole.
- A channel answer searches the channels’ messages only (
RAG_COMPLETION, a chunk search). The hybrid entity lane is not used, because one entity is one node for every channel that names it and could carry a relation from a channel outside the scope. - The search runs as the asker’s linked Cognee account, so the synced channels are read only when that account has read access to the workspace dataset (
slack_account_<hash>). For a member linked to another account, share the dataset with it first. Otherwise a channel answer reads nothing and replies “Nothing to read here”.
#channel · author · date. A final line says what the answer read, such as From #channel and N public channels, or From your channels and your memory in a DM.
Rating. Each answer carries 👍 and 👎 buttons. Only the member who asked can rate it. A rating is stored as session feedback (5 or 1) and moves the feedback weight of the workspace-dataset graph elements the answer used. @cognee answers do not read these weights: they use a chunk search (RAG_COMPLETION), which ignores feedback. The weights affect graph-completion searches of the workspace dataset, for example through the API or SDK, and only once DEFAULT_FEEDBACK_INFLUENCE is above 0 (default 0.0). With CACHING=false the answer is posted without the buttons.
Linking a Member
@cognee link replies with a link to GET /api/v1/integrations/slack_member/start. Logged in to Cognee in that browser, the member is sent to Sign in with Slack. Slack proves which member signed in, and a nonce cookie proves it is the browser that started it, so nothing typed into or forwarded through Slack can link an account. Only the openid scope is requested, and Slack’s user token is not kept. A client of your own can call POST /api/v1/integrations/slack_member/authorize and follow the returned URL instead. DELETE /api/v1/integrations/slack_member/connection unlinks the member.
Restricting Where Cognee Can Be Used
An opt-in, per-workspace channel allowlist decides where@cognee and the shortcuts work. It never decides what is synced; that is the channel selection’s job. It is set through two authenticated endpoints:
GET /api/v1/slack/channelslists every public channel, plus the private channels the app is in that the person who connected the workspace is also in. Each entry is flagged with whether it is allowed.PUT /api/v1/slack/channelssets the list (channelIds). An empty list (the default) means unrestricted. An id the listing does not offer returns422and nothing is saved.
429 with Slack’s Retry-After. Once a non-empty allowlist exists, @cognee in other channels is refused, so remember this when testing from a scratch channel.
GET/PUT /api/v1/slack/settings holds one owner-only setting, forgetUnavailableChannels (default false). See the channel table below.
Syncing Channels
The channel sync goes through the generic integration routes:
All channels of a workspace go into one dataset,
slack_account_<hash of the team id>. Besides manual syncs, an in-process tick syncs every connection with a selection every 6 hours, and resumes after 10 minutes when a run was cut short by its request budget, a rate limit or a Slack outage. A large channel can take several runs to finish its first sync. SLACK_HISTORY_SYNC_ENABLED=false turns the tick off. One workspace runs one sync at a time.
How conversations are stored. A thread (a message with replies) is one document. The messages without replies of one UTC day in one channel are one document for that day. Authors and mentions are rendered by full name, Slack markup is decoded, and attached files are named but never downloaded. Each document carries the node set slack:channel:<channel_id> (plus slack:shared for a Slack Connect channel). The channel name is kept as the document’s parent, so renaming a channel re-cognifies nothing. Joins, leaves and other non-content messages, the app’s own messages, and messages that talk to an app are left out. DMs and group DMs are not synced.
Edits and deletions. A sync renders again only the threads and days that changed. An edited or deleted message is picked up from the app’s message events and its thread is read again on the next sync. A deleted reply, or a deleted message without replies, is removed the next time its thread or day is read. A thread that is gone from Slack is forgotten only once a sync completes a walk of the whole channel. Forget this or @cognee forget on a message of a synced channel, by its author or by the person who connected the workspace, leaves that message out of every later sync. The message stays in Slack.
Before reading a channel, the sync asks Slack about it:
Documents written by the former history importer (
/cognee-import, before 1.6.8) stay in the datasets they were imported into and are no longer updated.
Syncing a Channel from Code
The same connector is available in the SDK asslack_source, for a bot token you already hold. One source is one channel. The bot token needs channels:history, channels:read and users:read (plus groups:history and groups:read for a private channel), and the app must be a member of the channel.
node_name=["general"] finds nothing. A runnable script is in examples/guides/slack.py.
Search References
A search withinclude_references=True names each Slack document it read by its title and permalink (document_title, document_url) and its channel name (document_parent), which is how @cognee builds its Sources line.
Uninstalling, Disconnecting, and Removing the App from a Channel
- Removing the app from a channel stops it from reading or answering there. A selected channel it was removed from is handled as in the channel table above.
- Uninstalling the app (
app_uninstalled) revokes the connection and, as Slack’s Developer Policy asks, deletes the workspace’s data 14 days later: the synced documents, the dlt staging copy and state, and every member’s Remember this and@cognee rememberitems from that workspace. Connecting the workspace again within the 14 days cancels the deletion. Slack delivers events best effort, so anapp_uninstalledthat never arrives starts no deletion. tokens_revokedalone or a disconnect deletes nothing, unless the disconnect is called withdelete_data=true.- After the connection ends,
GET /api/v1/integrations/slack/connectionreportsconnected: falsewithdisconnectedBy("provider"for an uninstall or a bot token revoked in Slack,"owner"for a disconnect in Cognee, even when Slack echoes it back astokens_revoked),disconnectedAt, and thedatasetIdthe synced data stays in. After an uninstall,dataDeletedAftersays when the data will be deleted anddataDeletedAtis set once it was.
Multiple Environments
Slack apps are tied to one set of OAuth credentials and their redirect URLs. 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 ownSLACK_CLIENT_ID/SLACK_CLIENT_SECRET/SLACK_SIGNING_SECRET/SLACK_REDIRECT_URI/SLACK_MEMBER_REDIRECT_URI.
This is separate from how many Slack workspaces one deployment can serve: any number of teams can each connect their own workspace to the same Cognee deployment through the same Connect flow. Each workspace syncs into its own dataset.
Troubleshooting
- Connect ends in
?slack=error_invalid_state: the UI and the OAuth callback are on different hosts, usually a tunnel while the UI is open onlocalhost:3000. Open the UI on the tunnel host (see the ngrok section), or you used Slack’s own “Install to Workspace” button instead of starting from/api/v1/integrations/slack/start. - “Something went wrong when authorizing Cognee” during Connect: the redirect URI your backend sent (
SLACK_REDIRECT_URI, orSLACK_MEMBER_REDIRECT_URIfor@cognee link) isn’t byte-identical to an entry under the app’s redirect URLs, or.envholds a different app’sSLACK_CLIENT_ID/SLACK_CLIENT_SECRET. - Callback redirects to
?slack=error_exchange_failed: the traceback is in the backend log. Usual causes: a redirect URI mismatch, or a missing/malformedINTEGRATION_CREDENTIALS_KEYS. - Slack’s events URL verification fails: the server is not reachable through the tunnel yet, or
SLACK_SIGNING_SECRETis not set. Start the server with the secret set, then retry the verification on the Event Subscriptions page. - Signature verification fails on every request (401):
SLACK_SIGNING_SECRETdoesn’t match the app you installed. Copy it again from Basic Information and restart the backend. @cogneedoes nothing: the app is not in the channel (/invite @cognee), or the workspace was connected with an older manifest and lacksapp_mentions:read/chat:write. Disconnect and reconnect it.- “Link your Slack account first”: the member has not linked their Cognee account. Send
@cognee linkand open the page in a browser where you’re logged in to Cognee. - An answer says nothing was found in a channel: the channel is not synced and there is no selected public channel. Add the channel with
PUT /api/v1/integrations/slack/resourcesand wait for the sync, or check@cognee status. - The sync reports
failed_missing_scope: the token lacksusers:read. Disconnect and reconnect the workspace. - Request URL mismatch after restarting ngrok: free-tier ngrok mints a new random host every restart. Update every URL in the app’s settings and
.env, or use a reserved domain.
Standalone Channel-Memory Bot
cognee-integration-slack is a separate Slack bot from the cognee-integrations repository. Instead of one synced dataset per workspace, it gives a workspace per-channel memory: once a channel opts in, the bot silently ingests its messages into that channel’s own Cognee dataset, and anyone can ask @cognee <question> or /recall <question> to get an answer with cited links back to the source Slack messages.
It is a thin client to a running Cognee server over HTTP (POST /api/v1/add, /cognify, /search, /forget) — no in-process Cognee and no LLM key of its own, since the server holds those. Slack I/O runs over Socket Mode, so it needs no public URL, no tunnel, and none of the manifest or OAuth setup above.
Install
The package is not published on PyPI yet. Install it from the repository:slack-bolt, aiohttp, and httpx. uv sync creates a project venv without activating it, so run the bot through uv run (below) or activate .venv first; pip install -e . into an already active environment needs neither.
Create the Slack App
In api.slack.com/apps, create an app with Socket Mode enabled, then:- Copy the bot token (
xoxb-…) and the app-level app token (xapp-…). - Subscribe the bot to the
message.channelsandapp_mentionevents. - Add the slash commands
/recall,/cognee-optin,/cognee-optout, and/cognee-forget. - Install the app to the workspace and invite the bot to the channels it should remember.
Configure and Run
The bot reads everything from environment variables (a.env.example ships in the package directory):
Commands
An empty question gets a usage hint back. A channel with no dataset yet — never opted in, or opted in with nothing cognified — returns “I couldn’t find anything about that in this channel’s memory yet.”: the server answers the search with a
404 for the unknown dataset, which the bot treats as an empty result. Once the channel has memory, an unanswerable question gets whatever the LLM produces from the available context; the bot does not filter refusal phrasings. A server-side failure (LLM auth, rate limit, a failed cognify) returns “Sorry — I hit an error answering that.” rather than silence; the cause is in the bot’s logs.
How It Works
- One dataset per channel. Messages land in the dataset
slack_<channel_id>, tagged with a node set of[<channel_id>]. The dataset is the boundary/cognee-forgetclears, so forgetting is per channel, never per person. - Batched graph building. Each message is added with a cheap
addcall;cognifyruns once a channel hasCOGNEE_SLACK_COGNIFY_BATCHpending messages, and always before answering a question, so an answer reflects everything said so far. Concurrent cognify runs on one channel are serialized. - Cited answers. Answering runs two searches:
GRAPH_COMPLETIONfor the prose, andCHUNKSfiltered to the channel’s node set for the source messages. Each stored message carries a one-line provenance header ([cognee-slack] channel=… ts=… author=… permalink=…) inside its text, which is parsed back out of the retrieved chunks to build the links. The reply is a Block Kit message: the answer, then up to five sources as links labelled#<channel ID> · <user ID> · <UTC time>(raw Slack IDs, not names — the link itself opens the original message) with a+N morenote for the rest. A message whose permalink could not be resolved shows as plain text, never a broken link. - What gets ingested. Messages and thread replies in opted-in channels. Edits, deletions, joins, bot messages, the bot’s own posts, messages that mention the bot, and empty messages are skipped. Public channels only, via
message.channels. Edited or deleted Slack messages are not re-synced.
Tests
The suite runs without Slack, Cognee, or LLM credentials — the adapter runs against a fake HTTP client, the handlers against mocks:Related
Channel-Memory Bot Source
Source and tests for
cognee-integration-slack.dlt Integration
Load other sources through dlt the same way
slack_source does.Cloud Integrations UI
Where “Connect Slack” lives in the Cognee Cloud UI.
Node Sets
How per-channel node-set tags scope retrieval.