# How the Guided intake demo works

This demo shows scripts: a conversation that follows fixed phases and moves on only when a gate passes. Watch the strip above the claim page and the phase rail on its left. When the page sees a gate pass, the strip lights with the gate that passed, and the rail prints it and lights the next phase.

Harbour Insurance is a fictional insurer, and this page is where a customer starts a home claim. The agent's configuration lives in Mindset: five prompt fields, one function and a script, all defined in `demos/guided-intake` and applied to the org through the admin MCP. The model is `claude-haiku-4-5`.

## The script runs the conversation

A claim has an order that matters, so a script holds it. It has six phases: welcome and triage, emergency help, incident details, damage and evidence, cover check, and summary. Each phase says what happens on entry, what the model should do, what it may use, and what it collects.

- **On entry**, a phase runs fixed steps before the model says anything. The welcome shows three capability cards. Later phases ask their first question and offer suggested replies: the cost bands, the contact options, and Submit my claim at the end.
- **Collects** are named values, such as `incident_type`, `incident_date`, `rooms_affected` and `cost_band`. The model records them with `record_script_data`, and the platform checks each one against the script's declared schema.
- **Gates** decide when a phase moves on. Most are plain conditions, for example "`incident_date`, `rooms_affected` and `description` are collected". The triage gate has a second kind too: when the urgency is recorded as an emergency, a model judges whether the visitor really needs help right now. If it says yes, the claim goes through the emergency phase first. The cheap conditions are checked first, so a claim that isn't an emergency never waits for the judge.
- **Narrowing** keeps each phase to its own tools. The incident and damage phases offer nothing but recording what the visitor says; only triage and the cover check may call the cover function.

The model never moves the claim itself. It records what it heard, and the platform's gates decide.

## The cover check

`guided-intake-check-cover` is a function: literal sample policy rules (water damage, storm, flood, fire, theft and the rest, each with an excess and a limit) followed by pure steps that find the rule, apply the cost band and write one line of outcome. The cover phase calls it on entry, so the check always happens, and the agent can also call it to answer a question about cover.

## The page

No run event names a script phase. But inside `<mindset-agent>`, `record_script_data` runs in the browser, and its result carries the script run as the platform stored it: the collected data, the current phase and any judge's verdict. The page reads those events to fill in the claim file and move the step indicator. The claim file is the form: its fields fill in as the agent records each answer, the emergency verdict and the cover outcome join it when they arrive, and once it is complete its **Submit claim** button sends "Submit my claim" to the agent. The visitor never fills in a form themselves; they answer one question at a time. The emergency step appears on the indicator only when the claim goes through it. The page then applies the script's own condition gates, read from the same JSON, to show where the claim goes next.

**View script** opens the script as a readable document: every phase with its entry steps, what it collects, what it may use, and its gate, written as sentences. It is generated from the same file that was applied to the agent, so it can't drift from what runs.

One page tool, `lodge_demo_claim`, marks the claim as lodged and returns a demo reference. It refuses while the claim file is incomplete. Situational awareness tells the agent whether the claim is lodged. Nothing is sent anywhere.

## Under the hood

The pane lists every call: `record_script_data` as each value lands, the cover function, and the page tool.

## Build the same thing

Write the script with [Write a script](https://docs.mindset.ai/docs/write-a-script), the cover check with [Build a function](https://docs.mindset.ai/docs/build-a-function), and pin behavior tests with [Test an agent's behavior](https://docs.mindset.ai/docs/test-an-agents-behavior). Embed it with [the `<mindset-agent>` element](https://docs.mindset.ai/docs/the-mindset-agent-element).
