Quote from a price list
Requirement
"Give a quote from our price list using our discount formula."
Pieces
- Custom data: a collection
prices, one record per item. - Custom tool:
quote, the discount formula, handed the price record and the order and answering the total. - Flow: query the price, then quote.
- The flow as a tool, attached to a node, on a published agent.
The shape to avoid
The prices and the formula in the prompt. The model does arithmetic badly and inconsistently, the prices go stale, and nobody can see which price a quote was made from. Here the price is a record, the formula is code that runs the same way every time, and the flow ties the two together.
Steps
Ids from an earlier step are written as {{step_N.field}}; the test that runs
this page substitutes them.
-
The price list.
create_collectionCode -
A price.
create_record(collection_id={{step_1.id}})Code -
Another.
create_record(collection_id={{step_1.id}})Code -
The formula. It is handed the matching price records, the quantity and the customer type, and answers a value.
tool_idin the response is what the flow step names.create_custom_toolCode -
Publish it.
publish_custom_tool(custom_tool_id={{step_4.id}})Code -
The flow.
create_flowCode -
Entry step: the price for the requested SKU, with the collection's query tool. The flow's inputs are in scope as
$ref:trigger.<key>.add_step(flow_id={{step_6.id}})Code -
Then the formula, over the records the query answered.
add_step(flow_id={{step_6.id}})Code -
Query, then quote. The flow's result is the last step's output: the quote.
add_flow_edge(flow_id={{step_6.id}})Code -
The flow as one tool.
create_toolCode -
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_13.id}})Code -
The node, with the quote tool.
add_node(graph_id={{step_14.graph_id}})Code -
Named as the root.
set_root(graph_id={{step_14.graph_id}},node_id={{step_15.id}})Code -
The profile on the draft.
edit_draft(version_id={{step_14.id}})Code -
Published.
publish_version(version_id={{step_14.id}})Code
What the agent sees
One tool, quote, with sku, quantity and customer_type, answering the
custom tool's result under result: the item, the unit price, the discount
and the total. The price list and the formula are invisible from the
conversation.
Variations
- The formula changes: edit the custom tool's draft
(
edit_custom_tool_draft) and publish again; the flow, the tool and the agent are untouched. - A price changes:
update_record; nothing is republished. - The item is named, not coded: query on
iteminstead ofsku, and let the node instructions ask the model to pick the SKU fromquery_pricesfirst.