Skip to Content
Builder Docs
CRM, APIs & Knowledge Bases

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:

  1. Pre-Call HTTP Data Fetch (automatic HTTP request fired at call initialization — ideal for inbound calls and dynamic CRM lookups)
  2. External Trigger API initial_context (for API-initiated outbound calls and embedded tests)
  3. 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): Any https:// endpoint (such as your n8n.talkar.in webhook or CRM middleware).
  • Credential (pre_call_fetch_credential_uuid): Optional Credentials Vault entry. If using oauth2_client_credentials and the endpoint returns HTTP 401, 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 FieldMeaning
call_inbound.agent_idTarget workflow / agent numeric ID (workflow_id)
call_inbound.from_numberThe caller's number (caller_number)
call_inbound.to_numberThe 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:

VariableInbound ValueOutbound / Campaign ValueNotes
`{{initial_context.caller_number}}`Customer's phone numberTalkar outbound DID / caller IDFor inbound, matches from_number; always add initial_context. prefix or `| fallback:`
`{{initial_context.called_number}}`Talkar DID dialedDestination customer phone numberUse 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 providerAutomatically excluded from manual CSV checks
`{{gathered_context.call_id}}`Unique call identifierUnique call identifierStored in gathered_context; requires cross_node_variable_injection_enabled = true on downstream nodes
`{{current_time_<TZ>}}`Live time in IANA timezoneLive time in IANA timezoneExample: `{{current_time_Asia/Kolkata}}`
`{{current_weekday_<TZ>}}`Day name (Monday, Tuesday, ...)Day nameExample: `{{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 returns null.

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's initial_context object alongside phone_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 alongside phone_number (+E.164). Each row populates initial_context for that lead's call.

See the Talkar Service API Reference and Nodes, Prompts & Variables for complete syntax rules.

On this page