Greet callers by name
Requirement
"Greet callers by name when we know them."
Pieces
- Custom data: a collection
customerswithphonedeclared as the identity field, so itsget_customerstool looks a customer up by number. - The lookup as a pre hook:
get_customerson the agent'spre_hook_tool_ids, with itsphoneparameter fixed to$ref:conversation.number. The hook runs before the first word and its answer is injected as context; the number comes from the conversation, on either leg of a call. - Node instructions that say to use the name when the lookup answered.
- A published agent.
The shape to avoid
The customer list in the prompt. It goes stale the day it changes, it puts
every customer's name in front of the model on every call, and the personal
data escapes the retention window that a collection's personal fields
respect.
Also the in-conversation lookup: the tool on the node and instructions that ask the caller for their number. It works, but it makes the caller say a number the platform already knows, and the greeting cannot use the name because the lookup has not happened yet.
Steps
Ids from an earlier step are written as {{step_N.field}}; the test that runs
this page substitutes them.
-
The customers. Both fields are personal.
create_collectionCode -
Declare the identity field. It is set once the fields exist, and it is what gives
get_customersaphoneparameter instead of arecord_id. A phone number written to it is stored in E.164, so two spellings of one number are one customer.update_collection(collection_id={{step_1.id}})Code -
A customer.
create_record(collection_id={{step_1.id}})Code -
Fix the lookup's
phoneto the number the conversation opened with.get_tool_idon the collection is the tool's id. Afixed_parametersvalue written$ref:conversation.<key>is resolved when the tool runs: an inbound call opens with the caller's number undernumber(and the dialled one undercalled_number), an outbound call with the contact's under the samenumber. The model no longer seesphoneat all.update_tool(tool_id={{step_1.get_tool_id}})Code -
An agent publishes only with an AI profile.
create_llm_settingsCode -
The profile.
create_profileCode -
The agent.
create_agentCode -
Its draft.
get_draft(agent_id={{step_7.id}})Code -
The root node. No tool on it: the lookup has already happened by the time the node is reached, and its answer is in the context. The instructions say what to do with it.
add_node(graph_id={{step_8.graph_id}})Code -
Named as the root.
set_root(graph_id={{step_8.graph_id}},node_id={{step_9.id}})Code -
The profile on the draft, and the lookup as the pre hook.
edit_draft(version_id={{step_8.id}})Code -
Published.
publish_version(version_id={{step_8.id}})Code
What the agent sees
No tool. Before the first word, one line of context: get_customers's
answer, {"record": {...}} with the name or {"record": null}. The
instructions decide what to say with it.
Variations
- A browser test call opens with no number, so the hook is handed no
phoneat all and answers that there was nothing to look up by; the agent greets without a name. Test the greeting by calling the published number. - Outbound calls from a campaign: the same hook serves, because the
contact's number opens the call under
numbertoo. The contact's record also travels with the call as context, so a campaign that already knows the name needs no lookup. - A returning caller's last order: a second field on the same record, or
a second collection
orderswhosequery_orderstool sits on the root node; the instructions say what to mention. - Writing a new caller down: attach
write_customers(write_tool_id) to the node; it asks the person before it writes, becauserequires_confirmationis on by default for a collection's write tool.