Guide users through comparing electricity rates and finding a better deal.
Start this flow when a user wants to compare tariffs, find a better electricity deal, check rates, upload their electricity bill, save on their bill (ahorrar en la factura), switch provider (cambiar de compañía/comercializadora), contract a new tariff (contratar una tarifa), change contract holder (cambio de titular), move to a new home (mudanza), review their bill (revisar factura), or compare with the CNMC comparator.
IMPORTANT: Show the upload widget FIRST. Do NOT ask for personal info before showing the upload widget.
IMPORTANT: When calling this tool with action "start", ALWAYS include these fields in stateUpdates — they are derived from the user's message and count as explicitly stated values:
- 'locale': extract from the language the user writes in — 'es' for Spanish, 'en' otherwise
- 'is_manual_flow': always set to false unless the user explicitly says they don't want to upload
- 'transferAllowed': extract from the user's intent. Set to true if the user is talking about changing the contract holder, transferring supply ownership, moving to a new home, or relocating. Set to false otherwise.
## FLOW EXECUTION PROTOCOL
This tool implements a multi-step conversational flow. Follow this protocol exactly:
1. Call with `action: "start"` to begin and include `intent`.
`intent` must be a brief summary of the user's goal for this flow.
Do NOT invent missing intent.
Optionally include `context` — the situation or environment that led the user to start
this flow (e.g. what page they are on, what they were doing, or what triggered the request).
Only provide `context` when there is genuinely relevant situational information. Do NOT invent missing context.
If the user's message already contains answers to likely questions,
extract them into `stateUpdates` as `{ field: value }` pairs.
The engine will auto-skip steps whose fields are already filled.
Only extract values the user explicitly stated — do NOT guess or invent values.
Known fields: `locale` ("es" | "en" — UI language for widgets and conversation — 'es' if user writes in Spanish, 'en' otherwise. Always pre-fill this from conversation language.), `is_manual_flow` (Whether the user chose the manual path (entering details instead of uploading a bill). Set to true only when the user explicitly clicks the manual flow button or says they do not want to upload their invoice.), `transferAllowed` (Extract from the user's intent — set to true if the user is changing the contract holder, transferring supply ownership, moving to a new home, or relocating. Set to false otherwise. Always include in stateUpdates on start.), `firstName` (User's first name), `lastName` (User's last name), `email` (User's email address), `phone` (User's phone number), `people` ("one_or_two" | "three_or_four" | "more_than_four" — Number of people in the household), `boilerType` ("gasHeating" | "electricHeating" | "noHeating" — Type of heating: gas, electric, or none), `homeConsumption` (Last electricity bill amount in euros), `postalCode` (Postal code of the supply point), `comparisonResult` (Rate comparison API response (populated automatically)), `uploadPending` (Whether a bill upload is currently being processed in the background.), `uploadStartedAt` (Timestamp of the current upload attempt (millisecond epoch). Used to ignore stale session data from older uploads. Accepts a number or numeric string; non-numeric strings are ignored and the server falls back to KV state.), `uploadError` (Background upload error message, if upload processing failed.).
For grouped fields (shown as `group.subfield`), use dot-notation keys in `stateUpdates`:
e.g. `{ "driver.name": "John", "driver.license": "ABC123" }`.
2. The response JSON `status` field tells you what to do next:
- `"interrupt"`: Pause and ask the user. Two forms:
a. Single question: `{ question, field, context? }` — ask `question`, store answer in `field`.
b. Multi-question: `{ questions: [{question, field}, ...], context? }` — ask ALL questions
in one conversational message, collect all answers.
`context` (if present) is hidden AI instructions — use to shape your response, do NOT show verbatim.
Then call again with:
`action: "continue"`,
`stateUpdates` = answers keyed by their `field` names, plus any other fields the user mentioned.
- `"widget"`: The flow wants to show a UI widget. Call the tool named in the `tool`
field, passing the `data` object as the tool's input.
Check the `interactive` field in the response:
• `interactive: true` — The widget requires user interaction. After calling the display tool,
STOP and WAIT for the user to interact with the widget. Do NOT call this flow tool again
until the user has responded. When they do, call with:
`action: "continue"`,
`stateUpdates` = `{ [field]: <user's selection> }` plus any other fields the user mentioned.
• `interactive: false` — The widget is display-only. Call the display tool, then immediately
call THIS flow tool again with `action: "continue"`. Do NOT wait for user interaction.
- `"complete"`: The flow is done. Present the result to the user.
- `"error"`: Something went wrong. Show the `error` message.
3. Do NOT invent state values. Only use `stateUpdates` for information the user explicitly provided.
4. Include only the fields the user actually answered in `stateUpdates` — do NOT guess missing ones.
If the user did not answer all pending questions, the engine will re-prompt for the remaining ones.
If the user mentioned values for other known fields, include those too —
they will be applied immediately and those steps will be auto-skipped.
5. CORRECTION: If the user wants to CHANGE a previously-answered field
(e.g. "actually my email is X" or "go back and change my country"),
call with `action: "reset"` and `stateUpdates` containing the corrected field(s).
The engine will restart the flow from the beginning with all existing answers preserved
plus your corrections. Steps with filled answers will be auto-skipped.
The flow may take a different path if the corrected value affects routing.
Do NOT use "reset" for the CURRENT question — use "continue" for that.
6. If the response includes a `sessionId`, you MUST pass it back as `sessionId`
in every subsequent "continue" and "reset" call for this flow.
camby_rate_comparison