Repository navigation
feat(slack): connect a Slack workspace per brand and pick its channel (API) - #2259
Merged
Merged
Conversation
… (API) Part of ansvisor#2139 (N1). Server only; the card comes next. - A brand's Slack is one more sign-in in the Account's pool (integration_accounts, provider `slack`, labelled with the workspace's name from auth.test), used through brand_integrations as a brand's own Google login is. Its channel and the four send switches (Pulse, drops, daily suggestion, agents that need someone) live in the row's settings. - Composio: Slack's install through the Slackbot toolkit's auth config (COMPOSIO_SLACK_AUTH_CONFIG_ID: Ansvisor's own Slack app, or Composio's managed one as a fallback). Slack is called through Composio's proxy (proxyRequest now POSTs a JSON body), so the bot token stays with Composio and Slack's own codes and Retry-After come back. - lib/slack/api.js: slackGet / slackPost, every failure a SlackError with a code only. lib/slack/connection.js: the brand's Slack, where it stands (not connected, refused, access lost, connected), channels page by page, the test message (blocks/connected.js). - routes/slack.js under /api/slack/brands/:brandId: read for anyone who can access the brand; connect, activate, use another brand's workspace, channels, PUT channel and switches, test message, disconnect for admins and managers. Writes but Disconnect need the plan's slack_notifications. A workspace whose connector can't see the brand isn't offered or posted to. Slack refusing the connection marks the sign-in; a channel that is gone is cleared. The demo brand connects nothing. - A brand's settings on a sign-in start over when it uses another one. - Plans: slack_notifications (Starter, Growth, Enterprise, self-hosted) and slack_approvals (Growth, Enterprise, self-hosted), in both plan files. - Demo and read-only guards, slackLimiter, /api/integrations/config's `slack`, env docs. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
The web opens the plan dialog on error plan_limit; the routes said it only in code. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
cihan-gyk
pushed a commit
to cihan-gyk/ansvisor
that referenced
this pull request
Nov 10, 2026
ansvisor#2259 was squash-merged, so its file came back as an add/add conflict: this branch's connected.js is kept (its test message names the Daily Pulse only). schema.sql is rebuilt with 00510 and 00515. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
cihan-gyk
pushed a commit
to cihan-gyk/ansvisor
that referenced
this pull request
Nov 10, 2026
Brings in upstream/main through feature/slack-pulse: ansvisor#2259 (squash-merged) and the MCP OAuth PRs. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
This was referenced Nov 10, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First of the Slack PRs (plan N1, approved by the owner on 2026-11-10). It is server only; the Settings card comes in a later PR.
A brand's Slack follows the brand access connection model (fix(mcp): read each brand's Google sign-in in list_connections (brand access PR 14) #2045, feat(web): let each brand choose its Google account in Brand settings > Integrations (brand access PR 15) #2112).
integration_accounts, providerslack, labelled with the workspace's name fromauth.test).brand_integrations), as a brand's own Google login does.settings. They start over when the brand switches to another workspace, because a channel belongs to its workspace.Composio, with Ansvisor's own Slack app.
COMPOSIO_SLACK_AUTH_CONFIG_ID), set up with our own Slack app. Composio's managed app works too, as the env fallback.Retry-Afterback.proxyRequestnow POSTs a JSON body.lib/slack/api.js:slackGet(reads, query) andslackPost(writes, JSON). Every failure is aSlackErrorthat carries a code only, never Slack's or Composio's text.lib/slack/connection.js: the brand's Slack, and where it stands:not_connected;refused: the workspace removed the app or revoked the token;access_lost: whoever connected it can't see the brand any more, so nothing would be posted;connected.It also lists channels (up to 5 pages of 200, archived ones left out), checks a channel, and posts the test message (
blocks/connected.js, worded on the server as the e-mails are).routes/slack.js, under/api/slack/brands/:brandId:GETis open to anyone who can access the brand.connect,activate,use(another brand's workspace),GET channels,PUT(channel and switches),testandDELETE.slack_notifications. Disconnect works on a read-only workspace.useand aren't posted to.auth_failed. A channel that is gone is cleared.Plans (owner, 2026-11-10), in both plan files:
slack_notificationson Starter, Growth, Enterprise and self-hosted;slack_approvalson Growth, Enterprise and self-hosted, for the later approvals PRs.Guards and docs:
slackLimiter(60 calls per 15 minutes, like the CMS cards);/api/integrations/configgetsslack;server/.env.exampleanddocs/self-host/env-variables.mdxdocument the new env var.No migration: the pool tables take a
slackprovider as they are. Nothing a person sees changes yet.Related issue
Part of #2139.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
cd server && npx vitest run src/routes/slack.test.js src/lib/slack src/lib/composio.test.js src/lib/brand-integrations-own.test.js src/routes/integrations-config.test.js src/middleware src/routes/write-roles.test.js.server/src/lib/slack/__fixtures__/slack-api.json. They are recorded in the shapes Slack documents (auth.test,conversations.listover two pages,conversations.info,chat.postMessage, and the error answers), with ids and names replaced.COMPOSIO_SLACK_AUTH_CONFIG_ID;POST /api/slack/brands/:id/connectwith a callback on the app, open the address it returns, thenPOST /activate;GET /channels,PUT { channelId },POST /test: the test message arrives in the channel;What Gökhan sets up first (about 1.5 hours):
chat:write,chat:write.public,channels:read,groups:read,users:read,users:read.email;COMPOSIO_SLACK_AUTH_CONFIG_IDon the API server.Fallback: a Composio-managed Slackbot auth config. Its consent screen says "Composio", and workspaces connected through it must reconnect when we switch to our own app.
Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/) —eslint src/config/plans.ts, the only web file changedyarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/) —prettier --checkon the changed filehelp/(or no user-visible change) — no user-visible change yet;help/settings/slack.mdcomes with the cardAlso run on this branch (c29093a, which merges cleanly into current
main):npm run format:checkandnpm run lintpass.npm testran on 5638028: 445 files, 6,147 passed, 4 skipped.slack.test.jsandwrite-roles.test.jspassed again (48 tests).src/config/plans.tsis the only web file. The plan-related tests (src/config,plan-facts,precedence,access,src/components/settings,src/components/billing,src/lib/white-label,src/lib/billing) pass: 62 files, 729 tests.build-schema.shisn't needed. No web route changed, soyarn buildwasn't run.Generated by Claude Code