Skip to main content

03 — Tools: side effects

3.1 Two kinds of tools​

A tool's Tool trigger picks its kind:

  • Agent decided (options.llm_tools entries): the agent chooses when to run them, like any LLM tool. {name, description, parameters, conditions, fulfillment: {<actions>}} — name is the function name, description tells the agent when to call it, parameters (Parameters) are JSON-schema properties the agent fills (their values become state variables), and the nested fulfillment map holds the actions to run.
  • On an event (fulfillment array entries): the engine fires them when the entry's timing event occurs and its conditions hold. {timing, conditions, <action keys>} — action keys sit at the entry's top level.

A fulfillment entry whose only action is trigger is not a tool — it's an event transition (01-flow §1.6). An entry can combine trigger with other actions; it then acts as both.

"options": { "llm_tools": [{
"name": "check_wait_time", "description": "the contact asks how long the wait is",
"fulfillment": { "webhook": { "url": "https://api.example.com/wait" } }
}]}

3.2 Event timings​

The timing values:

TimingBuilder labelFires when
triggeredGoal triggeredthe goal becomes the active goal (any start reason)
triggered_onceGoal triggered (first time only)like triggered, but only the first time ever
performedGoal attemptedthe agent actually said the goal's message
collectedField is collectedan answer was collected for the goal (actively or passively)
completedGoal completethe goal completes — never fires for a goal the flow stopped unfinished (01-flow §1.5) — the default when timing is absent

Entries are evaluated in array order; for next-goal overrides the last one wins (01-flow §1.6). Some configs carry other timing values the builder UI doesn't edit — preserve them, and author with the five above (lookups/non-ui-fields.md).

The builder offers a goal only the timings that can fire for its shape, under the same labels for event tools and event transitions — author to the same rules:

  • collected needs a value_type; on a choice it is labelled Choice selected and is the choice's natural default (02-dialogue §2.5).
  • performed needs messages; a choice or container is never performed.
  • triggered / triggered_once never apply to a choice (it is picked, not started). triggered_once is also withheld from containers and hot-transfer goals: the engine re-enters a container on every goal scan, and the hot transfer is uninterruptible, so neither fires exactly once.
  • completed is withheld from hot-transfer goals: its repeating hold sub-goal never completes, so the parent never does. Hang transfer follow-ups on performed.

3.3 Actions​

Any entry (event- or agent-based) may carry several actions; each key below is one action.

  • values — set state: a map of key → value written into call state, overwriting collected answers by goal name (an empty value clears and re-opens the goal). Both keys and values accept placeholders, including %self%/%parent%. values_silent is the same without triggering an acknowledgement.

    { "timing": "collected", "values": { "stage": "qualified", "budget_usd": "{budget}" } }

    Gotcha: values apply to any goal with that name — duplicate names share one slot.

  • trigger — jump: start the named goal (falls back to matching a trigger phrase if no goal has the name; eligibility still applies). Use only when the target is not simply next in the flow. The special value %abort_goal% cancels the current goal instead of jumping.

  • webhook (Call a webhook) — call your endpoint and act on the reply:

    • Request: url (placeholders allowed), method (default POST), body (map; placeholders; when omitted, POSTs the full call state — every variable and collected answer, plus goal_name, goal_value, timing), headers, params, timeout (s, default 3), max_attempts (default 3, retried on 500s only).
    • Response: a JSON object whose keys are applied as actions — values / values_silent write state, trigger jumps to a goal ("%abort_goal%" cancels the current one), acknowledge / exclusive_message / ux adjust the turn. Requests to private/internal addresses are blocked.
    • mapping: use it when the endpoint doesn't reply in that action shape. It is a template for the action object: its keys are action keys (values, trigger, …) nested the way the action needs them, and each string leaf is a dot path into the reply ("$" takes the whole reply). The applied actions become only what the template builds; unmapped reply keys are dropped.
    { "timing": "completed", "webhook": { "url": "https://api.example.com/leads/{chat_id}" } }
    {
    "timing": "triggered",
    "webhook": {
    "url": "https://api.example.com/abilities",
    "method": "GET",
    "mapping": { "values": { "abilities_count": "count", "first_ability": "results.0.name" } }
    }
    }

    Sets the abilities_count variable from the reply's count. Gotcha: { "count": "abilities_count" } is backwards and missing values; it builds an action named count and writes nothing.

    Gotcha: a slow endpoint stalls the turn — keep handlers fast or fire-and-forget.

  • text_message (alias sms, Send a text message) — send an SMS: message (required, placeholders allowed); phone_number_field picks which state field holds the target number (default phone = the contact); to_number hard-codes a target (alerts to a fixed number); from_number overrides the sender (defaults to the agent's number).

    { "timing": "collected", "text_message": { "message": "Hi {contact_name}, here's the link: {link}" } }
  • voice_action — call control: hang_up (after the agent finishes speaking — the normal way to end), hang_up_immediately (cuts off speech; rare), speech_slow_down / speech_speed_up / speech_normal, speech_volume_up / speech_volume_down.

  • call_result (Set contact state) — set the call outcome (§3.4). Usually paired with voice_action on the closing goal.

  • Transfer — new_call (hot transfer/merge) and forward_call (blind forward): full contract in flows/hot-transfer.md.

  • CRM (e.g. hubspot) — push collected values to the connected CRM; fields per integration.

"fulfillment": [
{ "timing": "performed", "voice_action": "hang_up", "call_result": "disqualified" }
]

3.4 Call results​

A script may set exactly these four values:

ValueMeaningEffect
qualifiedcontact matches the business requirementusually set mid-call on the qualifying answer
convertedcontact completed the objective (booked, agreed, transferred)ends the campaign for this contact as a success
disqualifiedcontact doesn't fitcontact will not be attempted again
do_not_callcontact asked not to be calledend the call and remove from the call list

Set a result on every path that ends the call deliberately; an unset result leaves the contact eligible for retry per campaign rules.

The system assigns further values on its own (voicemail, ivr, no_answer, busy, wrong_number, contact_verified, callback_requested, …) — you may read them via %call_result% in conditions, but never set them.