Digital agent scripts: branching step graphs
An agent script is a small, directed step graph the agent console walks during a live digital conversation — chat, email, or messaging. The console opens on the script’s start step, shows the agent what to say or do, and follows whichever branch option matches the customer’s answer. The agent never has to remember the flow; the next question is always on screen. Set that against the two tools your agents already have:- Macros are static: a prewritten reply, inserted as-is. Nothing reacts to what the customer said.
- AI reply suggestions are generative: a drafted reply, not a process — the AI has no idea which question must come after the answer.
Where it lives
Open Inbox → Settings → Agent scripts. The page is restricted to owners and admins — writes to the API require an owner or admin key too. Reads are open to every teammate, so the agent console can fetch the graph while a conversation is live. The settings tiles on Inbox → Settings sit next to Macros and Routing; Agent scripts is the tile with the branching icon.The API surface
Five endpoints, all under the/api/v1/inbox base path:
Scripts are stored per workspace as a JSONB array on your organization settings — there is nothing to provision and no table to migrate; a saved script is readable by the console immediately. The wire shape is snake case (
step_id, next_step_id, start_step_id); the sections below build that shape by hand.
Author your first script
You author three things:- Steps. Each step has a
step_id, akind(prompt,question,note, ordisposition), an optionaltitle, and abody— what the agent reads, asks, or does. - Branch options. On any step, an
optionsarray — each option is alabel(the answer the agent picks) and anext_step_id(the step it advances to). Anullnext step ends the flow. - A start step.
start_step_idpicks where the console opens; omit it and the flow starts at the first step.
Worked example — a three-branch refund intake
The agent asks for the customer’s name, then the order ID, then routes to ship-back, replacement, or a fallback. Rendered tree:step_id unique, every next_step_id resolving to a real step, and start_step_id resolving too. A broken graph returns 422 INVALID_SCRIPT_GRAPH with the reason and persists nothing.
Read it back while a conversation is live
After you save — from the dashboard editor or the POST above — the script is immediately readable:- Save the script with Active on (the
enabledflag). - Open any live conversation on a channel the script targets (or any channel, if you left
channelsempty). - Open the script panel in the agent console and pick the script from the picker.
question step, and an explicit end on a disposition step. Because reads are open to every teammate, an agent never needs admin rights to follow a script — only to change one.
Patch the same script — rename a step label here — and the console sees it as a new version. PATCH replaces the steps array wholesale, so resend the whole graph on every edit (GET it first if you need the current shape):
version — every PATCH increments it, so the console can tell an agent mid-flow that the script changed and reload it.
Delete a script the same way:
Version and replace semantics
- Every save bumps
version(create starts at 1). PATCHreplacesstepsin full: there is no per-step edit. The supported flow is offline-edit-then-save — GET the script, edit the JSON locally, PATCH the whole graph back.- If a replaced graph keeps the old start step, it survives; otherwise the start falls back to the first step.
- The graph is validated on the patched result, so you can never save a branch that dangles after a steps-only or start-only patch.
The voice parity note
Digital agent scripts are the messaging-side counterpart to the voice queue scripts you already configure on a voice queue — the same idea (a scripted decision path the console walks during a live interaction), applied to chat, email, and messaging instead of a phone call. If your operation scripts calls today, model your digital flows the same way; the step kinds (prompt / question / note / disposition) deliberately mirror the voice script sections.
Invariants — what a script never does
A script is display-only guidance. It never terminates a delivery by itself: no message leaves for the customer until the agent sends it, no call is placed, no routing is triggered. The console renders the graph; the human walks it. Treat scripts as inert, auditable guidance buildable and reviewable entirely inside your workspace — every create, update, and delete lands in your audit log with the acting user.Rollout checklist
- Draft inactive. Create the script with
enabled: false(or Active off in the editor) while you build it. - Trace every branch. Walk each path from the start step to a
dispositionstep; confirm no branch dead-ends and every question has an explicit fallback option. - Dry-run one live conversation. Have a supervisor follow the script on a real thread while it is still inactive, and fix wording before publishing.
- Publish. Set
enabled: true; confirm the PATCH response’s bumpedversion. - Audit the change. Check the audit log entry for the create/update with the acting user.
- Retire by disabling. Turn a script inactive instead of deleting it; deletes are permanent.
See also
- Agent scripts reference — the stored shape, graph rules, and the full field tables.
- Inbox settings map — every tile on the Inbox → Settings hub and what it controls.
- Macros and canned responses — the static-reply tool scripts complement.
- Inbox AI co-pilot — the generative counterpart — drafts, not decision paths.