API · Connect your systems

Messages, hooks, tools & events

An avatar that only knows its prompt can talk. An avatar that knows your customer, checks your orders and books your slots can help. These four pieces connect a live call to your own systems. Pick one by asking two questions: who starts it, and does anyone wait for an answer?

The four, side by side

MessagesHooksToolsEvents
In one lineYou tell the AI somethingWe ask your server, because a rule matchedThe AI asks your server, because it judged it shouldWe tell your server what happened
Who starts itYour code, whenever it likesA rule you set: the call starts, or the visitor says certain wordsThe AI, during the conversationThe call itself
Does the avatar wait?NoYes, briefly, before it replies (no holding line)Yes. It says a holding line (“let me check…”) and then answersNo, and your answer is ignored
Best forFacts you already know, news from your system mid-callPulling data in at the right moment, every timeFetching with values from the conversation, and doing things (book, send, save)Your records, CRM, analytics after the call
Set up withPOST /v1/sessions (at start) or POST /v1/sessions/{id}/context (mid-call)/v1/agent/{id}/hooks/v1/agent/{id}/toolsThe call record and data handoffs

A picture that helps:

  • •A message is a note slipped to the avatar during the call. Nobody answers it.
  • •A hook is us phoning you because the visitor said a word on your list, and getting the answer before the avatar opens its mouth.
  • •A tool is the avatar deciding to phone you itself, saying “one moment” to the visitor while it holds the line.
  • •An event is being copied on an email: you are told, nobody waits for you.

Hooks and tools reach your server the same way: an HTTPS POST, signed, with the same body shape, and you answer in the same shape. One endpoint can serve both. See Your endpoint & signatures.

Which one do I need?

You want…Use
The avatar to know who the visitor is and what they bought, from the first wordA message at call start (scope call)
A personal greeting for this visitorA message at call start with exact: true: it replaces the agent's greeting
To tell the avatar news from your system while the call runs (a payment went through, an order shipped)A mid-call message, next_pause if it should speak up on its own
Data at call start that only your server has, for calls you didn't start yourself (the website widget, a QR code)A call-start hook
The answer ready the moment the visitor says certain words (“refund”, an order number)A pattern hook
The avatar to look something up with details from the conversationA tool, type wait
The avatar to do something: book, cancel, send, saveA tool (wait to confirm the result, silent to save in the background)
A job that takes longer than a few secondsAn async tool, or a tool that answers at once and a mid-call message later with the result
To know what happened in the callEvents: the call record and data handoffs (below)

Still unsure between a hook and a tool? A hook matches words; a tool understands meaning. A hook on “book” also fires on “I don't want to book”. Anything that acts on what the visitor means is a tool. Anything you want fetched every time a word or a shape appears, fast and without a holding line, is a hook.

A worked example: an online shoe shop

Lumen Shoes puts an avatar on its order page. Maria is logged in. Here is every piece, in the order it happens.

  1. 1

    The call starts with what the shop already knows

    The shop's server calls POST /v1/sessions with external_user_id: "u_88" and two messages: an exact greeting, “Hi Maria, welcome back to Lumen Shoes!”, and a call-scope fact, “Maria is a Gold member (10% off). Her cart: white trainers size 38.” The avatar greets her by name and knows her cart for the whole call.

  2. 2

    A call-start hook pulls her open orders

    As the call starts, the hook open_orders calls the shop's server with the session id and u_88. The server answers with her two open orders, scope call, so the avatar can talk about them all call long.

  3. 3

    A pattern hook answers returns questions instantly

    Maria asks “can I return the sandals?”. The word return matches the hook returns_policy; the shop's server answers in 200 ms and the avatar replies with the right policy, with no pause and no “let me check”.

  4. 4

    A tool checks one order

    “Where is order A4512?” The AI calls the tool check_order with order_id: "A4512", says “Let me check that for you”, and answers with the shop's result: shipped Tuesday, arriving Friday.

  5. 5

    A tool acts

    “Please start a return for the sandals.” The AI calls create_return. The shop's server checks that the order belongs to u_88, creates the return once (it keys it on the order id, see the warnings), and answers with the return number, which the avatar reads out.

  6. 6

    A message mid-call

    While they talk, Maria pays for the trainers in another tab. The shop's payment system posts a next_pause message: “Payment for the trainers just went through; they ship tomorrow.” At the next quiet moment the avatar tells her.

  7. 7

    Events after the call

    When Maria leaves, the call record (call.ended) goes to the shop's webhook with the transcript and u_88, and the next time Maria calls, the avatar remembers this conversation.

Rules that apply to all of them

⚠ The AI forgets single-use information

A message with scope turn, a hook answer with scope turn, and a tool's result are shown to the AI for one reply only. After that reply the AI has no recollection of them: only what it actually said out loud stays in the conversation. If the visitor asks about it again later, the AI will not know. Anything the AI should keep knowing must be sent with scope call. Details on Messages.

⚠ Anything you send may be said out loud

The AI can repeat whatever you give it: a message, a hook answer, a tool result. Never send passwords, keys, internal notes, or other customers' data. Send only what you would be happy for the visitor to hear.

⚠ Values from the conversation are the visitor's words

A tool's values and a hook's matched text come from what the visitor said. A visitor can say any order number, any name, “I'm the manager”. Check on your own server that the visitor may see or do it, using the ids you control (external_user_id sent with your key or a signed token, or the session_id), never a name or number they spoke.

⚠ Your server's speed is the avatar's speed

While a hook or a wait tool runs, the visitor waits. Answer in well under a second where you can. Slow answers make a slow avatar, and an answer that misses its timeout counts as no answer: the AI says it couldn't get it, and never guesses.

Also good to know

  • •Hooks and tools belong to the agent, not to one session: they run in every conversation with that agent, whether it was started through the API, the website widget, a direct link or a QR code. A change applies to calls that start after it.
  • •All four work in conversation sessions only. A render session has no AI of ours to tell or to call tools.
  • •The AI uses messages and results where they fit in the conversation, in the visitor's language. It does not read them out word for word unless you mark a message exact.
  • •Every call from us to your server is signed. Check the signature before you trust it.

Events today

Events are one-way: we tell your server something happened, and nothing waits for your answer. Today they come after the call:

  • •The call record (call.ended): one fixed JSON record after every call, with your ids, times, why it ended, the summary and the transcript.
  • •Data handoffs: the details the avatar collected, sent in the format you choose.

A live, turn-by-turn event feed during the call is not available yet. Until then, a call-start hook tells your server the moment a call starts (with its session_id), and pattern hooks tell it when the visitor says the words you care about.

Got a call from the website widget and want to send it messages? A call-start hook gives your server the session_id as the call begins; post messages to POST /v1/sessions/{session_id}/context with your key. GET /v1/sessions also lists every live session of your account, whatever started it.