- Customer identification: Associating the session with a specific user, allowing the agent to personalize responses.
- Variable substitution: Supplying values for variables defined in your agent’s prompt.
- Context injection: Any other free-form context that needs to be included in the system prompt.
Schema
Context is a JSON object. There are two reserved keys:$customer
and $variables
.
$customer
Provides details about the user the agent is speaking with. This enables personalization, historical lookup, and integration with CRMs like Salesforce or Zendesk. It’s schema is:
name
: Name of the customerphone_no
: Phone numer of the customeremail
: Email of the customerexternal_id
: External unique ID (e.g. the identifier in your internal systems) for the customersalesforce_lead_id
: Salesforce Lead ID of the customersalesforce_contact_id
: Salesforce Contact ID of the customerzendesk_user_id
: Zendesk User ID of the customerextra
: A free-form object for any additional metadata about the customer
$variables
Used to substitute variables in your agent’s prompt. All variables without default values must be supplied. You can define them in the Configuration tab and reference them in your prompt as $variable_name
.
Preloading
In practice, we’ve found that preloading context—before a conversation begins—is the single highest-leverage way to improve agent performance. You can preload context in a few different ways:- API trigger: If you’re starting a conversation via POST /conversations, include a
context
field in your request.- This does not work for inbound calls, since they are initiated by the customer and not by you.
- CRM integration: If you’re using a supported CRM, your agent will automatically look up the customer based on identifiers like phone number or email. The agent will pull basic personalization context such as:
- Name
- Location
- Company
- Webhook: Configure a webhook to dynamically preload context.
- Before every conversation, the agent sends a
conversation.setup event
to your webhook endpoint. - Your server responds with the configuration, including the
context
field you want to inject into the agent.
- Before every conversation, the agent sends a
In-conversation
You can update or inject new context into an on-going conversation. This is useful for passing external signals (e.g. “user just verified their identity”) mid-conversation. See the Update context endpoint documentation for more details.Examples
Here are a few examples of how you might shape your context depending on your use-case:Trucking / logistics
Healthcare
Read next
- Dynamic configuration: learn how to dynamically change the agent behavior for a particular conversation
- Webhooks: learn the schema of the
conversation.setup
event webhook used to fetch the initial conversation context