Skip to main content
A support bot needs a natural back-and-forth with the user and the ability to look things up in your systems. Here’s one built on the gateway with tool calling: it asks for an order ID and email, then calls a get_order_status tool to answer.
python app.py

You › Hi, where is my order?

Bot › I can check that. Please share your order ID and the email you used to place the order.

You › Order 123123, email santa@clau.se

Tool › get_order_status(order_id=“123123”, email=“santa@clau.se”)
→ found · out for delivery · ETA 2024-11-08

Bot › Your order 123123 is out for delivery, arriving around 2024-11-08 to Snowy Mountain 123, Greenland. Items: Large wooden sled and Reindeer harness (x2).

You › Great, what did I actually order?

Bot › Your order 123123 contains a Large wooden sled and a Reindeer harness (x2).

The bot asks for the ID and email, looks the order up once it has them, and still knows the contents on the next turn because the history is kept. Here’s the whole thing.

The bot

Run it:

How it works

  • The tools array describes get_order_status to the model. It calls the tool only when it needs order data, and asks for the ID and email first when they’re missing.
  • The reply loop runs the model, executes any tool call, feeds the result back, and repeats until the model returns plain text. That’s the standard tool round trip.
  • The whole conversation, including the system prompt and tool results, lives in messages, so the bot remembers the order across turns. See Conversations.
  • Swap model for any of the 300+ models without touching the rest of the code.
Every call is traced in the platform. Add an Observe rule on this bot to score replies and catch regressions.

What’s next

Tool calling

The full tool-use round trip.

Conversations

Multi-turn chat and message history.

Guard

Block or redact sensitive content before it reaches the model.

Observe

Score every reply and watch quality over time.