Skip to main content
Early accessGnani Evon v3.5 is now available as an API to early access registrants.
This recipe builds a command-line support bot for an online store. It answers in the customer’s language and uses tool calling to look up orders and open support tickets in your systems.

When to use this

  • Customers ask questions that need live data from your systems, such as order status.
  • The bot should take simple actions, such as opening a ticket, and confirm them in the chat.
  • Customers write in Hindi, English or a mix, and expect a reply in the same language.

The complete bot

Each script keeps the conversation, runs the tools the model asks for, and loops until the model answers. The order data is synthetic; replace the two functions with calls to your own systems.
Save the script as support_bot.py or support-bot.mjs and run it with python support_bot.py or node support-bot.mjs. A session looks something like this (replies vary):

How it works

  1. The customer’s message is added to messages, after the system message.
  2. The request sends tools. The model either answers, or replies with tool_calls.
  3. For each call, your code parses arguments, runs the function, and adds a tool message whose tool_call_id matches the call’s id.
  4. The conversation is sent again, with the same tools, until the model answers in content.
  5. The answer is kept in messages, so the next question has the whole conversation.

Options


Gotchas

Check message.tool_calls, not finish_reason. When you force a function with tool_choice, the reply can have finish_reason: "stop" even though it contains a tool call. And tool_choice: "required" is only allowed when tools has exactly one tool. Both differ from OpenAI. See Tool calling.
  • Validate arguments before you act. They are written by the model. Never pass them straight to a database query or a shell.
  • Return errors as tool results, as get_order_status does for an unknown ID. The model can then explain the problem to the customer.
  • Tool results are screened like user messages. If a tool returns text from customers or the web that tries to instruct the model, the request can be refused with 400 content_filter. The scripts drop that turn so the chat can go on.
  • Personal data in replies is masked. If a tool returns a phone number or UPI ID and the model repeats it, the reply contains a placeholder such as [REDACTED_PHONE]. See Safety and privacy.
  • Every tool round is a separate request. Each counts toward your rate limits and daily token quota. Trim old turns in long chats.

Tool calling

The tool-calling flow, step by step.

Safety and privacy

Blocked requests and masked personal data.

Voice agent

Put the same bot behind Prisma and Timbre.

Errors

Status codes, error bodies and retries.