Overview
Dynamic Context lets you fetch customer data from your external APIs once, before each conversation starts. Instead of relying only on contact records, your agents can access account status, order history, support tickets, and business context from your CRM, databases, and backend systems.Dynamic Context is configured in Agent Settings → Operations → Dynamic Context. The returned JSON data is available directly as variables (e.g.,
{{ field_name }}) in your agent’s greeting and instructions.The context API is called once before the conversation begins. The data is available for rendering the greeting and throughout the conversation. It does not refresh during the conversation. Keep your endpoint fast (<1s response time) and return only data needed for the conversation.
- HTTPS endpoint
- JSON response under 32 KB
- Response time under 1 second (ideally)
- Authentication via Bearer token, API key, or Basic auth
How It Works
Request Flow:Inbound calls
direction: "inbound" with caller’s contact_number. Look up customer data in your CRM.Outbound calls
direction: "outbound" with contact_number you’re calling. Fetch campaign context.Web widget
medium: "web" with optional external_id. Identify user in your system.Configuration
Navigate to Dynamic Context
- Open your agent settings
- Click the Operations navigation group (on the left sidebar)
- Select Dynamic Context from the sections
Configure Endpoint
Endpoint URL:
https://api.company.com/contextAuthentication: Choose Bearer Token, Basic, API Key, or NoneThe request will include: agent_uuid, direction, agent_number, contact_number (and external_id for web widget)Request & Response Format
What We Send (POST Request)
agent_uuid(string, always included) - The UUID of the agent handling the calldirection(string, always included) - “inbound” or “outbound”agent_number(string, optional) - The phone number the agent is usingcontact_number(string, optional) - The customer’s phone numberexternal_id(string/int, optional) - Only for web widget calls, if provided by your integration
X-Agent-UUID,X-Agent-Number,X-Contact-Number,X-Direction,X-Medium(phone/web)X-Room-SID- Unique identifier for this conversation sessionX-External-ID- For web widget calls only
Typical usage: Your endpoint uses
contact_number or external_id to look up the customer in your CRM/database, then returns relevant account data, order history, tickets, etc. The agent_uuid can be used to customize responses per agent if needed.What You Return (JSON Response)
- Valid JSON format
- Under 32 KB
- Return only necessary fields (keeps response fast)
- Handle missing data gracefully (return
nullor omit fields)
How variables are accessed: All top-level keys in your JSON response become template variables. If you return
{"account": {"tier": "VIP"}}, you access it as {{ account.tier }}, not {{ context.account.tier }}.Using Context Variables
All returned data from your API is available directly as top-level variables in your agent’s greeting and instructions. Accessing fields:Authentication
Bearer Token (Recommended)
API Key (Header)
Basic Auth
None
No authentication (only for internal/private networks).Example Use Case
Customer Support with Full Context Scenario: Support agent needs complete customer view before conversation starts. Your API returns:Best Practices
Keep responses fast
Keep responses fast
- Target under 1 second response time
- Cache frequently accessed data (5-10 minute TTL)
- Return only fields you’ll use in instructions
- Use database indexes on lookup fields (contact_number, external_id, or your internal customer IDs)
Handle missing data gracefully
Handle missing data gracefully
- Use
| default("value")filters in instructions - Return
nullfor missing fields (don’t error) - Test with contacts that have minimal data
Secure sensitive data
Secure sensitive data
- Don’t return SSN, credit cards, passwords
- Use HTTPS only
- Implement authentication (Bearer token recommended)
- Return only necessary fields (e.g., last 4 of account number, not full)
- Log access for audit trails
Test before production
Test before production
- Use Test Request modal with real customer data
- Test edge cases (new customer, VIP, suspended account)
- Verify instructions handle missing fields gracefully
- Pilot with small traffic percentage before full rollout
Troubleshooting
401 Unauthorized
401 Unauthorized
Context variables empty
Context variables empty
- Use Test Request to verify endpoint is responding
- Check JSON structure matches what you’re accessing
- Verify Dynamic Context toggle is ON
- Use
| default("fallback")for missing fields
Slow or timeout
Slow or timeout
- Add database indexes
- Implement caching
- Return only necessary fields
- Optimize database queries
- Check network latency to your API
Wrong data returned
Wrong data returned
- Check parameters in Test Request modal
- Verify template variables resolve correctly:
{{ account.tier }} - Ensure cache keys include customer identifier
- Test with known customer to confirm data matches