Skip to content

feat(settings): post a brand's Daily Pulse to Slack from Settings › Integrations - #2264

Merged
gkhngyk merged 8 commits into
ansvisor:mainfrom
cihan-gyk:feature/slack-card
Nov 10, 2026
Merged

gkhngyk merged 8 commits into
ansvisor:mainfrom
cihan-gyk:feature/slack-card

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Stacked on #2263 (feature/slack-pulse). Merge that first; until then this diff also shows its commits. This is plan N2, built to the mockup the owner approved on 2026-11-10. It shows only what works today: the channel, the test message and the Daily Pulse switch.

Settings › Integrations › Team and alerts › Slack (slack-card.tsx), for the active brand, like the CMS cards:

  • Not configured on a server without the Slack env vars, naming them.
  • Connect Slack opens Slack's install of the Ansvisor app in a popup, and polls until Composio says it is active, as Brand settings' Google connect does.
  • Use the same workspace as… lists the workspaces other brands use, with their brands, when the person who connected them can see this brand.
  • Once connected, the card shows the workspace, who connected it and when, and which other brands use it.
  • The Channel picker searches the workspace's channels.
    • Channels are listed when the picker opens, or at once while no channel is picked yet ("Pick a channel" is the last setup step).
    • A private channel shows once the app was invited there.
  • The Daily Pulse switch (on by default) follows the Pulse's frequency in Notifications.
  • Send a test message, and Disconnect after a confirm dialog.
  • Problem states, each with its note and a Reconnect:
    • Reconnect when Slack no longer accepts the connection;
    • Paused when the person who connected Slack can't see the brand any more;
    • Pick a channel when the channel is gone.
  • Who sees what:
    • members who aren't admins or managers see where the brand's Pulse goes, with no buttons;
    • the demo brand shows Slack connected with sample data, and its buttons open the plan dialog;
    • a read-only workspace, or a plan without Slack, also gets the plan dialog, not a toast.

Room for the next switches

  • The settings keep all four send kinds: Pulse, drops, daily suggestion, and agents that need someone.
  • The card shows only SLACK_SHOWN_KINDS (['pulse']).
  • N4, N5 and N6 each add their kind there, with their strings, their Help lines and their server send.

Chat › Connections

  • Slack moves from Soon to a live tool in the Team & data group ("The brand's Daily Pulse in a channel", sends messages).
  • Its account is shown as "#channel, workspace", and Settings opens #slack.
  • connection-rows.ts reads the brand's Slack from brand_integrations; before 00470 there is none.
  • No agent asks for it, so agents' checks don't change.

Strings are in web/messages/en.json: settings.slack.*, settings.integrations_team and chatConnections.access.sends_messages.

Help:

  • new help/settings/slack.md (approved: false): connect, channel, test message, when the Pulse is posted, the reconnect states, and disconnect;
  • help/reports/daily-pulse.md (approved) now says the Pulse can also go to the brand's Slack channel, and that Off stops the Slack post too;
  • approved-articles.json is regenerated.

Related issue

Part of #2139.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. cd web && yarn vitest run src/components/settings/slack-card.test.tsx src/components/settings/integrations-section.test.tsx src/lib/chat/connections.test.ts src/lib/demo/integrations.test.ts src/lib/help.
  2. Without COMPOSIO_SLACK_AUTH_CONFIG_ID on the API server, Settings › Integrations › Team and alerts shows Slack Not configured, and nothing else changes.
  3. Live test with Gökhan, once the Ansvisor Slack app and its Composio auth config exist:
    • as an admin, Connect Slack: the popup installs the app, then the card asks for a channel;
    • pick a public channel and Send a test message: "Ansvisor is connected. {brand}'s Daily Pulse will be posted here." arrives;
    • invite @Ansvisor to a private channel: it shows in the picker;
    • run the brand's daily tracking: the Pulse appears in the channel;
    • turn Daily Pulse off and reload: it stays off, and the next Pulse goes by e-mail only;
    • on a second brand, use Use the same workspace as…;
    • Disconnect;
    • as an analyst, the card only says where the Pulse goes; on the demo brand, it shows sample data.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR
  • Help article updated under help/ (or no user-visible change) — see help/README.md

On 2d20ad5:

  • yarn format:check and yarn typecheck pass.
  • yarn lint has 0 errors; its 9 warnings are all in files this PR doesn't touch.
  • yarn test: 1,057 files, 11,530 passed, 1 skipped. This includes slack-card.test.tsx (14 tests), Slack in connections.test.ts, the integrations section, and the Help validator and search, with approved-articles.json regenerated.

After merging #2263's updated branch and current main (27cc29a):

  • typecheck passes.
  • Settings, Chat › Connections, config and Help tests pass: 39 files, 392 tests.
  • It merges cleanly into main.

No new migration (00515 is #2263's) and no new web route, so yarn build wasn't run.


Generated by Claude Code

… (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
… in Chat's Connections

Part of ansvisor#2139 (N2), on the Slack API (N1).

- Settings › Integrations › Team and alerts › Slack, for the active brand:
  Connect Slack (Slack's install in a popup, polled until active), Use the
  same workspace as…, the workspace and who connected it, a searchable
  channel picker (listed when it opens, or at once while none is picked),
  four switches for what goes to Slack, Send a test message, Disconnect.
  Reconnect, Paused (the connector can't see the brand) and Pick a channel
  say what's wrong. Members see where messages go; the demo brand shows
  sample data and opens the plan dialog; so do a read-only workspace and a
  plan without Slack.
- Chat › Connections: Slack is a live tool of the Team group ("sends
  messages"), read from the brand's sign-in in the pool, opening #slack.
- Strings in en.json; Help: settings/slack (approved: false).

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
The card now stacks on the Daily Pulse in Slack (N3), the one thing its
switches post for now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
Part of ansvisor#2139 (N2). The card shows what is posted today: the channel, the
test message and the Daily Pulse (N3). The settings keep the four send
kinds; the drop alerts, the daily suggestion and agents that need someone
each add their switch (SLACK_SHOWN_KINDS), strings and Help with their
server send.

- en.json: the card and Chat's Connections say the Daily Pulse only.
- Help: settings/slack describes connecting, the channel, the test message
  and when the Pulse is posted (its frequency in Notifications);
  reports/daily-pulse says the Pulse can also go to Slack, and Off stops
  that too. approved-articles.json regenerated.

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
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
gkhngyk
gkhngyk previously approved these changes Nov 10, 2026

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@cihan-gyk
cihan-gyk dismissed gkhngyk’s stale review November 10, 2026 10:37

The merge-base changed after approval.

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@gkhngyk
gkhngyk merged commit 22a97da into ansvisor:main Nov 10, 2026
13 checks passed
gkhngyk pushed a commit that referenced this pull request Nov 10, 2026
…rop beyond normal swing (W2-18)

Part of #2139 (N4), on the Slack card (#2264).

- lib/slack/drops.js: after a brand's full daily run, the last 7 complete
  days against the 7 before (explain_change's default), from chat_why_cells,
  on the prompts tracked in both weeks only (the stable cells, on the
  engines tracked in both; ChatGPT Shopping left out). Visibility and the
  citation rate fall beyond normal swing when the drop is more than 2 x its
  standard error, Why did it move's rule (web lib/chat/why/explain.ts),
  ported and kept in step. At most one alert per metric per brand per 7
  days (slack_posts, sent ones). Read only for a brand that posts drop
  alerts to a channel; posted through deliver.js; never throws.
- blocks/drop.js: what fell, from what to what, normal swing, the days and
  engines, Ask Chat why (where the new Chat is on) and Open Visibility.
- The card shows the "Drops beyond normal swing" switch; the test message
  names the kinds the brand will get (POSTED_KINDS); the card, its member
  line and Chat's Connections speak of the Pulse and alerts.
- Help: settings/slack gets "Drop alerts".
- Also: the Pulse's notification text escapes the brand's name for Slack.

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
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-migration Adds or edits a migration — apply it to the hosted database

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants