How it works
The context is JSON with theconversation so far and the reply the bot
wants to send next, bot_next_reply. The keys are yours to choose. One
decision, route, asks whether the bot can safely finish the conversation
with that reply. It has two outcomes: handle means the reply resolves the issue, and escalate
means a person or a stronger model should take over.
A policy turns those into one of your two actions, keep or hand_off,
using what each mistake costs:
Keeping a conversation that should have gone up costs ten times as much as a needless hand-off.
So
policy.action is hand_off whenever the probability of escalate is above 1 in 11.
Try it
Open this recipe in the playground to run it without an account. The customer there was charged £1,200 instead of £120 and will dispute it with the bank today. The bot’s next reply says refunds take 5 to 7 working days. To run it from your code, setSQWISH_API_KEY as in the quickstart, then send this request:
Act on the answer
The outcomes arehandle and escalate, but your code acts on policy.action, which is keep
or hand_off:
policy.expected_costs shows what each action was expected to cost.
Adapt it to your data
- Your costs. Set them from your own numbers: what a missed hand-off costs you, against the price of a person’s time or a bigger model’s call. Only how they compare matters: 10 and 1 act the same as 100 and 10 (weigh what mistakes cost).
- Your conversations. Send your own conversation in the same shape, with the reply your bot is about to send.
- Many conversations. Send one request per conversation.
What to watch
Track two numbers:- Missed hand-offs: conversations the bot kept that a person later had to take over. These
cost you most. If there are too many, raise the cost of
keepwhen the answer isescalate. - The hand-off rate: the share of conversations passed on. This is what you spend on people or
the bigger model. If it is too high, lower the cost of
keepwhen the answer isescalate, or raise the cost ofhand_offwhen the answer ishandle.
How well it works
This recipe hasn’t been measured on a public dataset. Its sample shows the format: measure it on your own examples before you rely on it.
Next steps
- Route a support ticket: send each ticket to the right team.
- Improve a decision: measure it on your own conversations and make it more accurate.
- API reference: every field in the request and the answer.
