How to Add Metadata
1. Via URL Parameters (Embedded Widget)
When using the embeddable call widget, you can add metadata directly through URL parameters:2. Using the Web SDK
You can add metadata to a call using the Web SDK by providing the metadata as the second parameter in thestart
method. The third parameter, include_metadata_in_prompt
, determines whether the metadata should be included in the agent’s system prompt.
- The first parameter is the
agentId
or a temporary agent configuration. - The second parameter is the metadata you want to attach to the session.
- The third parameter is
include_metadata_in_prompt
, which controls whether the metadata is used by the agent during the conversation.
3. Using the native Websocket connection
You can also attach metadata by initiating a session through a WebSocket connection. Include the metadata in theinitiate
method payload.
4. Using the Outbound API
To add metadata using the outbound API, you need to include it in the request body when calling thestart_outbound_call
API. You can also specify whether to include the metadata in the agent’s prompt.
from_phone
: One of your agent’s phone numbers.to_phone
: The phone number of the call recipient.metadata
: Optional. Any extra data you want to attach to the session.include_metadata_in_prompt
: Optional. Set totrue
to include metadata in the agent’s prompt. Defaults tofalse
.
How to retrieve and use Metadata
The metadata will stay associated with that session throughout its lifecycle. This metadata will also be included in the following:- Prefetch Data Webhook: Metadata is forwarded during the session’s prefetch data webhook which you can use to retrieve personalized data.
- End of Call Webhook: Metadata is passed along at the conclusion of the call, allowing you to track and identify sessions.
Use Metadata as Variables
Any metadata you attach to a call session can be used as dynamic variables throughout your call flow. Variables can be referenced in agent prompts, messages, webhook parameters, and function calls using the{variableName}
syntax.
For example, if you add metadata like:
{userName}
or {userType}
in various places during the call.
For detailed information about using variables, including syntax and examples, see our Variables documentation.