https://retellai.com/?utm_source=discord&utm_medium=seo logo
Is it possible to set a dynamic variable by prompt
# ❓・ai-evy-support
a
@AI Evy Is it possible to set a dynamic variable by prompt?
a
Thanks for tagging me @adityagupta_14737. I'll look through relevant sources and get back to you shortly.
### Answer --- No, dynamic variables cannot be set directly within a prompt during a call. [(1) ]() Dynamic variables are injected at specific points: - **For outbound calls**: Set via the
retell_llm_dynamic_variables
field when using the Create Phone Call API - **For inbound calls**: Set via the inbound webhook response - **Default values**: Configured at the agent level as fallbacks If you need to store or update values during a conversation, the recommended pattern is to use custom functions to manage state—returning data from tool calls that then becomes part of the LLM's context for later use. [(2) ]() You can also capture values at the end of a call using post-call variables in the
call_analyzed
webhook.
​ To learn more, see the sources I considered: [[1] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[2] Discord message from @moetechy_ on 2025-04-18](https://discord.com/channels/1186424376300679209/1294891368505937952/1362827273971175475) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
a
@AI Evy I want a variable to be set in webhook when the call is completed.
a
Thanks for the follow-up, @adityagupta_14737. I'll get back to you soon.
### Answer --- When a call is completed, you can receive data via the call event webhook by subscribing to the
call_ended
or
call_analyzed
event types. [(1) ]() For extracting specific values after a call ends, you have two main options: 1. **Post-Call Analysis Data**: Configure
post_call_analysis_data
on your agent to extract custom variables (string, number, boolean, or enum types) from the call transcript. This data becomes available in the
call_analyzed
webhook event. [(2) ]() 2. **Collected Dynamic Variables**: During the call, if you're using Conversation Flow, variables collected via nodes are available in the
collected_dynamic_variables
field in the webhook payload. [(3) ]() The
call_ended
webhook payload includes fields like
transcript
,
metadata
, and
retell_llm_dynamic_variables
that were set for the call. [(1) ]() Example webhook payload structure:
Copy code
json
{
  "event": "call_ended",
  "call": {
    "metadata": {},
    "retell_llm_dynamic_variables": {
      "customer_name": "John Doe"
    },
    "collected_dynamic_variables": {
      "last_node_name": "Test node"
    }
  }
}
, [(3) ]() If you need custom data extraction after the call, define it in
post_call_analysis_data
when creating or updating your agent—this will be included in the
call_analyzed
webhook. [(2) ]()
​ To learn more, see the sources I considered: [[1] Webhook Overview](https://docs.retellai.com/features/webhook-overview) [[2] Create Voice Agent](https://docs.retellai.com/api-references/create-agent) [[3] Update Call](https://docs.retellai.com/api-references/update-call) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.