# Start here Choose a client, connect your inbox, and test the complete support loop. RespondKit adds in-app support to React, React Native, SwiftUI, and Android Compose apps. Customers talk in your app; your team replies from Discord. The merged implementation also supports email follow-up and file attachments. ## Choose your starting point | Your task | Read | | --------------------------------------------- | ---------------------------------------------- | | Connect a product for the first time | [Getting started](/docs-markdown/getting-started.md) | | Add support to a website | [React widget](/docs-markdown/react-widget.md) | | Add support to a React Native app | [React Native](/docs-markdown/react-native.md) | | Add support to an existing iOS or Android app | [SwiftUI and Android](/docs-markdown/native-clients.md) | | Recover a customer's history after login | [Identity and account changes](/docs-markdown/identity.md) | | Work through support requests | [Discord inbox](/docs-markdown/discord-inbox.md) | | Integrate using a coding agent | [Coding-agent guide](/docs-markdown/coding-agents.md) | ## What is available Customer sessions, conversation history, read receipts, local greetings, email capture, native device context, and attachments share one API. Email follows up on unread operator replies after a default ten-minute delay. Incoming email replies return to the same thread. Message translation is optional and operator-requested. **Check the release before installing.** Merging a feature does not publish its npm or Maven package, deploy its database migrations, or configure its email domain. [Release and rollout](/docs-markdown/rollout.md) explains the order and how to test it. External support runners can list threads, read transcripts, download attachments, and send replies through the inbox-scoped [Support agents](/docs-markdown/agent-api.md) API. ## One conversation, multiple channels 1. The client opens a session scoped to your product's inbox. 2. A customer message appears in that client's transcript and a Discord forum thread. 3. An operator uses `/reply`. Translation is optional. 4. The client displays the reply and acknowledges that transcript as read. 5. If the reply remains unread and email is configured, the scheduled sender emails it. A read acknowledgement cancels pending delivery. For text-only access to these same guides, use [the documentation index](/llms.txt), [the complete documentation](/llms-full.txt), or individual Markdown pages linked from the index. --- # Getting started Provision an inbox, choose a client, and send one test conversation. ## 1. Prepare one inbox per product An inbox controls the allowed client origins, Discord forum and operators, default locale, and optional email sender. Use separate staging and production inboxes. All platforms of the same product can share an inbox when you want verified account history across devices. Your integration needs three public values: the RespondKit API URL, the inbox ID, and an allowed product origin. Native apps supply the configured origin explicitly. The origin is a routing restriction; account access requires [verified identity](/docs-markdown/identity.md). The deployment owner provisions these values using the repository's [workspace configuration example](https://github.com/xanthous-tech/RespondKit/blob/main/apps/api/config/workspaces.example.json). Never put Discord, email, or identity-signing secrets into a client. ## 2. Check that the feature is released Use a published, compatible SDK version and deploy its API migrations first. For merged features that are not published yet, test a pinned repository revision or locally built package before releasing a host app. See [Release and rollout](/docs-markdown/rollout.md). ## 3. Add your client | Platform | Entry point | Guide | | ------------ | ------------------------------------------------ | ------------------------------------------- | | React web | `RespondKitWidget` | [React widget](/docs-markdown/react-widget.md) | | React Native | `createRespondKitStore` and `RespondKitScreen` | [React Native](/docs-markdown/react-native.md) | | iOS | `RespondKitStore` and SwiftUI `RespondKitScreen` | [SwiftUI and Android](/docs-markdown/native-clients.md) | | Android | `RespondKitStore` and Compose `RespondKitScreen` | [SwiftUI and Android](/docs-markdown/native-clients.md) | Mount the web widget or native store once near your app root. Keep it alive across navigation and while its chat screen is closed, so unread indicators continue working. Supply your authenticated user's ID and email when available. Add a backend-signed identity resolver before promising account history across browsers or devices. An anonymous customer can still chat; the UI asks for an email when one is missing. ## 4. Verify the support loop Send a message from a staging client. Find the matching Discord forum thread and send `/reply message:Hello from support`. Confirm the reply appears in the app and the read checkmark appears in Discord after viewing it. Then close chat while keeping the app foregrounded. Send another operator reply and confirm the unread indicator appears. Test logout and a second account before using real customer data. ## 5. Enable optional features Configure [email and attachments](/docs-markdown/email-and-files.md) after basic messaging and identity work. Choose a localized greeting in your host app. Built-in UI localization is a separate, planned capability; passing `context.locale` does not currently translate the SDK's controls. See [Localization](/docs-markdown/localization.md). --- # React widget Configure the embedded RespondKit customer experience. `RespondKitWidget` is the public React entrypoint. It owns session bootstrap, thread creation, message polling, optimistic sends, retry state, and the visible chat interface. ## Install and mount once Check [release availability](/docs-markdown/rollout.md), then install the selected `@respondkit/react` version. The host must process `@respondkit/react/styles.css` with Tailwind CSS v4. Keep one widget near the application root so navigation does not recreate its session. ```tsx import { RespondKitWidget } from "@respondkit/react"; import "@respondkit/react/styles.css"; ; ``` The host supplies `appLocale`; this is conversation context, not a switch for translated SDK controls. Add verified identity when the user signs in. ## Props | Prop | Type | Description | | --------------- | ----------------------- | ------------------------------------------------------------------- | | `apiBaseUrl` | `string` | RespondKit API origin. | | `context` | `RespondKitContext` | Product and customer context for this conversation. | | `title` | `string` | Header text shown in the open widget. | | `accentColor` | `RespondKitAccentColor` | Tailwind palette family used by the launcher and customer messages. | | `initiallyOpen` | `boolean` | Opens the widget on its first render. | | `fetch` | `typeof fetch` | Optional fetch implementation for hosts that need to supply one. | | `greeting` | `string` | Local first bubble for a fresh conversation; omitted from restored history and server messages. | | `getIdentityToken` | `() => Promise` | Fetch a fresh backend-signed account assertion. | | `identityPending` | `boolean` | Pause identity work while host authentication loads. | | `renderLauncher` | `(props) => ReactNode` | Render your own launcher using the supplied button props and unread state. | ## Accent colors The widget supports the standard Tailwind color families, including `lime`, `indigo`, `rose`, `slate`, and `neutral`. ```tsx ``` ## Customer identity Pass your stable internal ID whenever possible. Add `getIdentityToken`, an async callback fetching a short-lived HS256 assertion from your authenticated backend, to link anonymous conversations and recover account history across browsers. Pass `identityPending` while authentication is loading. Raw user IDs and PostHog IDs remain advisory and cannot grant history access. The widget preserves browser identity through login, rotates it on logout or account switching, and offers a conversation selector when account history contains multiple threads. `posthogSessionId` is accepted alongside `posthogDistinctId` for analytics correlation. See the repository’s [identity setup guide](https://github.com/xanthous-tech/RespondKit/blob/main/docs/architecture/customer-identity.md) for the JWT contract and rollout order. ## Email, attachments, and your own launcher The widget prompts for an email when the host/server has none. Customers can continue without supplying one. It accepts multiple files of any type after the R2 backend is configured; see [Email and files](/docs-markdown/email-and-files.md). Use `renderLauncher` to place support in your app navigation. Spread `buttonProps` onto the actual button, including its ref, and display `hasUnreadReplies`. Keep the widget mounted while its launcher is hidden. Do not programmatically click an internal DOM selector to open support. ```tsx renderLauncher={({ buttonProps, hasUnreadReplies }) => ( )} ``` --- # React Native Present native support UI from a shared TypeScript store. The React Native package renders React Native views and shares the RespondKit protocol with the other clients. Conversation state, API calls, drafts, and retries run in TypeScript. It does not embed the SwiftUI or Compose SDK. Small native modules provide system file/photo selection and device integration. ## Install and build Check [release availability](/docs-markdown/rollout.md) first. Once your selected version is published: ```sh pnpm add @respondkit/react-native react-native-device-info react-native-get-random-values react-native-safe-area-context cd ios && pod install ``` The package declares React Native 0.81+ and React 19.1+; the repository example is tested on React Native 0.87.1. Rebuild the native app after installing or upgrading native modules. Use an Expo development build if your host uses Expo; Expo Go does not contain the required modules. For a React Native CLI host, add `@babel/plugin-transform-export-namespace-from` to your dev dependencies and Babel plugins. The shared protocol uses Zod namespace exports. See the [example Babel configuration](https://github.com/xanthous-tech/RespondKit/blob/main/apps/native-example/babel.config.js). ## Create one store Create the store after your host authentication state has settled. `appStorage` below is your app's async `getItem`/`setItem` adapter; choose encrypted storage for production conversation data. The identity endpoint must return a JWT string from your authenticated backend. ```tsx import { createRespondKitStore, storagePersistence } from "@respondkit/react-native"; const store = await createRespondKitStore({ apiBaseUrl: "https://support-api.example.com", inboxId: "inbox_example_public", origin: "https://example.com", persistence: storagePersistence(appStorage, "respondkit:production:example"), context: { userId: user.id, email: user.email, locale: appLocale }, getIdentityToken: async () => { const response = await authenticatedFetch("/api/support-identity", { method: "POST" }); if (!response.ok) throw new Error("Could not verify support identity"); return response.json(); }, }); ``` Use [the identity contract](/docs-markdown/identity.md) for backend setup. Do not embed a signing secret in the app. Storage failures should be visible; silently creating a replacement store can lose retry state. ## Mount the lifecycle and screen ```tsx import { RespondKitLifecycle, RespondKitScreen } from "@respondkit/react-native"; import { SafeAreaProvider } from "react-native-safe-area-context"; function AppRoot() { return ( ); } function SupportScreen() { return ( navigation.goBack()} title="Support" greeting="Hi! How can we help?" /> ); } ``` `store`, `YourNavigator`, and `navigation` belong to your host app. Keep the lifecycle outside the conditionally mounted support screen. Use `useRespondKit(store).unreadThreadIds.size` for your own unread indicator. ## Account and app lifecycle On login, logout, or account switching, call `await store.updateIdentity(context, tokenProvider)` followed by `await store.refresh()`. Use the new account's resolver and include `nativeDeviceContext()` in replacement contexts unless supplying your own device metadata. The store hides the previous account's data before asynchronous work. Foreground polling runs every ten seconds by default and pauses in the background. The visible transcript sends read acknowledgements; background status polling does not. There is no push-notification registration or background message service. Dispose the store only when the host permanently releases it. ## Files and verification System photo/video and document pickers support multiple selections. Uploads use the configured R2 backend, with retry/remove controls and attachment links. The package adds no broad photo/storage permission. See [Email and files](/docs-markdown/email-and-files.md). The [native example](https://github.com/xanthous-tech/RespondKit/tree/main/apps/native-example) uses local simulated replies. Configure a real API/inbox and remove its injected transport to test uploads and live Discord/email delivery. Test both platforms, account changes, restart-safe retries, keyboard layout, and cancelled picker results before rollout. --- # SwiftUI and Android Keep native support stores alive across screens and account changes. ## Compatibility first | SDK | Current requirement | | --------------- | ------------------------------------------------------------------------------- | | SwiftUI | Swift 6, iOS 18+; `RespondKitCore` and `RespondKitUI` Swift Package products | | Android Compose | Android API 26+; `dev.respondkit:respondkit-compose` includes the core artifact | Check the host app's actual deployment target before integrating. For older OS versions, preserve an existing contact path or plan an explicit SDK compatibility change. Do not silently raise your app's minimum OS just to add support. Choose a released version using [Release and rollout](/docs-markdown/rollout.md). Add `https://github.com/xanthous-tech/RespondKit.git` in Xcode; Android consumers use Maven Central. The [native setup reference](https://github.com/xanthous-tech/RespondKit/blob/main/docs/native/README.md) covers configuration, encrypted persistence, and local examples. ## SwiftUI Create one `RespondKitStore` on the main actor, with the API URL, inbox, and allowed product origin. Keep it at app scope. Given that store: ```swift import SwiftUI import RespondKitCore import RespondKitUI struct SupportEntry: View { let store: RespondKitStore @State private var isPresented = false var body: some View { Button("Contact support") { isPresented = true } .respondKitLifecycle(store) .fullScreenCover(isPresented: $isPresented) { RespondKitScreen(store: store, greeting: "Hi! How can we help?") } } } ``` Mount `.respondKitLifecycle(store)` on a stable app root if `SupportEntry` itself comes and goes with navigation. Use `store.hasUnreadReplies` for your own badge. Keep the greeting in your host's localization catalog. ## Android Compose Own the store at app/activity scope with a main-dispatcher coroutine scope and `EncryptedFilePersistence`. Mount `RespondKitLifecycle(store)` outside the support destination. Given the store and your navigation controller: ```kotlin @Composable fun SupportDestination(store: RespondKitStore, onClose: () -> Unit) { RespondKitScreen( store = store, onClose = onClose, title = "Support", greeting = "Hi! How can we help?", ) } ``` Observe `store.state` with `collectAsStateWithLifecycle()` for unread indicators and UI state. The host owns navigation and badge placement. Cancel the owning coroutine scope when its owner is permanently disposed. ## Shared behavior Keep context aligned with authenticated account changes and use a backend identity token for cross-device history. Anonymous installations remain separate. Both SDKs preserve drafts and immutable send retries, acknowledge visible messages, expose conversation history, and collect model/OS diagnostics without a unique hardware identifier. Photos/videos and documents use system pickers, with no new broad library/storage permission. Completed files are uploaded to R2. A file picker cancellation must leave chat usable. See [Email and files](/docs-markdown/email-and-files.md). Built-in control text is currently English. Localized greetings and locale-aware timestamps are separate from complete UI localization; see the [localization proposal](/docs-markdown/localization.md). --- # Identity and account changes Recover account history without trusting client-supplied identifiers. ## Anonymous and verified customers An anonymous installation can create and resume its own conversations. To recover history across browsers, iOS, Android, and React Native, use the same product inbox and the same stable authenticated account subject on every platform. `userId`, email, PostHog IDs, and device fields supplied by the client are advisory. An email match does not link accounts. A backend-signed identity assertion grants access to the account's history. ## Backend contract Store a separate signing secret of at least 32 characters for each inbox in your product backend and RespondKit. On the Worker, use `IDENTITY_SIGNING_KEY_` or the `IDENTITY_SIGNING_KEYS` JSON secret map. These are private server secrets. Your authenticated endpoint returns an HS256 JWT string with header `{"alg":"HS256","typ":"JWT"}` and these claims: | Claim | Value | | ------------ | ----------------------------------------------------- | | `aud` | `respondkit` | | `inboxId` | Configured inbox ID | | `sub` | Stable user ID from the validated host session | | `email` | Optional email from that session | | `iat`, `exp` | Current issue time and expiry; lifetime 1–300 seconds | Use a fresh token for each resolver request and `Cache-Control: no-store`. Never accept a user ID from the identity endpoint's request body as proof of authentication. See the [complete backend example](https://github.com/xanthous-tech/RespondKit/blob/main/docs/architecture/customer-identity.md). ## Client behavior React hosts provide `getIdentityToken` and keep `identityPending` true while auth is loading. Native hosts keep one store and update its identity when the authenticated user changes. Raw IDs alone must not be used to promise shared history. Test anonymous → login, a second device → same login, logout → another account, token expiry, and failed token renewal. Previous account data must disappear on account changes. Preserve stable inbox IDs and existing visitor storage during an SDK upgrade. ## Contact email is separate The email prompt saves a contact address for follow-up. It does not authenticate the customer or merge account histories. If the host already knows the email, pass it in context. Customers can still chat without supplying one. --- # Discord inbox Use a Discord forum channel as the operator-side support inbox. RespondKit maps one customer conversation to one Discord forum post. Customer messages and sent replies appear in the thread, and operators have three commands when answering customers directly: `/reply`, **Translate to English**, and `/activity`. ## Required channel permissions The RespondKit bot needs permission to: - view the forum channel; - create posts; - send messages in posts; - read post history; - manage posts; - add reactions; - use application commands; - attach files for long private translation previews and activity timelines. ## Customer read receipts A bot-owned ✅ on a "Reply sent" message means the customer displayed that reply in an open, visible chat. Sending a reply, polling unread counts, or keeping the chat closed does not mark it read. Each reply keeps its own checkmark once read; a newer reply stays unchecked until it is displayed. This requires the React SDK 0.4.1 or later and the bot's Add Reactions and Read Message History permissions. The widget sends an authenticated transcript cursor to the API and retries failed receipts. The API persists that cursor before adding the reaction. A once-per-minute sweep recovers Discord failures and receipts that arrive before the bot's reply is posted. A delayed checkmark does not require resending the reply. ## Reply to a customer Run `/reply` inside the relevant support thread: ```text /reply message:Please reopen the app and try the export again. ``` The customer receives the exact text you entered. Translation is optional: ```text /reply message:Please reopen the app. translate:customer /reply message:Please reopen the app. translate:hi ``` `customer` uses the language you last named for the thread, or else a reliably detected one; translating a newer customer message never replaces an operator-named language. If it is unknown, translate an incoming message first or supply a language name or code (`Burmese`, `简体中文`, `my`). Browser locale is not treated as proof of the customer's language. A requested translation must succeed before the reply becomes available to the customer. If it needs review, RespondKit shows a private preview with a **Send this translation** button, and nothing is sent until you confirm. When delivery finishes or fails, the private message updates to say whether the reply was sent or not sent. If a reply was not sent, run `/reply` again; the customer receives it once. ## Translate an incoming message Right-click or long-press a customer message and choose **Apps → Translate to English**. A translation appears as a reply to its original message. Repeated requests reuse the saved result. Translation failures are private and do not mark the original message as failed. Translation must be enabled for the inbox using `TRANSLATION_ENABLED_INBOXES`, with a working Gemini credential. Enable the commands for your operator role under **Server Settings → Integrations → RespondKit**. No additional Discord OAuth scope or Message Content intent is needed. ## Customer activity When PostHog is configured for the inbox, `/activity` posts the customer's latest 20 pageviews and product events in the Discord thread. Use `count:50`, `minutes:30`, `kind:pageviews`, or `until:last_message` to narrow the snapshot. Supplying minutes without count allows up to 100 events. Long timelines include a text attachment. Activity stays in Discord and is not sent to the customer. PostHog failures do not affect replies. The bot needs Attach Files permission for long timelines; hosts already supplying a PostHog distinct ID need no client update. --- # Email and files Enable unread email follow-up and private R2 attachments. ## Email after an unread reply The inbox's configuration defines the sender. The default delay is 600 seconds. The scheduled Worker runs each minute, so normal delivery occurs roughly ten to eleven minutes after publication; backlog or outages can delay it further. ```json { "email": { "from": "support@example.com", "name": "Example Support", "replyDomain": "reply.example.com", "unreadDelaySeconds": 600, "operator": { "forwardTo": "support-team@example.net", "allowedReplyFrom": ["owner@example.net"] } } } ``` Apply the workspace configuration, configure the `EMAIL` binding and verified sending domain, route incoming replies to the Worker, set `PUBLIC_API_URL` to the API origin, configure the private `ATTACHMENTS` R2 bucket, and apply migrations through `0008_operator_email.sql`. The legacy Email Routing binding restricted to verified destination addresses is insufficient for arbitrary customer recipients. Follow the [Cloudflare email setup](https://github.com/xanthous-tech/RespondKit/blob/main/docs/integrations/cloudflare-email.md). A client's read acknowledgement cancels pending email. Dispatch rechecks read state and recipient before provider handoff. Mail already accepted by the provider cannot be recalled. Multiple overdue messages can share one email; newer replies retain their deadlines. Customer replies, including HTML-only emails and attachments, enter the existing thread. Chat shows a plain-text preview and file links. Discord also receives download links to the original `.eml` and decoded `.html`; there is no Markdown conversion or link-service-specific parser. Long emails keep their complete original in R2 and show a bounded preview. Closed-thread and automated replies are rejected. An uncertain provider send is held for investigation rather than automatically resent. ## Reply from your operator mailbox The optional `operator` settings send each new customer message to `forwardTo`, normally on the next minute's scheduled run. Operator notifications have no ten-minute delay and do not depend on Discord delivery. Existing messages are not backfilled when you enable this. Reply to the notification from an address in `allowedReplyFrom`. The notification's private `operator+` Reply-To selects the existing thread. Your reply appears in all customer clients as written, with its files. Customers with no email still receive it in-app. Customers who supplied an email get the normal delayed follow-up if they have not read it. Use your actual sending mailbox in `allowedReplyFrom`, even if `forwardTo` is an alias forwarding to Gmail. Both envelope and From header must match that address. The sender, operator destination, and reply domain are independent settings; no `chat@` address is assumed. Remove `operator` to disable mailbox notifications and operator replies. Original HTML is preserved when forwarding customer mail to the operator. Oversized HTML falls back to a preview and full-original download links; files are always linked from private R2. Inline-image parts remain downloadable and intact in the original `.eml`. Customer follow-ups use the customer-visible text and file links; operator-only archives and reply addresses are kept out of that transcript. Treat reply addresses and file links as confidential capabilities. ## Files from every client Configure a private R2 bucket as `ATTACHMENTS` and apply migration `0007_attachments.sql` before enabling updated clients. [Attachment deployment details](https://github.com/xanthous-tech/RespondKit/blob/main/docs/integrations/attachments.md) cover storage and endpoint behavior. | Client | Selection | | ------------ | --------------------------------------------- | | Web | Multiple files, all types | | SwiftUI | System photo/video picker and file importer | | Compose | System photo/video picker and document picker | | React Native | Bundled iOS/Android system picker modules | Native clients add no broad photo-library/storage permission and do not request camera access. File-only messages are supported. The customer can retry failed uploads or remove files before sending. There is no product size cap or configured completed-object expiration; Cloudflare's platform request and multipart limits still apply. Downloads use non-expiring capability links. Anyone with a link can download its file, so keep links in the intended support conversation. Removing a completed upload from a draft does not delete it from R2. ## Test before enabling broadly Use a mailbox and files you control. Verify unread email delivery, read-before-deadline cancellation, an email reply returning to chat/Discord, multiple-file upload, interrupted retry, and file downloads from both customer history and Discord. Test account switching while a system picker is open. --- # Release and rollout Ship the backend first, then move one app at a time. ## Merged code and published packages The documentation describes the merged SDKs. A release must also publish npm packages and Android artifacts, create a Swift tag, apply migrations, and configure the target backend. Check each channel independently before changing a host app. At the 2026-10-04 audit, `@respondkit/react` and the latest GitHub release were 0.5.3, predating the merged email/native/attachment stack. `@respondkit/react-native` was not available in the public npm registry. Do not assume installing 0.5.3 includes those changes. Version 0.6.0 is now prepared in the repository; it must pass publication and registry verification before apps install it. Recheck the [releases](https://github.com/xanthous-tech/RespondKit/releases) and registry at integration time. ```sh # Run outside a repository that forbids npm commands through devEngines. npm view @respondkit/react version npm view @respondkit/react-native version ``` Use a new, coordinated release version; do not overwrite an existing tag or package version. A pinned source revision or locally packed artifact is appropriate for a staging integration before publication. The [release guide](https://github.com/xanthous-tech/RespondKit/blob/main/docs/native/releases.md) covers signing and publication. ## Deploy the backend first Apply all migrations for the selected release. Configure the product inbox, allowed origins, Discord operator access, identity signing keys, optional sender/reply domain, and private R2 binding. Confirm the scheduled trigger is enabled. Complete a real staging message/reply/read/email/file loop before switching customers. ## Roll out in waves 1. Upgrade one existing web integration. Keep its inbox and visitor keys stable; test identity and the existing support entry point. 2. Reuse that pattern for other web products and new web apps, with separate product inboxes. 3. Pilot React Native in an internal development build on iOS and Android. 4. Roll out established native apps after checking minimum OS versions and doing TestFlight/internal Android testing. Use an app-controlled feature flag or staged release. Keep the previous contact route available while the new client is disabled. Do not run two active support widgets with competing launchers on the same screen. ## A product is ready when Messaging, signed account history, logout isolation, read cancellation, contact capture, attachments, and the real operator workflow have each been exercised. Check both email-present and no-email customers. Test an interrupted request and an app restart. Record whether tests used simulated replies or the real deployment. Monitor failed sends, identity failures, attachment failures, mail outcomes, and support response time with the deployment's logs and your existing observability. Do not describe unimplemented dashboards or metrics as available. ## Roll back without losing access Disable the new entry point with the host feature flag and restore the previous contact path. Preserve visitor IDs, drafts, uploaded objects, and additive database migrations. Once visitors have been linked to verified accounts, do not downgrade to an anonymous-only SDK: it cannot access linked history. Native distribution still follows store-release timelines. --- # Coding-agent guide A bounded integration workflow with source references and acceptance checks. Use this guide when a coding agent installs or upgrades RespondKit in a host app. For an AI agent that handles customer requests, read [Support agents](/docs-markdown/agent-api.md). ## Read in this order 1. [Release and rollout](/docs-markdown/rollout.md): identify a published version or pinned test revision. 2. The platform guide: [React](/docs-markdown/react-widget.md), [React Native](/docs-markdown/react-native.md), or [SwiftUI and Android](/docs-markdown/native-clients.md). 3. [Identity](/docs-markdown/identity.md): use the host's real authentication session. 4. [Email and files](/docs-markdown/email-and-files.md): check backend capabilities before exposing uploads. Machine-readable copies are generated from the same documentation source at `/llms.txt`, `/llms-full.txt`, and `/docs-markdown/.md`. They do not require client-side JavaScript or a separate hand-maintained knowledge base. ## Inspect before editing Locate the host's app root, auth/session provider, navigation, existing support entry point, locale source, and persistence adapter. Check for an existing integration before adding another store or widget. Confirm the target deployment's inbox and origin with its configuration; do not invent production values. Read the repository's instructions. Make an integration branch and keep the host's current support route available during rollout. ## Integration contract - Keep one store/widget per active product scope. A screen presentation must not create a new visitor on every open. - Raw `userId`, email, metadata, device details, and analytics IDs are context. Only a backend-signed assertion authorizes shared account history. - Keep private credentials on the backend. Fetch a fresh short-lived identity assertion through the host's authenticated endpoint; return errors to the UI rather than falling back to another account. - Clear visible account data when identity changes. Use the SDK's identity lifecycle rather than rewriting its persisted state. - Preserve immutable client message IDs on retries. Do not create a second message after an uncertain response. Do not invent an agent token, job endpoint, translation prop, or package version. The [protocol schemas](https://github.com/xanthous-tech/RespondKit/tree/main/packages/protocol/src), [React props](https://github.com/xanthous-tech/RespondKit/blob/main/packages/react/src/widget/respondkit-widget.tsx), and [React Native exports](https://github.com/xanthous-tech/RespondKit/blob/main/packages/react-native/src/index.ts) are the source references. ## Acceptance checks | Flow | Expected result | | ------------------------------------------- | ------------------------------------------------------------------------- | | Anonymous chat, then login | Existing conversation remains; verified account history becomes available | | Restart or reload after a send timeout | Same pending message retries without duplication | | Logout, then sign in as a different user | Previous user's history is hidden | | Reply while chat is closed | Unread indication appears; foreground polling alone does not mark it read | | Display the reply | Read acknowledgement reaches the API and cancels pending email | | Pick multiple files and interrupt an upload | Retry works; account changes discard late picker/upload results | Also test no-email, declined/cancelled picker, closed-thread, and offline states. Report what was tested locally, what reached a real staging service, and what still needs a device test. Include version, migration requirements, and rollback route in the PR description. --- # Support agents Inbox-scoped HTTP API for listing threads, reading transcripts, downloading attachments, and sending replies. ## Agent API v1 The `/v1/agent` API gives one external support runner per inbox four routes to read customer conversations and send replies. It uses the same `MessageWorkflow` as human replies: customer publication, optional translation, read receipts, delayed reply email, and Discord copies of sent replies. Policy rules such as when to reply, working hours, concurrency, and human review live in your runner, not in RespondKit. A running server needs migrations through `0012_simplify_agent_api.sql` and a configured agent credential before these routes are usable. ## Credentials and identity Provision a random bearer token with at least 32 random bytes. Store its lowercase SHA-256 hex digest in the Worker secret `AGENT_TOKEN_`, and give the raw token only to the runner host. The server hashes the presented token and compares fixed-length digests in constant time. Do not use a customer session token, and never reuse one token across inboxes. Optionally set `AGENT_NAME_` to a display name of 1 to 80 letters, digits, spaces, periods, underscores, or hyphens. It defaults to the inbox ID. Sent replies retain `authorKind: "agent"` and this name, and their Discord thread copy starts with **Agent <name>**. Rotate or revoke access by replacing or removing the secret. Every route requires: ```http Authorization: Bearer ``` Agent routes do not require an `Origin` header and do not grant browser CORS access. Responses carry `Cache-Control: no-store`. The rate limit is 120 authenticated requests per token per UTC minute. HTTP `429` means wait until the next minute. Threads from other inboxes return `404`. ## Routes | Method | Route | Request / behavior | | ------ | ------------------------------------------------- | -------------------------------------------------------------------------------- | | GET | `/v1/agent/threads` | Optional `state=open\|closed`, `cursor`, `limit` (1 to 100, default 50) | | GET | `/v1/agent/threads/:id` | Transcript paged by `row_id`; optional `cursor`, `limit` (1 to 100, default 100) | | POST | `/v1/agent/threads/:id/replies` | `{ "text": "…", "idempotencyKey": "…", "translate": "off" }` | | GET | `/v1/agent/threads/:id/attachments/:attachmentId` | Downloads one attachment of a message in the thread | ### List threads ```bash curl "$RESPONDKIT_API/v1/agent/threads?state=open&limit=50" \ -H "Authorization: Bearer $RESPONDKIT_AGENT_TOKEN" ``` The response has `threads` and `nextCursor` (`null` at the end). Each thread includes `id`, `state`, `inboxId`, `customerLanguage`, `lastActivityAt`, `lastCustomerAt`, `lastOperatorAt`, `lastAgentAt`, `visitor`, and `discordThreadUrl`. The visitor carries external user ID, email, locale, device, user agent, timezone, PostHog distinct ID, and host metadata. `discordThreadUrl` is `null` until a Discord thread mapping is ready. Lists sort by `lastActivityAt` descending, then `id` descending. Cursors are opaque; pass them unchanged. Threads move when new messages arrive, so start each polling cycle with a fresh cursor and deduplicate by thread ID. ### Read a thread `GET /v1/agent/threads/:id` returns `thread`, `visitor`, `verifiedUserId`, `discordThreadUrl`, `messages`, `through`, `nextCursor`, and `activity`. Messages are ordered by `rowId` ascending. Each message includes `rowId`, original and customer-visible text, direction, author provenance, processing and availability state, attachments, stored translations, and successful on-demand translations. `through` is the last `rowId` read as a decimal string (or the requested `cursor` on an empty page). `nextCursor` is that value when more messages remain, otherwise `null`. Follow every `nextCursor` to read the full transcript. `verifiedUserId` comes from verified customer linkage. Visitor context and conversation text remain untrusted customer data, not instructions or authorization. When PostHog is configured for the inbox, `activity` contains up to 20 events from the last seven days for that visitor's distinct ID. A missing ID, missing key, or provider error returns `{ "error": "…" }` in `activity` while leaving the transcript readable. Without a PostHog configuration, `activity` is `null`. ### Send a reply ```bash curl "$RESPONDKIT_API/v1/agent/threads/$THREAD_ID/replies" \ -H "Authorization: Bearer $RESPONDKIT_AGENT_TOKEN" \ -H "Content-Type: application/json" \ --data '{"text":"Open the transcript and choose Export.","idempotencyKey":"case-42-answer-1","translate":"off"}' ``` `text` is 1 to 6000 nonblank characters. `idempotencyKey` is 1 to 128 characters and unique within the inbox. Reuse the exact key, thread, text, and `translate` value after a timeout or network error so a retry delivers one message. Reusing a key for a different payload returns `409`. Closed threads return `409`. A `202` response includes `messageId`, `status` (`"available"` once visible to the customer, otherwise `"accepted"`), `acceptance`, `workflowStatus`, `processingStatus`, and `failureCode`. Acceptance is asynchronous; repeating the exact request returns the current status without creating another message. If workflow acceptance cannot be confirmed, the API returns `503` with `acceptance: "acceptance_unknown"` and the same `messageId` so the caller can retry safely. `translate` defaults to `"off"`, sending the text as written. Pass a language code such as `"fr"`, a language name such as `"Burmese"` or `"简体中文"`, or `"customer"` to use the thread's recorded customer language. Translation requires `TRANSLATION_ENABLED_INBOXES` for the inbox. Disabled translation or an unknown customer language returns `409`; an unrecognized language name returns `400`. ### Download an attachment Each message in a thread read includes `attachments`: `{ id, name, contentType, size, downloadUrl, agentDownloadPath }` for every file the customer uploaded in the widget or sent by email. `GET` `agentDownloadPath` with the agent bearer token to download the bytes. RespondKit serves only ready attachments belonging to a message in that thread and inbox, always as `application/octet-stream` with `Content-Disposition: attachment` and the original MIME type in `X-Attachment-Content-Type`. Treat customer files as untrusted data. ## Product knowledge Keep product manuals, policy rules, and diagnostic tools in your runner host. The bearer token only scopes access to one inbox; it does not grant billing, database, or deployment permissions. For agents installing customer SDKs, see the [coding-agent guide](/docs-markdown/coding-agents.md). --- # Localization Shared Paraglide JSON with build-time Apple and Android resource generation. ## Current behavior RespondKit now has separate iOS and Android resource compiler packages, a shared validator, and an English source catalog. They generate native resource files from a small subset of Paraglide's inlang JSON format. The packages are private workspace tools, not published npm packages. SDK views still use their existing English strings. The generated resources are not yet wired into SDK bundles, and `context.locale` still supplies conversation context rather than selecting translated UI controls. Do not add a `messages` prop or assume a UI locale option exists before the client integration is released. Keep SDK controls, host-owned titles/greetings, and customer conversation text separate. Operator-requested conversation translation remains a backend feature. ## One source, native outputs | Client | Build output | | ---------------------- | ---------------------------------------------------------------------------------------- | | React and React Native | The same JSON can feed Paraglide's JavaScript compiler; SDK integration is still pending | | SwiftUI | `RespondKit.xcstrings` from `@respondkit/paraglide-ios` | | Android Compose | `strings.xml` and `` from `@respondkit/paraglide-android` | Edit `localization/messages/en.json` and reviewed translations in `messages/{locale}.json`. Register release locales in `localization/project.inlang/settings.json`. Generate and check the resources from the repository root: ```sh pnpm localization:generate pnpm localization:check ``` Commit `localization/generated` with its source changes. CI rejects stale resources. Installed mobile clients receive translation updates with a new SDK/app release; there is no runtime synchronization service. ## Supported Paraglide subset Use flat, stable `lower_snake_case` message IDs. RespondKit prefixes them with `respondkit_`. | Feature | Rule | | ---------- | -------------------------------------------------------------------------------------- | | Plain text | Unicode text, punctuation, quotes, percent signs, and newlines | | Parameters | `{name}` string parameters; translations may reorder or repeat them | | Plurals | One nonnegative integer count, one cardinal `plural` declaration, and category matches | | Fallback | Supply every category for the locale or an explicit final wildcard match | | Locales | Language with optional script and region; preserve `zh-Hans` versus `zh-Hant` | ```json { "respondkit_remove_file": "Remove {name}", "respondkit_show_new": [ { "declarations": ["input count", "local category = count: plural"], "selectors": ["category"], "match": { "category=one": "Show {count} new message", "category=*": "Show {count} new messages" } } ] } ``` Use string arguments for already formatted dates or numbers. Native parameter positions follow alphabetical argument names, regardless of sentence order. A plural can interpolate only its count; use integers from 0 through 2,147,483,647 for compatibility with Android's quantity APIs. Do not use nested JSON, ICU syntax, markup, literal braces, backslash escapes, custom formatters, date/number annotations, decimal or ordinal plurals, exact-number matches, gender/platform selectors, or multiple plural inputs. The compilers fail on unsupported features. The inspected UI needs none of these features. ## How plural generation works The validator gets a locale's categories from `Intl.PluralRules`, then copies the corresponding translated pattern into Apple plural variations and Android quantity resources. An explicit wildcard supplies omitted categories. `Intl` identifies categories; it does not translate words or create translations. The device selects the form for the actual count at runtime. The grammatical category `zero` is not a condition for exactly zero in every language. Use a separate key and a client condition for a special empty state. OS and Node ICU versions can differ, so this is not a promise of identical formatting on every OS release. Compatibility tests use Paraglide JS 2.20.2 and message-format 4.3.0 across English, Arabic, Russian, Polish, French, and Traditional Chinese. [Paraglide variants](https://github.com/opral/paraglide-js/blob/main/docs/variants.md), [Android plural rules](https://developer.android.com/guide/topics/resources/string-resource#Plurals). ## Client integration remains the next step Swift needs resource processing, the SDK's resource bundle, and localized lookups. Android needs generated resources installed in its library and `stringResource`/`pluralStringResource` calls. React and React Native need Paraglide message calls and SDK-owned locale handling; RN also needs Metro/Hermes validation. [Apple string catalogs](https://developer.apple.com/documentation/xcode/localizing-and-varying-text-with-a-string-catalog), [Paraglide locale strategies](https://paraglidejs.com/strategy). The host language should take precedence over device preferences with a documented English fallback. Host greetings remain host-localized. OS-owned pickers follow system localization. Backend diagnostic errors need a separate stable-error-code mapping before advertising complete UI localization. For compiler APIs, native call examples, exact restrictions, and the inspected string inventory, see the repository's [localization guide](https://github.com/xanthous-tech/RespondKit/blob/main/localization/README.md).