Repository navigation
Proposal: interactive actions on bot messages #244
ronaldlokers
started this conversation in
Ideas
Replies: 1 comment 1 reply
|
I opened a PR implementing the bot actions discussed here: #247 It supports:
I tested the different use cases locally with a working webhook, including polls, multi-user checklists, persisted selections, app links, icon-only choices, and webhook-driven message updates. The PR also adds bot documentationthat covers the complete bot API, not only actions. Feedback on the API shape and behavior would be very welcome! |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary
Bots can now edit their own messages (merged in #239). That turned out to be half of something bigger, and I'd like to propose the other half:
A bot may attach a short list of labelled actions to a message. Clicking one POSTs back to the bot's webhook.
That's the whole ask. No layout framework, no schema language, no form builder — those belong in bot-land, and with self-editing already in place, they compose out of what's there for free. I'll show that below.
I'm happy to implement this and open a PR; I'd rather agree on the shape first.
Why this is worth doing
A bot message is currently a dead end: the only way for a human to respond is to type. The workarounds all have real problems.
Outbound links are the closest thing available today, and they're genuinely risky. A GET that mutates state is a loaded gun in a chat client — any link unfurler, prefetcher, or corporate link scanner can fire the action with no human involved. The safe version needs an interstitial page with a confirm button, which defeats the point. Links also punt you into a browser tab, which for a one-tap "yes, deploy it" is a heavy context switch and on mobile is worse than typing.
Typed replies are fine between humans and poor as an interface. They need a command vocabulary the user must remember, they're error-prone on a phone keyboard, and they can't be disambiguated when three prompts are outstanding.
Boosts are semantically wrong. A boost is a reaction, not a decision, and there's no way to express "these three specific options."
Prior art
action_idper element,block_actionspayload to a configured request URLcustom_id(100 chars) echoed back in the interactionactionsarray inside a message attachment; each action names an integration URL plus acontextobjectcallback_data(64 bytes) echoed to the botThe consistent shape across all four: a label, an opaque developer-defined value, and a callback carrying that value back. Everything past that is layout ambition. Mattermost's early design is the sweet spot, and notably it lets integrations create interactive messages without pre-registering anything — which fits Campfire's bot model exactly.
The proposal
Actions on outgoing bot messages
Extend the existing bot message endpoint:
label— display text. Short.value— opaque to Campfire, echoed back verbatim. I'd suggest a 200-character cap so bots can pack state; Discord's 100 is occasionally tight and Telegram's 64 bytes definitely is.style— optional,default/primary/danger. Presentation only.Cap at something small, maybe 5 actions per message. Plain buttons in a row under the message body; no new layout concepts.
This is additive and non-breaking: strong params already drop unpermitted keys silently, so an older server receiving
actionsposts the message and ignores them, and a bot that never sendsactionssees no change at all.Callback to the bot's webhook
Reuse the inbound envelope so bot authors need almost no new code:
{ "type": "action", "room": { "id": 23, "name": "Ops" }, "user": { "id": 42, "name": "Kevin" }, "message": { "id": 100 }, "action": { "value": "deploy:a1b2c3" } }A
typediscriminator means existing bots keep working — they can ignore anything that isn't a message. As with regular bot messages, the callback should be suppressed if a bot somehow triggers its own action.Why one primitive is enough
Every richer interaction is a loop of post → action → edit, and that loop now lives entirely in the bot, because the edit half already exists.
A poll is not a server feature. It's a bot that posts a message with one action per option, tallies votes in its own store, and edits its message to show the running result:
Roughly fifty lines of bot code, no server involvement. And because the bot owns the logic, someone else can build a different poll — ranked choice, anonymous, quorum-gated, auto-closing — without anyone touching Campfire.
The same loop gives you:
[ ← ] [ → ]edit the body in place, so long output stops flooding the room.[ I'll take it ]edits the body to show the owner and drops the button.This is also why I'd resist a Block Kit-style schema. Slack needed one because third parties build against a hosted product they can't extend. Campfire users run their own server and write their own bots; the expressive power belongs on their side of the wire.
Editing is also what keeps rooms clean: without it every action leaves a permanently-live button behind and the room becomes a minefield of stale prompts. That's already solved.
Use cases
[ Ack ] [ Escalate ]on an alert, the message editing to show who acked and when.[ Merge ] [ Rerun ] [ Mute 1h ]on a failed build.[ Lock up ] [ Snooze ], which is my own use case.[ Run it ] [ Show me the diff ] [ No ]is a much better consent surface than asking someone to type "yes". Campfire is well placed here precisely because it's self-hosted.Security considerations
valueis untrusted input to the bot. Worth documenting loudly. Bots should sign or namespace values rather than trusting them — same discipline as a URL parameter.Explicitly out of scope
Naming these so the discussion doesn't sprawl:
selectaction type is an additive follow-up if buttons prove insufficient.Related work
There's an open PR (#210) implementing polls directly: three new models (
Poll,PollOption,PollVote), three controllers, three Stimulus controllers, dedicated CSS, and migrations — all for one feature, which then can't be varied without another PR.I want to be clear that's a well-built PR and I'm not arguing against it so much as offering a different trade. The
actionsprimitive is a fraction of that surface area, and polls fall out of it as bot code, alongside checklists, approvals, and everything else in the list above. If polls are wanted as a first-class product feature with a compose-box affordance, #210 is the right shape and this proposal doesn't replace it. If the goal is for Campfire to stay small while people build what they need, this is the cheaper path — and it's the one that also covers the deploy-approval and on-call cases, which no amount of poll support reaches.Also worth noting jpshackelford's earlier work on bot endpoints for reading messages and adding reactions (#190, now closed) — same surface, worth a look for envelope conventions before anyone settles naming here.
Open questions
@-mentioned recipients?value? Bots needing more can store state and pass a key.confirmstring for destructive actions, or is that scope creep? I lean toward leaving it out of v1 — a bot can always send a second message.Happy to prototype if the direction seems reasonable. I've been running the edit endpoint pinned to main in my own cluster since it merged and it's been solid; I'd dogfood this the same way before proposing it as done.
All reactions