Pre-Call Data Fetch & Dynamic Variables
Load CRM records into `initial_context` before the first greeting using Pre-Call Fetch, Campaign CSV columns, or Trigger API payloads.
Pre-Call Data Fetch & Dynamic Variables
A voice agent feels dramatically smarter when it already knows who is calling, what language they prefer, and why you are reaching out before speaking its opening line.
Talkar gives you three ways to inject dynamic data into initial_context prior to the Start Call node greeting:
- Pre-Call HTTP Data Fetch (automatic HTTP request fired at call initialization — ideal for inbound calls and dynamic CRM lookups)
- External Trigger API
initial_context(for API-initiated outbound calls and embedded tests) - Campaign CSV columns (for bulk outbound campaigns)
Configuring Pre-Call Data Fetch (Start Call Node)
On the Start Call node, enable Pre-Call Data Fetch (pre_call_fetch_enabled) and supply:
- Endpoint URL (
pre_call_fetch_url): Anyhttps://endpoint (such as yourn8n.talkar.inwebhook or CRM middleware). - Credential (
pre_call_fetch_credential_uuid): Optional Credentials Vault entry. If usingoauth2_client_credentialsand the endpoint returns HTTP401, Pre-Call Fetch automatically invalidates the cached token, refreshes it once, and retries.
What Talkar Sends to Your Endpoint
Talkar dispatches an HTTP POST request with a 10-second timeout immediately before the call begins:
{
"event": "call_inbound",
"call_inbound": {
"agent_id": 42,
"from_number": "+919876543210",
"to_number": "+918061234567"
}
}| Payload Field | Meaning |
|---|---|
call_inbound.agent_id | Target workflow / agent numeric ID (workflow_id) |
call_inbound.from_number | The caller's number (caller_number) |
call_inbound.to_number | The Talkar DID / destination number dialed (called_number) |
Keep Pre-Call Fetch under 1–2 seconds
Because Pre-Call Fetch runs before the Start Node delivers its greeting, slow upstream CRM responses directly delay how quickly the caller hears "Hello". If your CRM API is slow, front it with a cached lookup in n8n.talkar.in or pass the data directly at call trigger time.
Required JSON Response Format (initial_context / dynamic_variables)
Talkar only merges keys wrapped under initial_context (canonical) or dynamic_variables (legacy fallback)—either at the top level or nested inside call_inbound. Flat top-level keys or "data": {...} wrappers are ignored!
{
"initial_context": {
"customer_name": "Rohan Sharma",
"crm_lead_id": "LEAD-8492",
"account_tier": "Enterprise",
"open_ticket": "TKT-104"
}
}Inside your Start Call greeting and downstream Agent prompts, you can immediately reference any key returned inside initial_context:
Hi {{customer_name | fallback:there}}, thanks for calling support regarding ticket {{open_ticket | fallback:your account}}.Always-Available System & Telephony Context
Every call automatically populates runtime telephony values before any prompt renders—even without Pre-Call Fetch:
| Variable | Inbound Value | Outbound / Campaign Value | Notes |
|---|---|---|---|
`{{initial_context.caller_number}}` | Customer's phone number | Talkar outbound DID / caller ID | For inbound, matches from_number; always add initial_context. prefix or `| fallback:` |
`{{initial_context.called_number}}` | Talkar DID dialed | Destination customer phone number | Use initial_context. prefix or `| fallback:` so publish/CSV checks pass |
`{{initial_context.direction}}` | "inbound" | (Not set on outbound; use trigger_mode or | fallback:) | Use `| fallback:outbound` in shared inbound/outbound workflows |
`{{provider}}` | Telephony provider (plivo, twilio, etc.) | Telephony provider | Automatically excluded from manual CSV checks |
`{{gathered_context.call_id}}` | Unique call identifier | Unique call identifier | Stored in gathered_context; requires cross_node_variable_injection_enabled = true on downstream nodes |
`{{current_time_<TZ>}}` | Live time in IANA timezone | Live time in IANA timezone | Example: `{{current_time_Asia/Kolkata}}` |
`{{current_weekday_<TZ>}}` | Day name (Monday, Tuesday, ...) | Day name | Example: `{{current_weekday_Asia/Kolkata}}` |
Bare `{{caller_number}}` / `{{called_number}}` in CSV or Trigger validation
When publishing or validating campaigns, Talkar scans prompts for custom template variables so it can require them in Campaign CSV headers. Dotted paths (`{{initial_context.caller_number}}`), fallback expressions (`{{caller_number \| fallback:unknown}}`), current_time*, current_weekday*, and provider / campaign_id / source_uuid are automatically skipped from manual variable prompts.
Fallback & Error Handling Behavior
What happens if your Pre-Call Fetch endpoint times out (past 10s) or returns HTTP 4xx / 5xx?
- Talkar treats Pre-Call Fetch as fail-safe / non-fatal so callers are never dropped during temporary CRM outages.
- The returned keys simply remain absent from
initial_context. - Writing
`{{var \| fallback:default}}`on every Pre-Call Fetch variable guarantees clean spoken phrasing even when a CRM lookup misses or returnsnull.
Good prompt pattern:
Address the caller as {{customer_name | fallback:there}}.
If {{open_ticket | fallback:none}} is not "none", ask if they are calling about ticket {{open_ticket | fallback:none}}.Injecting Context on Outbound API & Campaign Calls
For outbound calls, you rarely need Pre-Call Fetch because you already know the lead record when initiating the call:
- External Trigger API (
POST /api/v1/public/agent/{uuid}): Pass all known CRM fields inside the request'sinitial_contextobject alongsidephone_number. - Campaigns CSV: Include any required variable referenced in your prompts (such as
first_name,crm_id,renewal_date) as non-empty columns in your CSV upload alongsidephone_number(+E.164). Each row populatesinitial_contextfor that lead's call.
See the Talkar Service API Reference and Nodes, Prompts & Variables for complete syntax rules.
Integration Architecture Overview
Choose the right integration pattern—Pre-Call Fetch, Mid-Call HTTP Tools, MCP servers, Knowledge Bases, Webhook Nodes, or `n8n.talkar.in`—for every CRM and backend use case.
Custom HTTP Tools & Webhooks
Build reliable mid-call REST integrations (`http_api`), store API keys in the Credentials Vault, use `body_template` & double-brace `{{param}}` substitution, test requests with header masking, and configure Post-Call Webhooks.