https://retellai.com/?utm_source=discord&utm_medium=seo logo
Is it possible to set a dynamic variable by prompt
# ❓・ai-evy-support
f
@AI Evy Is it possible to set a dynamic variable by prompt?
a
Thanks for tagging me @faizan_53123. I'll look through relevant sources and get back to you shortly.
### Answer --- You cannot directly set a dynamic variable purely through the prompt itself. However, you can use the Extract Dynamic Variables tool to extract values from a user's response during the conversation and save them as dynamic variables. [(1) ]() Here's how it works: 1. Add an Extract Dynamic Variable Tool to your agent 2. Define the variables you want to extract (with name, description, and type: Text, Number, Enum, or Boolean) 3. Update your prompt to instruct the agent when to invoke the extraction function. For example:
Copy code
When user states his name and phone number, please extract the information by calling the `extract_user_details` function.
For setting dynamic variables before a call starts, you would need to: - Use the
retell_llm_dynamic_variables
field in the [Create Phone Call API](/api-references/create-phone-call) for outbound calls [(2) ]() - Supply them via the [Inbound Call Webhook](/features/inbound-call-webhook) for inbound calls - Set default values at the agent level as a fallback
​ To learn more, see the sources I considered: [[1] Extract Dynamic Variables](https://docs.retellai.com/build/single-multi-prompt/extract-dv) [[2] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
f
@AI Evy I want a variable to be set in webhook when the call is completed.
a
Thanks for the follow-up, @faizan_53123. I'll get back to you soon.
### Answer --- Dynamic variables are set before or at the start of a call (via API or inbound webhook) , not when a call ends. [(1) ]() When a call completes, the
call_ended
webhook fires and POSTs the call object to your endpoint, which includes the
retell_llm_dynamic_variables
that were used during the call. [(2) ]() Sample payload structure:
Copy code
json
{
  "event": "call_ended",
  "call": {
    "call_id": "Jabr9TXYYJHfvl6Syypi88rdAHYHmcq6",
    "retell_llm_dynamic_variables": {
      "customer_name": "John Doe"
    },
    "transcript": "...",
    ...
  }
}
If you need to capture values extracted during the call, use the Extract Dynamic Variables tool to save them as dynamic variables, then access them in the
call_ended
or
call_analyzed
webhook payload. [(3) ]() For storing custom data after a call, you would typically: 1. Receive the webhook payload on your server 2. Process and store the relevant data (transcript, extracted variables, metadata) in your own backend/database The webhook itself is for receiving call data, not for setting variables back into Retell after the call ends. [(8) ]()
​ To learn more, see the sources I considered: [[1] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[2] Webhook Overview](https://docs.retellai.com/features/webhook-overview) [[3] Discord message from @simonyost on 2025-04-21](https://discord.com/channels/1186424376300679209/1294891368505937952/1363996589827555379) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
f
@AI Evy What should I do in order to get a call
a
Thanks for the follow-up, @faizan_53123. I'll get back to you soon.
### Answer --- To make or receive a call with Retell AI, here are your options: ### Inbound Calls 1. Buy a phone number in the "Phone Numbers" tab [(1) ]() 2. Assign your agent to that number 3. Dial the purchased number to receive calls ### Outbound Calls Option 1: Dashboard - Click "Make an outbound call" and enter the phone number including country code (e.g.,
+12137774445
) Option 2: SDK/API
Copy code
javascript
const response = await retellClient.call.createPhoneCall({
  from_number: '+14157774444',
  to_number: '+12137774445',
}) ;
[(2) ]() Option 3: Batch Calls - Navigate to the Batch Call tab and click "Create Batch Call" [(3) ]() - Upload a CSV with phone numbers ### Web Calls Use the Web SDK to create browser-based calls:
Copy code
javascript
await retellWebClient.startCall({
  accessToken: createCallResponse.access_token,
}) ;
[(4) ]() Make sure your phone number is properly configured with an
outbound_agent_id
, or use
override_agent_id
in your request. [(9) ]()
​ To learn more, see the sources I considered: [[1] Build your first phone agent in 5 minutes](https://docs.retellai.com/get-started/quick-start) [[2] SDKs](https://docs.retellai.com/get-started/sdk) [[3] Create batch calls](https://docs.retellai.com/deploy/create-batch-call) [[4] Connect to web call](https://docs.retellai.com/deploy/web-call) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
f
@AI Evy What should I do in order to get a dynamic variable in webhooks, which should be set on call completion only
@AI Evy What should I do in order to get a dynamic variable in webhooks, which should be set on call completion only
a
Thanks for the follow-up, @faizan_53123. I'll get back to you soon.
### Answer ### Answer --- Dynamic variables in Retell AI are set before or during a call, not at call completion. [(1) ]() To capture values that are determined during the call and access them in the
call_ended
webhook: 1. Use the Extract Dynamic Variables tool during the conversation to save values extracted from user responses as dynamic variables 2. Receive them in the
call_ended
webhook payload
— the
retell_llm_dynamic_variables
field will contain all dynamic variables that were set or extracted during the call [(2) ]() Sample
call_ended
webhook payload:
Copy code
json
{
  "event": "call_ended",
  "call": {
    "call_id": "Jabr9TXYYJHfvl6Syypi88rdAHYHmcq6",
    "retell_llm_dynamic_variables": {
      "customer_name": "John Doe"
    },
    "transcript": "...",
    ...
  }
}
The webhook is for receiving call data after completion — you cannot set new variables back into Retell via the webhook response. Your server receives the payload, then you process and store the relevant extracted variables in your own backend/database.
​ To learn more, see the sources I considered: [[1] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[2] Webhook Overview](https://docs.retellai.com/features/webhook-overview) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
f
@AI Evy What does 'Extract Dynamic Variable' function do?
a
Thanks for the follow-up, @faizan_53123. I'll get back to you soon.
### Answer The Extract Dynamic Variables tool lets you extract values from a user's response during a conversation and save them as dynamic variables for later use. [(1) ]() How it works: 1. Add an Extract Dynamic Variable Tool to your agent 2. Define variables with: - Variable Name – A short name to reference the variable - Description – A brief explanation of what the value should be - Variable Type – Choose from
Text
,
Number
,
Enum
, or
Boolean
Variable Types available: - Text – Any word or sentence (e.g.,
"headache"
,
"John Smith"
) - Number – A numeric value (e.g.,
42
,
98.6
) - Enum – A value from a predefined list (e.g.,
"Yes"
,
"No"
,
"Maybe"
) - Boolean – True or false What you can do with extracted variables: [(2) ]() - Reference collected data anytime during the call - Pass dynamic variables to webhooks, CRMs, or integrations - Personalize workflows in real time This works in both Single/Multi Prompt agents and Conversation Flow agents.
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
​ To learn more, see the sources I considered: [[1] Extract Dynamic Variables](https://docs.retellai.com/build/single-multi-prompt/extract-dv) [[2] Platform Changelogs | Retell AI](https://www.retellai.com/changelog) ​
f
@AI Evy So Can I use this for my use case? Like I will add Extract Dynamic Variable with some value should be set at the time of call completion? Like before calling end_call
a
Thanks for the follow-up, @faizan_53123. I'll get back to you soon.
### Answer Yes, you can use the Extract Dynamic Variables tool for this use case. Here's how to approach it: 1. Add an Extract Dynamic Variable Tool to your agent with the variables you want to capture 2. Update your prompt to instruct the agent to call the extraction function right before ending the call For example, you could include in your prompt:
Copy code
Before ending the call, extract the relevant information by calling the `extract_call_summary` function.
The extracted values will then be saved as dynamic variables and included in the
retell_llm_dynamic_variables
field of your
call_ended
webhook payload. This way, the values are captured during the call (just before it ends) and are available in your webhook for processing in your backend.
message has been deleted
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
f
@AI Evy Will it be only included in call_ended? Or it will also be included in call_analyzed?
a
Thanks for the follow-up, @faizan_53123. I'll get back to you soon.
### Answer ### Answer The
retell_llm_dynamic_variables
field is included in both
call_ended
and
call_analyzed
webhook events. [(1) ]() The webhook payload contains the call object, which includes the
retell_llm_dynamic_variables
field:
Copy code
json
{
  "event": "call_ended",
  "call": {
    "call_id": "Jabr9TXYYJHfvl6Syypi88rdAHYHmcq6",
    "retell_llm_dynamic_variables": {
      "customer_name": "John Doe"
    },
    ...
  }
}
Since both
call_ended
and
call_analyzed
webhooks POST the call object to your endpoint, and the call object contains
retell_llm_dynamic_variables
, the extracted dynamic variables will be available in both webhook events. The
call_analyzed
webhook is triggered after post-call analysis completes and includes additional fields like
call_analysis
with sentiment, summary, and custom analysis data. [(2) ]() , [(4) ]()
​ To learn more, see the sources I considered: [[1] Webhook Overview](https://docs.retellai.com/features/webhook-overview) [[2] Get Call](https://docs.retellai.com/api-references/get-call) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
f
@AI Evy So my requirement is that at the call completion I want to set a dynamic varible AICallCompleted: true. So how will I do with the help of Extract Dynamic Variable.
a
Thanks for the follow-up, @faizan_53123. I'll get back to you soon.
### Answer To set
AICallCompleted: true
at call completion using the Extract Dynamic Variables tool: 1. Add an Extract Dynamic Variable Tool to your agent with: - Variable Name:
AICallCompleted
- Variable Type:
Boolean
- Description: Set to true when the call is completed [(1) ]() 2. Update your prompt to instruct the agent to call the extraction function right before ending the call. For example:
Copy code
Before ending the call, extract the call completion status by calling the extract function and set AICallCompleted to true.
The extracted
AICallCompleted: true
value will then be included in the
retell_llm_dynamic_variables
field of your
call_ended
and
call_analyzed
webhook payloads. Important: When referencing the variable in your tool description, use the
{{variable_name}}
format to ensure it's properly passed. [(4) ]()
​ To learn more, see the sources I considered: [[1] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
f
@AI Evy WHat do you mean by call completion status in this 'Before ending the call, extract the call completion status by calling the extract function and set AICallCompleted to true.'
a
Thanks for the follow-up, @faizan_53123. I'll get back to you soon.
### Answer --- The phrase "call completion status" in that prompt example was just a suggested way to describe what the extraction should capture—it's not a specific Retell AI term or field. What it means: You're instructing the agent to invoke the Extract Dynamic Variable function at the end of the conversation (before hanging up) and set your
AICallCompleted
variable to
true
. [(1) ]() Since you're using a Boolean variable type, the agent will extract and save
true
as the value for
AICallCompleted
when that function is called. One important note: Retell AI passes dynamic variables as strings, not native booleans. [(2) ]() So when you receive
AICallCompleted
in your webhook, it may come through as the string
"true"
rather than a boolean
true
. Make sure your backend handles this accordingly.
​ To learn more, see the sources I considered: [[1] Extract Dynamic Variables](https://docs.retellai.com/build/single-multi-prompt/extract-dv) [[2] Boolean dynamic variable issue](https://discord.com/channels/1186424376300679209/1381979752394522696) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
Thanks for the follow-up, @faizan_53123. I'll get back to you soon.
f
@AI Evy this is my current prompt : When the intake is completed and the user does not have any further questions, call the function
end_call()
to hang up the call SO can you please update this? my extract Dynamic variable function name is 'call_completion_status' and the variable name is callCompleted.
a
### Answer --- Here's the updated prompt that calls your extract function before ending the call:
Copy code
When the intake is completed and the user does not have any further questions, first call the function `call_completion_status` to set callCompleted to true, then call the function `end_call() ` to hang up the call.
[(1) ]() This ensures the agent extracts and saves the
callCompleted
variable before hanging up, so it will be included in your
call_ended
webhook payload under
retell_llm_dynamic_variables
.
​ To learn more, see the sources I considered: [[1] Extract Dynamic Variables](https://docs.retellai.com/build/single-multi-prompt/extract-dv) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.