Skip to content

Let the Slack assistant answer off-topic questions (opt-in checkbox) - #297

Merged
HugoGresse merged 4 commits into
mainfrom
slack-answer-any-question
Oct 28, 2026
Merged

HugoGresse merged 4 commits into
mainfrom
slack-answer-any-question

Conversation

@HugoGresse

@HugoGresse HugoGresse commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

The Slack bot only helps with the event today. This adds an opt-in "Answer any question, even unrelated to OpenPlanner or this event" checkbox on the Slack settings page. When enabled, the assistant also acts as a general assistant in Slack (same model and OpenRouter key). When disabled, nothing changes: the system prompt is byte-for-byte the one shipped today, so existing Slack installs and the in-app chat behave exactly as before.

Changes

  • src/types.ts — new Event.slackAnswerAnyQuestion?: boolean | null (shared with functions via the existing import).
  • src/events/page/api/components/SlackAssistantOptions.tsx — new "Assistant behaviour" block with the checkbox, rendered inside SlackChatSection for both official and self-managed apps. The helper text names the cost exposure (any workspace member who can message the bot uses the event OpenRouter key) and that the scope is a model instruction, not a hard block.
  • src/events/page/slack/EventSlack.tsx / SlackManualSetup.tsx / mapEventSettingsFormToMutateObject.ts — form schema, default value, persistence, and a single form-level Save button (the per-section one in the manual setup is gone).
  • functions/src/api/routes/chat/chatAgent.ts — optional answerAnyQuestion boolean on runChatAgent; when true a scope paragraph is added to the system prompt, otherwise the prompt is unchanged.
  • functions/src/api/routes/slack/slackChatHandler.ts — passes the event flag; long replies are no longer cut at Slack's text cap but continued in the thread (splitForSlack cuts at paragraph / line / word boundaries).
  • functions/src/api/routes/chat/chatAgent.test.ts, slack.test.ts, slackFormat.test.ts — exact prompt assertions, flag → system prompt wiring through the Slack handler, splitting.

Screenshot

New "Assistant behaviour" block on the Slack settings page, checkbox ticked and saved (local emulator, throwaway event). Taken before the Save button moved to the bottom of the page; the block itself is unchanged apart from the helper text.

Slack settings page showing the new Answer any question checkbox, ticked

Test plan

  • tsc --noEmit clean on both front and functions
  • vitest (Node 24, as in .nvmrc): chat/ and slack/ suites green, 46 tests
  • Toggle the checkbox on the Slack page, save, reload: value persists (checked on the Firestore emulator)
  • Ask the bot an off-topic question with the box on / off
  • Ask for a very long answer with the box on: reply continues in the thread instead of being cut

🤖 Generated with Claude Code


Note

Low Risk
Prompt and UI configuration only; no auth or data-model breaking changes, and in-app chat behaviour is unchanged when answerScope is omitted.

Overview
Adds an opt-in per-event setting so the Slack assistant can answer off-topic questions, while tightening the default Slack behaviour to event-only topics.

Organizers get a new Assistant behaviour checkbox on the Slack settings page (slackAnswerAnyQuestion), persisted on the event and wired through the Slack form. The shared chat agent gains optional answerScope (event | any) that injects scope instructions into the system prompt: Slack always passes a scope (event-only unless the flag is on); in-app chat omits it, so its prompt stays unchanged. When scope is event, the model is told to decline unrelated questions; when any, it may act as a general assistant while still using event tools only for event questions.

Unit tests cover the three buildSystemPrompt variants (no scope, event, any).

Reviewed by Cursor Bugbot for commit 0694f8a. Configure here.

The Slack bot only helps with the event today, so teams that want a
general assistant in their channel have to install a second bot. A new
"Answer any question" checkbox on the Slack settings page stores
slackAnswerAnyQuestion on the event; the Slack handler maps it to an
explicit answerScope in the system prompt ('any' or 'event'). The
in-app chat passes no scope, so its prompt is byte-for-byte unchanged.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
firebase-tools 15.34.1 (2026-10-21) now checks that the Hosting API is
enabled before deploying, which calls serviceusage.services.get. The
github-action service account only holds firebasehosting.admin and
serviceusage.apiKeysViewer, so both the PR preview and the merge deploy
fail with a 403 on @latest. Pinning restores the last behaviour that
worked; granting roles/serviceusage.serviceUsageViewer to the account
would let the pin go away.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@HugoGresse
HugoGresse deployed to GitHub Action PR October 27, 2026 22:54 — with GitHub Actions Active
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit cf6a332):

(expires Wed, 04 Nov 2026 08:20:08 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 0c15c45ea5a4c54095387eacf30c3755c9260f22

…ice usage

The github-action service account was granted
roles/serviceusage.serviceUsageViewer on 2026-10-28, so the Hosting API
check added in firebase-tools 15.34.1 passes and the workflows can track
@latest again.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@HugoGresse
HugoGresse deployed to GitHub Action PR October 27, 2026 23:31 — with GitHub Actions Active
The unchecked state no longer injects a "decline unrelated topics" note:
that would have tightened every existing Slack install on upgrade. The
flag is now a plain boolean on runChatAgent that only adds a paragraph
when set, and the no-flag prompt is byte-for-byte the historical one
(the extra blank line is gone, with an exact assertion in the test).

Long replies in "any question" mode were silently cut at Slack's text
cap. markdownToMrkdwn no longer truncates; splitForSlack cuts at
paragraph / line / word boundaries and the handler posts the overflow as
continuation messages in the thread. The streaming updater still
truncates since chat.update carries a single message.

slack.test.ts now asserts the flag reaches the system prompt and that
the default leaves it untouched. Helper text states the cost exposure
(any workspace member uses the event OpenRouter key) and that the scope
is a model instruction, not a hard block. The Slack page has a single
form-level Save button instead of one per section.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@HugoGresse
HugoGresse deployed to GitHub Action PR October 28, 2026 08:19 — with GitHub Actions Active
@HugoGresse
HugoGresse merged commit cebba22 into main Oct 28, 2026
5 checks passed
@HugoGresse
HugoGresse deleted the slack-answer-any-question branch October 28, 2026 08:21

This branch was successfully deployed

1 active deployment
GitHub Action PR — cf6a3329 Deployed Oct 28, 2026 by HugoGresse via build_and_preview #546
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant