#whats the best way to handle a case in which I want my agent to have a variable throughout a conver
1 messages · Page 1 of 1 (latest)
Best practice: use Dynamic Variables and Tool Assignments.
-
Persist the value as a dynamic variable. Define a variable name (e.g., customer_id) and pass it at conversation start via conversation_initiation_client_data.dynamic_variables, or via the public talk-to page (vars/var_... query params). Reference dynamic variables with {{customer_id}} in prompts and tool parameters. If the value is sensitive, use the secret__ prefix (e.g., secret__customer_id) so it’s only used in headers and not sent to the LLM. (elevenlabs.io)
-
Use the variable in tools. In Server Tools, include variables in URL/params using placeholders (e.g., /resource/{customer_id} or ?id={customer_id}); you can also mark a tool parameter as a Dynamic variable in the tool configuration. (elevenlabs.io)
-
Populate or update the variable from a prior tool call. Configure tool assignments so a field from the tool’s JSON response (value_path) is written into your dynamic variable. This makes the ID available for all subsequent calls. Example (conceptually): dynamic_variable: "customer_id", value_path: "response.data.id", source: "response". (elevenlabs.io)
-
Prefer dynamic variables over overrides for per-conversation context; overrides remain available but are not the recommended mechanism for values like IDs. (elevenlabs.io)
-
Optional (telephony): for inbound Twilio calls, you can inject dynamic variables at call start via your webhook. (elevenlabs.io)
This approach ensures the ID is set once, persists for the whole conversation, and is reliably injected wherever the tool needs it.
Sources:
Personalization | ElevenLabs Documentation
Server tools | ElevenLabs Documentation
Create tool | ElevenLabs Documentation
Personalization | ElevenLabs Documentation
Twilio personalization | ElevenLabs Documentation
how can I authenticate the client initiation webhook on my backend?
Short answer:
Use header-based secrets. In ElevenAgents settings, attach one or more secrets to the “Conversation initiation” webhook as HTTP headers (for example, Authorization or a custom X- header). On your backend, require HTTPS and verify those header values exactly; reject the request if they’re missing or don’t match. Optionally add an IP allowlist for ElevenLabs egress IPs.
What the docs say:
- Configure the webhook URL and “add any secrets needed for authentication,” then “modify which secrets are sent in the headers.” The Security section recommends HTTPS, header-based auth, and storing sensitive values in the ElevenLabs Secrets Manager. (elevenlabs.io)
- If you also use post-call webhooks, those support HMAC verification via the ElevenLabs-Signature header; validate using the SDK’s constructEvent helper. This is separate from the initiation webhook. (elevenlabs.io)
- You can further harden your endpoint by allowlisting ElevenLabs’ published egress IPs. (elevenlabs.io)
Sources:
Twilio personalization | ElevenLabs Documentation
Webhooks | ElevenLabs Documentation
Post-call webhooks | ElevenLabs Documentation
back to my other question about passing in variables on initiation: what if i dont want the variables in the prompt? they are more for internal use of the agent. Can i still reference them in a tool call if I passed them in dynamic_variables object?
Yes. Dynamic variables you pass at conversation start (conversation_initiation_client_data.dynamic_variables) are available to tools even if you don’t use them in the system prompt or first message. (elevenlabs.io)
How to reference them in tool calls:
- In tool configuration, use the variable with {{ variable_name }} in headers, path/query params, or body params. These are resolved at call time. (elevenlabs.io)
If the variable is sensitive and you don’t want it sent to the LLM at all, prefix it with secret__ and use it only in tool headers (e.g., Authorization: Bearer {{ secret__token }}). Secret dynamic variables are not injected into prompts/first messages and are restricted to headers. (elevenlabs.io)
So, you can keep internal-only values out of the prompt and still pass them reliably to your tools via dynamic_variables. (elevenlabs.io)
Sources:
Agent WebSockets | ElevenLabs Documentation
Dynamic variables | ElevenLabs Documentation
Dynamic variables | ElevenLabs Documentation
Dynamic variables | ElevenLabs Documentation
How? it wont let me define a new dynamic variable in my tool call. only system variables
You’re not limited to system__ variables. To use your own dynamic variable in a tool call:
- In the tool configuration (headers/path/body/query), set the parameter’s Value type to Dynamic variable and click the + button to create a new variable name (e.g., customer_id). Custom dynamic variables cannot use the reserved system__ prefix. (elevenlabs.io)
- Reference dynamic variables in tool parameters using the {{variable_name}} syntax; they don’t need to appear in your prompt. (elevenlabs.io)
- Provide values at runtime via conversation initiation data (dynamic_variables in the SDK/widget) or via the Twilio initiation webhook. The webhook response should include all dynamic_variables you intend to use. (elevenlabs.io)
- If the value is sensitive and should never be sent to the LLM, define it as a secret dynamic variable by prefixing secret__ and use it in dynamic variable headers. (elevenlabs.io)
- Tools can also create/update dynamic variables from their JSON response via Assignments (map JSON paths to variable names in the server tool config). (elevenlabs.io)
- For embedded/hosted agents, dynamic variables you pass at initialization are automatically available to tool calls, enabling internal-only usage without exposing them in prompts. (elevenlabs.io)
Docs:
- Dynamic variables (definition, creating in tools, templating, secrets, runtime passing) (elevenlabs.io)
- Server tools (Assignments to set variables from tool responses) (elevenlabs.io)
- Twilio personalization webhook (must return dynamic_variables) (elevenlabs.io)
- Blog guidance on passing session data via dynamic variables and automatic injection into tool calls (elevenlabs.io)
If you still only see system variables in the picker, use the + in the tool parameter’s Dynamic variable field to add your custom name, then supply it at initiation as above. (elevenlabs.io)
i dont see a + in the tool parameters dynamic variable field