Skip to content
askdareDocumentation

    ADR-0044: Live chat after a handoff, and the vendor adapters

    • Status: Accepted on 2026-12-04 by the maintainer, with every recommendation (see "Settled with the maintainer"). Built by tasks 0.9-h1 to h5, after 0.9-b1 makes room.
    • Date: 2026-12-04
    • Amends: ADR-0030 (decision 8: the bot stops while a person writes; new handoff states; a live channel next to onHandoff), ADR-0033 (decision 4: a person's reply reaches the page as message.received) and ADR-0013 (message.received gains from).
    • Related: ADR-0004, ADR-0006, ADR-0022 (developer notes), ADR-0024, ADR-0027, ADR-0028, ADR-0031, ADR-0032, ADR-0041 (it takes React room first).
    • Evidence: a prototype on a local branch, spike/live-chat-0044, never pushed or merged. Vendor APIs were checked in their official docs on 2026-12-04 (links in decisions 8 and 9). OpenAI's Conversations API was checked in its OpenAPI spec through the openaiDeveloperDocs server on the same day.

    Context

    askdare 0.7 hands a conversation to a person one way (ADR-0030): a report goes to a webhook or a mailbox, the person answers by email, and the bot keeps answering. ADR-0030 left two promises for 0.9:

    • decision 8: "a setting to stop the bot after a handoff waits for live chat … where it means 'a person is now writing here'";
    • ADR-0033 decision 4: "a human's reply in the chat must reach the page as message.received, or the badge misses it."

    The maintainer chose the adapters on 2026-12-02 (ROADMAP, #300): Slack with live chat, HubSpot and Zendesk one-way, each creating a ticket. Two-way HubSpot (Custom Channels) and Zendesk (Sunshine Conversations) need paid tiers and stay under Later.

    What bounds the design:

    • No open connection between turns. The chat talks to the server only while a turn streams (ADR-0027). A person's reply arrives whenever the person writes.
    • No database and no pub/sub of askdare's own (ADR-0003). Conversations live in the app's ConversationStore (OpenAI Conversations, Postgres, or memory in tests), and counters in the rate-limit store (memory or Upstash).
    • Serverless hosts. Vercel and similar hosts run a function per request, up to the route's maxDuration. Nothing runs between requests: no timers, no background workers.
    • The client chooses nothing (ADR-0004), and every rendered text is sanitized.
    • The budgets. After 0.8, by CI's zlib: 344 B left in the React entry and 292 B in the headless case. ADR-0041 (runtime themes, accepted) takes about 140 B and 45 B of that, leaving about 204 B and 247 B. The loader has 348 B left, and ADR-0041 takes about 141 B of it.

    What the prototype measured

    Bytes

    The prototype adds the chat side of live chat to main:

    • the new handoff states;
    • author and name on history messages;
    • POST /live read every 3 seconds while a handoff is waiting or live and the page is visible, slowing to 15 seconds after a minute without a reply, and sending the visitor's text through the same request;
    • the person's replies added to the message list;
    • message.received with from: 'person' for each reply;
    • a MessageAuthor primitive (the person's label) in the default look.

    The state line needed no new code: HandoffStatus already shows handoff.<state>. Texts come from the server's configuration, so they add nothing to the bundles (checked: the default dictionary isn't in dist/react.js). Sizes are gzipped, measured with scripts/react-size.mjs and scripts/inline-assets.mjs on a laptop. CI's zlib compresses about 30 B worse per bundle, so the "left" column uses ADR-0041's CI figures.

    WhatmainPrototypeAddedLeft after ADR-0041 (CI)Left after both (CI estimate)
    React entry (react.js)34,34334,680+337204−133
    Headless (Root and useChat)11,96612,243+277247−30
    Embed (EmbedRoot and useChat)12,73413,015+2811,4121,131
    Iframe app44,40044,749+3496,1775,828
    Loader5,2845,289+5175170
    • The loader's 5 B is from: 1 in embed/host-events.ts, the loader's allowlist of event fields. That allowlist is typed from ChatEvent, so a new field on message.received doesn't compile without it. Without the field, the page wouldn't see from, but the badge would still count the reply (it counts outcome: 'completed'). embed/loader.ts itself doesn't change.
    • The prototype is the minimum. h2 adds the composer's placeholder while waiting, the state line's placement and screen reader details. This ADR budgets +420 B in the entry and +350 B in the headless case for h2, about 25% over the prototype.

    A lazy chunk is bigger, not smaller

    Moving the reading loop into a chunk loaded with import() when a handoff becomes waiting was measured too. Rolldown then splits the whole entry into an entry chunk and a shared chunk, and the first load grows:

    WhatEager (prototype)Lazy: first loadLazy: live chat chunk
    React entry34,68035,671 (9,508 + 26,163)361
    Headless12,24312,295 (71 + 12,224)356
    Embed13,01513,404 (1,433 + 11,971)360

    react-size.mjs counts every chunk, so the lazy variant also fails the check as it is measured today. A lazy chunk is rejected (decision 7).

    Polling against the stores

    A test on the spike branch (src/spike-live/poll.test.ts) models POST /live: one page({ limit: 20 }) read, then the items after the client's cursor (the ID of the newest item it has seen).

    • Memory store: 0.053 ms per read on a 200-item conversation. One store call per read, and only new items come back; a quiet read returns nothing.
    • Postgres (@boldare/askdare-postgres): page() is one order by seq desc limit N query on the conversation's index, so a read costs one indexed query.
    • OpenAI Conversations: a read is one GET /conversations/{id}/items (order, limit 1 to 100, after an item ID; OpenAPI spec, 2026-12-04). It uses no tokens and counts against the project's request rate limit; the spec documents a 429 and no separate limit. Items carry no timestamps, so times go in the notes (decision 3).

    At 3 seconds, a visitor in a live chat costs about 20 reads a minute, and about 4 a minute after the backoff. Each read is a function invocation on serverless hosts.

    Decision

    1. The states and who moves them

    A live handoff adds four states after requested, beside ADR-0030's six:

    • waiting: the request reached the live channel and nobody has joined yet.
    • live: a person has written in the conversation.
    • ended: the person ended it, or nobody wrote for idleMinutes.
    • missed: nobody joined within waitMinutes. The request stays in the channel, as a one-way handoff would.
    FromToMoved by
    requestedwaitingthe live channel's open() succeeded (instead of sent). A failure goes to saved or failed as in ADR-0030.
    waitinglivethe channel's first inbound message from a person
    waitingmissedwaitMinutes (default 10) with no person's message
    liveendedthe person ends it in the channel (Slack: decision 8), or idleMinutes (default 30) with no message from either side

    Timeouts need no scheduler. The server checks the times whenever it reads the state: on POST /live, on POST /messages, on POST /history and on an inbound event. If a timeout has passed, it appends the state's note and tells the channel (close()). When the visitor has left and the person never writes again, the channel is told on the next inbound event. The adapter then answers in the thread that the chat has ended.

    The visitor ends a live chat by starting a new conversation, which is the existing action. The old conversation ends at its idle timeout. A visitor's "End chat" button is Later: it costs bytes in the headless case, and a visitor who leaves doesn't press it.

    What the visitor sees, as new texts in all seven languages (h2 fixes the wording):

    • handoff.waiting: "Waiting for a person to join. You can write to them here."
    • handoff.live: "You're chatting with a person from our team."
    • handoff.ended: "The chat with our team has ended. I'm back to help."
    • handoff.missed: "Nobody could join right now. The team has your request and will get back to you if you left a way to reach you."
    • handoff.person: the label on a person's messages ("Team").

    2. Turning it on

    defineBot({
      handoff: {
        form: 'handoff',
        content: 'summary',   // what the person sees when the thread opens (ADR-0030)
        live: {
          waitMinutes: 10,    // 1–120: nobody joined → missed
          idleMinutes: 30,    // 1–240: nobody wrote → ended
          names: false,       // show the person's display name instead of `handoff.person`
          limits: { perMinute: 10, perConversation: 200 }, // the visitor's live messages
        },
      },
    });
    
    createChatHandler({ bots, liveChannel: slackHandoff({ token, signingSecret, channel }) });
    • live: true is a shortcut for the defaults. A bot with live and a handler without liveChannel fails at startup, and doctor says so, as for onHandoff (ADR-0030 decision 1).
    • One live channel per handler. The adapter routes bots to channels itself (Slack: channel as a string or a function of the bot). A bot without live uses onHandoff if it is set, and otherwise the live channel's one-way post. So liveChannel alone also covers one-way bots.
    • The bot is silent from waiting until ended or missed. No stopBot option: a bot that answers while a person writes, or while the visitor waits for one, makes two voices in one chat. While the bot is silent:
      • the visitor's message runs no model call and goes to the channel, stored in the conversation;
      • it is charged no tokens and no bot budget;
      • it has its own limits: perMinute per visitor, and per IP grouped by /64 as ADR-0030's are; perConversation for the whole live chat; and the bot's maxInputChars;
      • over a limit, the chat shows the existing rate_limited error.
    • Handoff limits (ADR-0030 decision 7) count a live handoff when it is accepted, as before. The docs suggest perConversation: 2 for live bots, so a visitor whose handoff was missed can ask again later.

    3. Where a person's messages live

    In the conversation store, so history, reloads, the console and the next model call see them. Every store works unchanged; no port change.

    • A person's message is an assistant message preceded by a developer note: [askdare:live] person <epoch ms>, with the display name after it when names is on (at most 64 characters, plain text). Both go in one append, so they stay together.
      • The assistant role keeps the person's words out of developer authority (unlike a note) and out of the visitor's voice (unlike a user message).
      • The note tells the model that a person wrote them, not the model itself.
    • The visitor's message while the bot is silent is a user message preceded by [askdare:live] visitor <epoch ms>.
    • State changes are notes too: [askdare:live] waiting|live|ended|missed <epoch ms> [target], with fixed sentences as in ADR-0030. For example, ended: "The person from the team finished the chat; you answer again. Do not repeat what they said." waiting carries the channel's target (decision 5). The latest note gives the state, and its time drives the timeouts, since OpenAI's items carry no time (at is 0).
    • On OpenAI Conversations the items go through POST /conversations/{id}/items, which takes up to 20 input items per call, assistant messages included (spike S7 did the same). It refuses an append while the conversation is locked by a running response. That happens when the model's handoff call is still streaming its last words as the person replies. The inbound side therefore retries the append with backoff for up to 20 seconds (decision 5). On item stores, a VersionConflictError gets the same retry (0.8.x-p4 fixes the related turn-side conflict).
    • History returns a person's message as role: 'assistant' with author: 'person' and, when names is on, name. It has no feedback handle, citations or reply options: a visitor doesn't rate a person's message. The notes themselves aren't shown.
    • What the model reads after ended: the live transcript, between the notes, at normal input cost. Long live chats grow the context. Item stores compact as ADR-0029 says, and docs/costs.md mentions it.

    4. Getting replies to the widget: polling POST /live

    Recommended: polling. While the latest handoff is waiting or live, the chat posts POST /live every 3 seconds, and every 15 seconds after 20 quiet reads in a row (about a minute). It reads only while the page is visible (visibilitychange), resumes when the page shows again, and stops when the state ends or the chat stops. The visitor's own message goes through the same request (text), so live chat has one endpoint and one loop.

    • Several instances: each read takes the newest page of the conversation store and returns the person's messages after the client's cursor. The store is the shared truth, so no pub/sub is needed.
      • This holds for every store that is shared: OpenAI Conversations, Postgres, any ConversationStore add-on.
      • It doesn't hold for the memory store across instances, which already can't serve several instances, and doctor warns about it in production (0.8.x-p1).
    • The cost per live visitor is at most about 20 reads a minute. That is one indexed query (Postgres), a map lookup (memory) or one GET with no tokens (OpenAI) each, plus a function invocation on serverless hosts. It lasts only while a person is asked or writing and the page is visible.
    • Latency: a reply shows within 3 seconds while the chat is active, and within 15 after a quiet minute. That is acceptable for a person typing in Slack.

    A held SSE stream was considered and not chosen (see "Alternatives"). Without pub/sub, the server would still read the store in a loop, only inside a function held open up to maxDuration, which serverless hosts bill by duration. It would also need reconnects, and proxies that buffer streams break it. Polling can later shorten to long-polling (holding a read up to about 20 seconds) without a protocol change beyond an optional wait field.

    5. The live channel port

    One-way adapters stay plain onHandoff functions (ADR-0030 decision 5). HubSpot and Zendesk are those (decision 9). A live channel adds an inbound side:

    interface LiveChannel {
      /** The route segment: `POST <basePath>/handoff/<name>`. `[a-z0-9-]{1,32}`. */
      readonly name: string;
      /**
       * Posts the request. With `ref`, it opens a live chat and must carry `ref` so that every inbound
       * event about it can hand it back. Without `ref`, it is a one-way post. Resolves to the channel's
       * own target for later `send` and `close` calls (Slack: channel and thread). Throws on failure.
       */
      open(report: ChatHandoffReport, live?: { ref: string; signal: AbortSignal }): Promise<string>;
      /** Posts the visitor's message to the target. */
      send(target: string, message: { text: string; at: number }, signal: AbortSignal): Promise<void>;
      /** Tells the person it ended: `person`, `idle`, `missed`, or `gone` (the conversation was deleted). */
      close(target: string, reason: LiveEndReason, signal: AbortSignal): Promise<void>;
      /**
       * Verifies an inbound request (signature, timestamp) and parses it. Returns the response for the
       * vendor (Slack's URL challenge, an acknowledgement) and the events to apply.
       */
      receive(request: Request): Promise<{ response: Response; events: readonly LiveEvent[] }>;
    }
    
    type LiveEvent =
      | { kind: 'message'; ref: string; id: string; text: string; name?: string }
      | { kind: 'end'; ref: string; id: string };
    • How an inbound event finds its conversation: askdare gives open() a sealed reference, ref. It is a JWE like the resume token (ADR-0004: dir + A256GCM, keys from CHAT_SECRET by HKDF, its own typ, aud = the bot, 30 days, rotation through CHAT_SECRET_PREVIOUS). It carries the conversation ID and the handoff's id.
      • The channel stores it where its vendor hands it back, and askdare stores no mapping. Slack puts it in the request message's metadata (decision 8).
      • An event whose ref doesn't open, or whose conversation is gone, is acknowledged and dropped. The channel is told gone once, so the person learns the visitor left.
      • The reference is encrypted, so the conversation ID never reaches the vendor in clear.
    • The inbound route POST <basePath>/handoff/<name> has none of the browser endpoints' checks (origin, access token): the vendor calls it, and only receive authenticates it.
      • The body is capped at 64 KB, and requests are rate-limited per IP.
      • It answers within the vendor's deadline (Slack: 3 seconds). receive and the acknowledgement run first; appending and the timeouts run after the response through waitUntil or after(), with the append retry of decision 3.
      • Replay: the vendor's timestamp window (Slack: 5 minutes, checked in receive), and each event's id claimed once for 10 minutes in the rate-limit store. That is the same one-time claim forms use (claimForm), shared across instances with Upstash.
    • Public (ADR-0006): LiveChannel, LiveEvent, LiveEndReason and the liveChannel option of createChatHandler, from @boldare/askdare/next; handoff.live and its types in defineBot; memoryLiveChannel() in @boldare/askdare/testing for apps' own tests and h1's. Sealing and opening ref stay internal: a channel treats ref as an opaque string.

    6. The protocol (additive in version 1)

    Each goes into docs/protocol.md, with fixtures (protocol-0.9.test.ts, on the model of protocol-0.7.test.ts):

    1. HandoffState gains waiting, live, ended and missed: in the handoff event, in POST /handoff's and POST /forms's answers, and in history's handoff.state. An old client shows an unknown state as nothing, as it ignores unknown values.
    2. History messages gain author?: 'person' and name?: string (1 to 64 characters, plain text).
    3. POST /live { botId, resumeToken, after?, text? }, with the access token, the resume token owning the conversation, and the same-origin checks every endpoint has. It answers 200 { state, messages, after? }:
      • messages holds only the person's messages after after, as history messages. The visitor's own messages aren't echoed back.
      • after is the newest item's ID, opaque to the client.
      • text is the visitor's message, sent to the channel and stored, answered without a turn.
      • In a state other than waiting or live, it answers the state and no messages, and refuses text with 409.
      • 404 for a bot without live; 429 for its burst limit.
    4. POST /messages while waiting or live answers 409 with a new error code (h1 names it, for example live_chat), so an old client gets an error instead of a model answer.
    5. The browser event message.received gains from: 'person' for a person's reply, with outcome: 'completed', durationMs: 0 and citations: 0. The bot's answers carry no from. The loader's field allowlist gains from (decision 7).
    6. The inbound route POST <basePath>/handoff/<name> is the channel's, not the chat's, and is documented with the adapter.

    7. The chat and its budget

    • A person's message renders in the message list with data-author="person" and a label (MessageAuthor, part author: the name or handoff.person). Its text goes through the same Markdown renderer and sanitizer as answers, with the same link allowlist. "Sanitized like model output" then costs no extra code, where a plain-text branch would. The adapter turns its vendor's formatting into plain Markdown (Slack: decision 8).
    • The state line is the existing HandoffStatus with the new texts. While waiting, the composer's placeholder becomes handoff.waiting, so the visitor knows they can write.
    • A person's reply is announced once to screen readers, as answers are, and never moves focus. It emits message.received with from: 'person'. The loader's badge counts it with no change to embed/loader.ts. The loader's field allowlist, embed/host-events.ts, gains from (+5 B, measured). h2 makes that one-line change after r1c, which owns the loader in 0.9.
    • The budget: b1 makes room first; no lazy chunk; no budget raise.
      • Added by h2 (estimate): +420 B in the entry and +350 B in the headless case. ADR-0041's React part adds +140 B and +45 B. ADR-0028 wants about 100 B of headroom for marked patches in the entry.
      • b1 frees at least 350 B in the React entry and 200 B in the headless case, measured on CI from 0.8's 344 B and 292 B left. That is 140 + 420 + 100 − 344 ≈ 316 B and 45 + 350 + 50 − 292 ≈ 153 B, rounded up.
      • If b1 can't reach that with the same behavior, it stops and says so with the numbers. A budget raise then needs its own ADR under ADR-0028, as decision 3 there says.
      • A lazy live chat chunk is rejected: measured, it makes the first load larger in every case.

    8. Slack: a channel per bot, a thread per conversation

    Checked in Slack's docs on 2026-12-04.

    • Each team creates its own internal app from a manifest in the docs, so there's no Marketplace listing.
      • Scopes: chat:write, channels:history (or groups:history for a private channel) and reactions:read.
      • Events: message.channels (or message.groups) and reaction_added, at the Request URL <basePath>/handoff/slack.
      • Internal apps keep Tier 3 for conversations.history (50+ requests a minute). The 2025 cut to 1 request a minute applies to commercially distributed apps that aren't in the Marketplace (changelog 2025-05-29).
      • Socket Mode needs a long-lived process, so it doesn't fit serverless hosts, and Request URLs do.
    • Opening: chat.postMessage posts the report to the bot's channel, as plain text with the report's content level. metadata is { event_type: 'askdare_handoff', event_payload: { ref } }.
      • Slack says metadata is readable by any member of the workspace. ref is encrypted, and the payload holds nothing else.
      • The message's ts is the thread, and target is <channel>:<ts>.
      • The adapter then posts the instructions in the thread: "Reply in this thread to chat with the visitor. React with ✅ to the first message to end it."
      • chat.postMessage, message metadata
    • The visitor's messages go to the thread with chat.postMessage (thread_ts), within Slack's limit of about 1 message per second per channel. A 429 gets one retry after its Retry-After, within the request's deadline; otherwise the visitor sees a delivery error and can resend.
    • Replies: message events in a thread (thread_ts ≠ ts).
      • Slack documents that message_replied events lack their subtype, so the adapter detects replies by thread_ts.
      • Events with bot_id are skipped, the adapter's own posts among them. So are edits, deletions and other subtypes, and files: a person's file isn't forwarded, and the adapter answers in the thread that files don't reach the visitor.
    • Finding the ref for a reply: a reply's event doesn't carry its parent's metadata. The adapter reads the parent once with conversations.history (latest = thread_ts, inclusive, limit: 1, include_all_metadata) and keeps thread_ts → ref in a small per-instance cache. This is one read per thread per instance, not polling. conversations.replies is never used.
    • Ending: a ✅ (white_check_mark) reaction on the thread's first message, from reaction_added (item.ts is the parent's).
      • Slash commands can't be run in threads and don't carry a thread_ts (slash commands), so they can't end a specific chat.
      • A keyword reply ("end") was rejected: it is easy to type by accident.
    • Verification: X-Slack-Signature is v0= plus HMAC-SHA256 with the signing secret over v0:<timestamp>:<raw body>, compared in constant time. Timestamps more than 5 minutes off are refused. The URL verification challenge is answered after the signature check.
      • Slack retries up to 3 times when it gets no 2xx within 3 seconds; the claimed event_id drops the duplicates.
      • Verifying requests, Events API
    • Text, both ways:
      • Into Slack: the visitor's text is escaped (&, <, > only, as Slack documents), which makes <!channel>, <!here> and <@U…> inert. It goes with parse: 'none', mrkdwn: false and no link_names, and is cut at 4,000 characters (formatting).
      • Out of Slack: <url|label> becomes [label](url) and <url> becomes the URL. User, channel and special mentions become plain text. Slack's &amp;, &lt; and &gt; are decoded. The rest goes to the chat's Markdown sanitizer, at most 4,000 characters.
      • With names: true, the adapter reads the person's display name with users.info, which needs users:read, and caches it per instance.

    9. HubSpot and Zendesk: one-way tickets

    Both are plain onHandoff transports (ADR-0030 decision 5), written with fetch and no vendor SDK. Each throws on failure, so the handoff ends failed, or saved through onLead, within ADR-0030's ten seconds. The report carries the contact, the reason, the bot, the language and the content the bot allows (none, summary, transcript), in a plain-text description.

    HubSpot (checked 2026-12-04):

    • API: POST /crm/objects/2026-09/tickets (create a ticket; dated versions ship in March and September with 18 months of support).
      • Properties: subject, content, hs_pipeline and hs_pipeline_stage (internal IDs; the default pipeline when omitted), and hubspot_owner_id when owner is set.
      • The contact: upserted by email (POST /crm/objects/2026-09/contacts/batch/upsert with idProperty: 'email'), then associated inline with association type 16, ticket to contact.
    • Idempotency: HubSpot has no idempotency header.
      • The report's id goes in a ticket property created with hasUniqueValue: true (askdare_handoff_id), which doctor checks. A retry then fails as a duplicate, and the adapter treats that as success.
      • h4 verifies that unique values work on tickets and what the duplicate error looks like. If they don't, it searches by the property before creating.
    • Authentication: a service key (Bearer), which HubSpot recommends now that legacy private apps can't be created (since 2026-10-26 for existing accounts; existing private app tokens keep working, and the same adapter takes either) (sunset, service keys).
      • Scopes: tickets (or crm.objects.tickets.write), crm.objects.contacts.read and crm.objects.contacts.write.
    • Plans: the scopes are available on any account, the free CRM included. Rate limits: 100 requests per 10 seconds on Free and Starter.
    • Later: two-way chat through Custom Channels. Its scopes are listed for Sales or Service Hub Enterprise (the brief assumed Professional), and it needs an OAuth app.

    Zendesk (checked 2026-12-04):

    • API: POST /api/v2/tickets (tickets).

      • requester: { name, email } from the report's contact, which creates the user depending on the account's settings.
      • subject, a comment with the plain-text body, external_id (the report's id, for people to search), tags (default askdare, plus the reason), and group_id.
      • Without a contact, the ticket's requester is the authenticated agent, and the docs say so.
    • Idempotency: an Idempotency-Key header with the report's id. A repeat within 2 hours returns the first ticket (introduction), which covers ADR-0030's retries.

    • Authentication: OAuth client credentials, not an API token. Zendesk deprecated API tokens:

      • accounts created since 2026-07-28 can't use them;
      • new tokens are blocked since 2026-10-27;
      • all tokens stop working on 2027-04-30 (announcement).

      The adapter takes clientId and clientSecret of a confidential OAuth client with the tickets:write scope (and users:write if requesters must be created). It exchanges them for a token (default 30 minutes; no refresh token) and caches the token per instance until shortly before it expires (OAuth migration). Zendesk attributes the tickets to the agent who created the client, so the docs recommend a dedicated agent with a restricted role.

    • Plans: ticket creation through the API works on every plan, Support Team and Suite Team included. Rate limits: 200 requests a minute on Team plans.

    • Later: two-way chat through Sunshine Conversations, included from Suite Professional.

    10. Packages: one add-on per vendor

    @boldare/askdare-slack, @boldare/askdare-hubspot and @boldare/askdare-zendesk, like the other add-ons (-s3, -postgres, -upstash).

    • Each vendor's API changes on its own calendar (HubSpot's dated versions, Zendesk's token sunset, Slack's rate limits), and a fix ships for that vendor alone.
    • An app installs only the vendor it uses. Each is small, written with fetch and node:crypto, with no vendor SDK.
    • Each peers on @boldare/askdare and imports only its public API, so a gap in the port becomes a core change (h1), not a private import.
    • First releases by hand, per RELEASING.md.

    11. The admin console

    • The review (ADR-0032) shows a person's messages with their label and the live state lines, rebuilt from the notes as history is.
    • The dashboard's handoff counts don't change. A live handoff counts once as delivered (sent) when it reaches waiting. Live, ended and missed aren't counted apart: they would need a new record kind, and "handoff and lead records in the admin store" is already under Later.

    12. The threat model

    New rows in THREAT_MODEL.md (numbers continue from T45):

    • T46, forged inbound events (POST <basePath>/handoff/<name>). Defenses:

      • receive checks the vendor's signature (Slack: the signing secret's HMAC, constant-time) and timestamp window;
      • each event id is claimed once for 10 minutes;
      • the body is capped at 64 KB, and requests are rate-limited per IP;
      • the conversation is found only through ref, sealed with CHAT_SECRET under its own typ, so a reference can't be forged or pointed at another bot.

      What's left: anyone with the signing secret and a ref (any workspace member can read the request message's metadata) can write into that conversation as the team.

    • T47, a person's text reaching the visitor. It is rendered through the answers' Markdown sanitizer (no raw HTML, the link and image allowlists) and cut at 4,000 characters. Vendor markup is converted to plain Markdown first. What's left: a team member can send the visitor a link from the allowlist, as the bot's knowledge can.

    • T48, the visitor's text reaching the team's tool. Defenses:

      • mentions and markup are escaped (Slack: &, <, >; no link_names; parse: 'none');
      • live messages have their own per-visitor, per-IP and per-conversation limits, since each costs a person's attention;
      • nothing a visitor types goes into a vendor field other than the message text and the report's documented fields.

      What's left: visitor messages, contact details and the allowed content stay in Slack, HubSpot or Zendesk under that tool's retention. docs/privacy.md lists what each adapter sends, and the status line tells the visitor a person reads the chat.

    • T49, vendor credentials in the app's environment. The Slack bot token, Slack signing secret, HubSpot service key and Zendesk OAuth client are each read from the environment, use the fewest scopes, and appear in no log, error or report. Zendesk's tickets act as the client's agent, so the docs recommend a dedicated, restricted agent. What's left: a leaked Slack token can post wherever the bot is a member, a leaked HubSpot key can read and write contacts, and a leaked Zendesk client can create tickets.

    13. What stays out

    Typing indicators, files in live chat (either way), several people in one conversation, transferring between people, read receipts, a visitor's "End chat" button, push notifications to a closed tab, and business hours beyond available(). Two-way HubSpot and Zendesk are under Later (decision 9).

    14. Order of work in 0.9

    • h4 and h5 (HubSpot, Zendesk) need nothing from h1: onHandoff exists since 0.7. They start once this ADR is accepted, on release/0.9, in the Add-ons lane.
    • h1 (server) after r1a (bot/define-bot.ts, server/handler.ts) and e1 (protocol/*), with 0.8.x-p1 and p4 merged in.
    • h3 (Slack) after h1.
    • h2 (chat) after h1, b1 and r1b. It changes embed/host-events.ts after r1c.

    Consequences

    • New public API (ADR-0006, listed by z1):

      • handoff.live in defineBot;
      • liveChannel in createChatHandler;
      • LiveChannel, LiveEvent, LiveEndReason;
      • memoryLiveChannel in testing;
      • the four states;
      • author and name on history messages;
      • POST /live;
      • the new error code;
      • from on message.received;
      • the MessageAuthor primitive and its author part;
      • five texts;
      • three add-on packages.

      All are additive: minor changesets.

    • The first inbound endpoint. Until now every request came from the visitor's browser. The Slack route is called by Slack and authenticated only by its signature. /security-review runs on h1 and h3.

    • Polling costs requests: about 20 a minute per visitor while a person is asked or writing and the page is visible, each one store read. On OpenAI Conversations, those count against the project's request rate limit.

    • A person's reply can take up to 15 seconds to show after a quiet minute.

    • A live chat's messages stay in the conversation, so later model calls read them, at input cost.

    • Slack keeps what the visitor wrote under the workspace's retention, and workspace members can read the request message's encrypted metadata.

    • Zendesk needs OAuth from day one, since its API tokens end on 2027-04-30. HubSpot needs a service key for new setups.

    • The React budget's room goes to live chat, after b1 frees it. The next feature that grows the chat makes room again (ADR-0028).

    Alternatives considered

    • A held SSE stream for replies, within maxDuration, reconnecting. Push latency is better, but without pub/sub the server still reads the store in a loop, inside a function billed by duration. It needs reconnect and resume logic in the chat, which costs more bytes than a timer, and buffering proxies break it. Long-polling is the step to take if 3 seconds proves too slow.
    • Pub/sub through Upstash or Postgres LISTEN. It would make live chat need a shared store beyond the conversation store, and wouldn't remove the reconnect problem on serverless hosts.
    • A lazy live chat chunk. Measured larger on first load in every case (see "What the prototype measured").
    • A budget raise instead of b1. ADR-0028 decision 3 asks for room first, and 0.8-b1 showed 300 to 500 B can be found with the same behavior.
    • stopBot: false, where the bot keeps answering while a person is asked or writing. That makes two voices answering the same messages. The visitor who wants the bot back starts a new conversation, or waits for missed.
    • A person's message as a developer note or a user message. A note gives the person's text developer authority, and that text can quote anything. A user message puts it in the visitor's voice.
    • A new stored item kind for a person (role: 'person'). It changes the ConversationStore port and every store's schema, and OpenAI's items have no such role.
    • A mapping store (thread to conversation) instead of a sealed reference. It needs storage askdare doesn't have, and the OpenAI store can't index by thread.
    • Slack: a slash command or a keyword to end. Slash commands don't run in threads, and a keyword is typed by accident.
    • Slack: conversations.replies polling. It is rate-limited for non-Marketplace distributed apps, and events are cheaper anyway.
    • One @boldare/askdare-handoff package with subpaths. Its version would move for every vendor's change, and its dependencies would grow for all of them.
    • Plain text for a person's messages. It is safe, but needs a second rendering branch (bytes) and loses links. The Markdown sanitizer already handles untrusted text.
    • Zendesk API tokens (the brief's plan). They end on 2027-04-30, and new accounts can't create them at all.

    Settled with the maintainer (2026-12-04)

    Accepted with every recommendation under "Open questions". So:

    1. Replies reach the chat by polling POST /live.
    2. The bot is silent from waiting until the chat ends; there is no stopBot option.
    3. Four states, missed included, with waitMinutes: 10 and idleMinutes: 30 by default.
    4. A person's messages are assistant items after an [askdare:live] note, rendered as sanitized Markdown.
    5. b1 frees at least 350 B in the React entry and 200 B in the headless case; no lazy chunk; a raise only by its own ADR.
    6. message.received gains from: 'person', with the 5 B change to the loader's allowlist in h2.
    7. Slack ends a chat with a ✅ reaction; people's names are off by default.
    8. Zendesk uses OAuth client credentials, and HubSpot a service key.
    9. One package per vendor.
    10. The console shows the live state in the review; dashboard counts are unchanged.

    The maintainer also asked whether HubSpot and Zendesk can be tested for free. They can:

    • HubSpot with a free developer test account;
    • Zendesk with its 14-day trial, opened just before h5's smoke test.

    Open questions (settled above)

    Each had a recommendation, and the maintainer accepted them all.

    1. Replies by polling POST /live (decision 4). Recommended: polling every 3 s, backing off to 15 s, while visible. Alternative: a held SSE stream.
    2. The bot is silent from waiting until ended or missed, with no stopBot option (decision 2). Recommended: yes. Alternative: stopBot as the brief sketched, with the bot answering while waiting.
    3. Four states, missed included (decision 1), with defaults waitMinutes: 10 and idleMinutes: 30. Recommended: yes. Alternative: three states, with ended covering "nobody joined".
    4. A person's messages are assistant items after an [askdare:live] note, rendered as sanitized Markdown (decisions 3 and 7). Recommended: yes.
    5. The budget: b1 frees ≥350 B in the entry and ≥200 B headless; no lazy chunk; a raise only by its own ADR if b1 fails (decision 7). Recommended: yes.
    6. from: 'person' on message.received, with the 5 B loader allowlist change in h2 after r1c (decision 7). Recommended: yes. Alternative: no field, so the page can't tell a person's reply from the bot's answer.
    7. Slack: ending with a ✅ reaction on the request message, and people's names off by default (decision 8). Recommended: yes.
    8. Zendesk with OAuth client credentials, HubSpot with a service key (decision 9), against the briefs' API token and private app. Recommended: yes, forced by the vendors' sunsets.
    9. One package per vendor (decision 10). Recommended: yes.
    10. The console shows the live state in the review; dashboard counts unchanged (decision 11). Recommended: yes.