Repository navigation
feat(slack): post the Daily Pulse to the brand's Slack channel (00515) - #2263
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
Part of ansvisor#2139 (N3), on the Slack connection (N1). - lib/slack/deliver.js: one message to a brand's channel, through every check: Slack set up, not the demo brand, a connected workspace, a channel, the kind turned on, a plan with Slack notifications (every paid plan, trial included; self-host always), and a connector who can still see the brand. Kept in slack_posts before it is sent (unique per brand and dedupe key), so it goes once. Posts to one channel are spaced by 1.1 s; a 429 is tried once more after Retry-After (up to 30 s), a 5xx, timeout or lost call after 2 s. Slack refusing the workspace marks it for a reconnect; a channel that is gone, or the app was removed from, is cleared. Logs carry codes only, and it never throws. - The Pulse's Slack leg, after its e-mail and webhook legs: the e-mail's numbers, highlights and warnings in Block Kit (blocks/pulse.js), worded only when it goes, with links to Visibility and the Pulse settings. It follows the brand's Pulse frequency. sent_pulses.slack_sent records it, apart from the other legs. - Migration 00515: slack_posts (server only, no policy) and sent_pulses.slack_sent; schema.sql rebuilt; the demo skips it. - The test message now says only what is posted: the Daily Pulse. - The Pulse's platform names and signed numbers move to pulse/format.js, shared by the e-mail and Slack. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
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
This was referenced Nov 10, 2026
cihan-gyk
pushed a commit
to cihan-gyk/ansvisor
that referenced
this pull request
Nov 10, 2026
…nect The Slack PRs (ansvisor#2263, ansvisor#2264) added a Team and alerts group where this branch adds the CRM group: both groups are kept, Slack's first, with both strings and both tests. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
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
Builds on #2259 (merged). This is plan N3:
The Settings card that lets a brand turn it on comes in the next PR, stacked on this one.
lib/slack/deliver.jsposts one message to a brand's channel, and only when every check passes:slack_notifications: every paid plan, the trial included, and self-host always;Once the checks pass:
slack_postsbefore it is sent, unique per brand and dedupe key (pulse:{date}for the Pulse). A retried job or a second server sends nothing twice.Retry-After(up to 30 s; longer gives up);token_revoked,invalid_auth…), it is marked so the card asks to reconnect;slack_posts.error_codekeeps Slack's code. It never throws.The Pulse's Slack leg runs after the e-mail and webhook legs, on cloud and self-host alike.
blocks/pulse.js) carry the e-mail's numbers, highlights and warnings: Visibility, 7-day trend, Mentions, Citations, Positive sentiment and Prompts you appear in. They also carry the degraded-data note, lists capped at five items, and links to Visibility and the Pulse settings.sent_pulses.slack_sentis written in its own update, so a database without 00515 still records the e-mail and webhook legs.Migration 00515
slack_posts: organization, brand, the workspace's sign-in, kind, dedupe key, channel, statussending|sent|failed, Slack'sts, error code, attempts.pulse,drop,suggestionandneeds_you; the last three come in N4–N6.sent_pulses.slack_sent.schema.sqlis rebuilt; the demo coverage skips the table, since a demo brand never posts.Smaller changes
pulse/format.js, shared by the e-mail and Slack. The e-mail is unchanged.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/lib/slack src/lib/pulse src/lib/demo/coverage.test.js src/lib/brand-access-policies.test.js. The tests cover:slack_sent;bash supabase/build-schema.shleavesschema.sqlunchanged.slack_posts.error_codesaysis_archived.Needs migration on prod: 00515. It only adds a table and a column, and depends on nothing newer than 00470.
Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/) — no web changeyarn typecheckpasses (run fromweb/) — no web changeyarn format:checkpasses (run fromweb/) — no web changehelp/(or no user-visible change) — nothing can switch it on until the card PR, which brings the Help for bothChecks on 39b9c13:
npm run format:checkandnpm run lintpass.npm test: 447 files, 6,174 passed, 4 skipped.bash supabase/build-schema.shrun, andschema.sqlcommitted with the migration.After merging
main(18c6c41):blocks/connected.js, because it was squash-merged. This branch's version is kept.schema.sqlis rebuilt with 00510 and 00515.main.Generated by Claude Code