Functions are the way an AI agent reaches outside its own conversation — to look up account data, push an update to your CRM, send a notification, or anything else. Events are the signals that functions emit to drive state transitions inside a flow. Together, functions and events are how a flow goes from “an LLM talking to a customer” to “an LLM that gets things done and routes intelligently between its own states”.Documentation Index
Fetch the complete documentation index at: https://docs.dialai.ca/llms.txt
Use this file to discover all available pages before exploring further.
Where functions live
Functions are managed under Build > Functions. From there you can:- List existing functions, filter by tag or integration.
- Create a new function (either a JavaScript-backed function or an integration-typed one).
- Open an individual function to edit its source, parameters, declared events, and tests.
- View Snapshots — published versions of a function used by published flows.
Functions remain available even after the conversation has left the state that introduced them. If a state needs a function, attach it there; once it’s been seen, it can be called again later in the conversation.
Creating a function
From the Functions page, click Create. You’ll land on the function editor, where you configure:- Name and description — what the agent sees when deciding whether to call this function.
- Inputs — three kinds (see below).
- Outputs — the response shape, declared events, and declared context additions.
- Source code — JavaScript that runs when the function is called.
Inputs
A function can take three kinds of input: Parameters are values the agent collects from the customer and passes in at call time. For aLookup Account by Phone function, the agent would supply the phone number as a parameter.
Internal parameters (also called context parameters) come from the conversation’s context — set by a previous function, by the runtime, or by the platform. Common examples: the customer’s contact ID, parameters set by a Caller ID Lookup that runs at startup.
Static parameters are configured per-flow under Configure Flow > Variables. Use them for API keys, base URLs, environment-specific toggles, and anything else that doesn’t change mid-conversation.
Outputs
A function returns a single JSON object with up to three keys:response is what the agent sees as the result of the call. This is the natural place for human-readable data the agent will use in its next reply.
contextAdditions is a set of key/value pairs added to the conversation’s context. Later functions can read these as internal parameters. Use this for data you want available later but don’t want the agent reasoning over directly.
event is the name of an event this call emits. A function may emit at most one event per call. Events are what drive state transitions — see the Events section below.
Source code
The function body is plain JavaScript with a small set of helpers available (HTTP fetch, logging, JSON parsing, etc.). The full helper reference is available via the info icon in the function editor.Events
An Event is a named signal that drives a state transition. The flow says “from state A, on eventAccountFound, go to state B”. The function says “I emit AccountFound when…”.
Events are how flows branch. A Lookup Account function might emit:
AccountFound— proceed to confirm details.MultipleAccounts— present a disambiguation step.NoAccountMatch— collect more info or escalate.
Events are not visible to the AI agent. They drive routing only — the agent reads the
response, the runtime reads the event.Designing functions
Functions don’t always need to “do something.” Sometimes the most useful function is one that simply emits an event to move the conversation into a new state with new instructions. Example: a flow handles billing inquiries with complex eligibility rules. Rather than cramming every rule into the initial state’s thought, define aStart Billing Process function that emits a BillingStarted event. The flow transitions to a dedicated billing state with a focused thought and a tighter set of functions. The agent stays in scope; the thoughts stay readable.
When to use each input type
| Use… | When the value… |
|---|---|
| Normal parameter | Comes from the customer in this turn (account number, address, requested date). |
| Internal parameter | Was set by an earlier function or the platform (contact ID, caller ID lookup result). |
| Static parameter | Is the same for every conversation in this flow (API key, base URL, integration ID). |
Testing a function
The function editor has a built-in test panel:- Fill the Test parameters form. To pre-populate values from a flow, click Populate from flow and pick a target flow.
- Click Run test.
- The panel shows the function’s response, any context additions, and the emitted event.
Function snapshots
When you publish a flow, the platform freezes the exact function source used by that flow as a snapshot. This means changes to a function don’t accidentally break a published flow — the published version keeps running the source it was published with. To pick up new function code in production, re-publish the flow. Snapshots are listed under Build > Functions > [Function].Related
Designing thoughts
Write the instructions that decide when to call your functions.
Flow configuration
Configure start-up and wrap-up functions and static parameters.
Building blocks
Manage parameters and tags shared across flows.