https://retellai.com/?utm_source=discord&utm_medium=seo logo
How can I retrieve a variable from the conversatio...
# ❓・ai-evy-support
e
@AI Evy How can I retrieve a variable from the conversation and pass it to a custom function?
a
Thanks for tagging me @elisra27. I'll look through relevant sources and get back to you shortly.
### Answer To retrieve a variable from the conversation and pass it to a custom function, you need to use Extract Dynamic Variable Nodes and then reference those variables in your custom function configuration [(1) ]() [(2) ]() . ## Step 1: Extract Variables from Conversation Use the Extract Dynamic Variable Node to capture information from the conversation . This node is specifically "used to extract information from conversation and store them as dynamic variable" [(2) ]() . You cannot extract variables inside Conversation Nodes . When creating an Extract Dynamic Variable Node, define [(1) ]() : - Variable Name – A short reference name - Description – What this value should be - Variable Type – Choose from Text, Number, Enum, or Boolean ## Step 2: Pass Variables to Custom Functions Once extracted, you can pass these variables to custom functions using the
{{variable_name}}
syntax . Dynamic variables can be used in : - Custom function URLs - Request headers [(3) ]() [(4) ]() - Query parameters - Tool descriptions [(1) ]() For example, if you extracted a variable called
user_name
, you can reference it in your custom function's request headers or query parameters as
{{user_name}}
[(3) ]() [(4) ]() [(1) ]()
. ## Step 3: Configure Custom Function When setting up your custom function [(3) ]() [(4) ]() : 1. Set request headers (optional) - Header values can include dynamic variables 2. Set query parameters (optional) - Query parameter values can include dynamic variables 3. Define parameters using JSON schema format (for POST, PATCH, PUT requests) The variables you extracted will be available throughout your conversation flow and can be referenced using the
{{variable_name}}
syntax wherever dynamic variables are supported [(1) ]() .
​ To learn more, see the sources I considered: [[1] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[2] Discord message from @renovia_70920 on 2025-10-30](https://discord.com/channels/1186424376300679209/1186462578310910112/1433525353967652947) [[3] Custom Function](https://docs.retellai.com/build/conversation-flow/custom-function) [[4] Integrate any system with custom function](https://docs.retellai.com/build/single-multi-prompt/custom-function) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
e
@AI Evy When I test this always stay on node extract variable and never pass to next node
a
Thanks for the follow-up, @elisra27. I'll get back to you soon.
### Answer Based on the sources, this is a known issue with Extract Dynamic Variable Nodes getting stuck [(1) ]() [(2) ]() [(3) ]() . Here's how to resolve it: ## Configure Your Transition Condition The Extract Dynamic Variable Node requires a proper transition condition to move to the next node [(1) ]() . You have two main options: Option 1: Use an Equation Condition Set your transition to check if the variable exists : -
{{variable_name}} exists
- Or use a specific value check like
{{company_name}} = "expected_value"
Option 2: Use a Prompt Condition Set a transition like "when the user name is extracted" . ## Common Issues to Avoid Don't make transitions always true - If you set a condition that's always true (like
{{company_name}} = "EllieGrid"
when that's a constant) , the node may transition before the variable is actually extracted . Avoid extracting the same variable multiple times - One user found that "the agent just hangs" when trying to extract the same variable in multiple Extract Variable Nodes [(2) ]() [(3) ]() . They resolved this by consolidating all variable extraction into a single node . ## Best Practices 1. Extract multiple variables in one Extract Dynamic Variable Node rather than creating separate nodes for each variable 2. Use equation-based transitions that check for variable existence rather than prompt-based transitions [(1) ]
() 3. Ensure your transition condition actually waits for the extraction to complete before moving forward If you imported your agent from a sample, try rebuilding from scratch as sample agents can have incorrect configurations . **
​ To learn more, see the sources I considered: [[1] extract variable node transition](https://discord.com/channels/1186424376300679209/1393706083108786357) [[2] Discord message from @q40478 on 2025-10-19](https://discord.com/channels/1186424376300679209/1186462578310910112/1429479310925758515) [[3] Discord message from @q40478 on 2025-10-19](https://discord.com/channels/1186424376300679209/1186462578310910112/1429489660366946414) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.