https://retellai.com/?utm_source=discord&utm_medium=seo logo
I think my extract dynamic variable it’s not worki...
# ❓・ai-evy-support
k
@AI Evy I think my extract dynamic variable it’s not working, it does not give me the value
a
Thanks for tagging me @K Rudy. I'll look through relevant sources and get back to you shortly.
### Answer There are a few common issues with Extract Dynamic Variables. Here's what to check: 1. Syntax Make sure you're using double curly braces
{{variable_name}}
when referencing the variable—not single braces
{variable_name}
. [(1) ]() 2. Extraction timing The Extract Dynamic Variables tool must run before any function that uses those variables. If you're trying to use the variable in a custom function URL, you need to extract it using the Extract Dynamic Variables tool first—not extract it with the custom function. Variables extracted via a custom function's response go into the body, not the URL. [(2) ]() 3. Prompt guidance It helps to explicitly tell the agent in your prompt when to invoke the extraction. For example: [(3) ]()
Copy code
When user states his name and phone number, please extract the information by calling the `extract_user_details` function.
4. Variable name matching Ensure the variable name in your extraction matches exactly (case-sensitive) what you're using elsewhere. [(2) ]() 5. Testing Try a simple test where your agent just speaks the extracted variable value to confirm it's being captured. [(4) ]() If you can share a call ID, that would help identify exactly where the issue is occurring.
​ To learn more, see the sources I considered: [[1] Issue with Global Variables Not Passing in Query Parameters for Custom Function Tool](https://community.retellai.com/t/issue-with-global-variables-not-passing-in-query-parameters-for-custom-function-tool/773) [[2] Custom function failure to substitute dynamic variable](https://community.retellai.com/t/custom-function-failure-to-substitute-dynamic-variable/231) [[3] Extract Dynamic Variables](https://docs.retellai.com/build/single-multi-prompt/extract-dv) [[4] Dynamic Variables](https://discord.com/channels/1186424376300679209/1356680357084135558) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
k
@AI Evy I was telling my prompt to extrac and account id that was obtained from a cuánto in function result, the data is there, so the problem it’s no the custom function that gathers the data My dynamic variable extract function it’s called extracted_dynamic_variable And the value y set up is {{AccountId}} Which has the same name that the webhook gives you
a
Thanks for the follow-up, @K Rudy. I'll get back to you soon.
### Answer --- Based on your description, there's an important distinction to understand: **The Extract Dynamic Variables tool is designed to extract values from the user's conversation responses, not from custom function results.** [(1) ]() If you want to capture a value like
AccountId
from a custom function's API response, you should use Response Variables within that custom function configuration—not the Extract Dynamic Variables tool. [(2) ]() , [(3) ]() Here's how to do it: 1. In your custom function that returns the
AccountId
, configure Response Variables to extract the value from the API response and save it as a dynamic variable (e.g.,
{{AccountId}}
) . [(2) ]() , [(3) ]() 2. Once saved as a response variable, you can reference it later in the conversation using
{{AccountId}}
. [(2) ]() , [(3) ]() A community thread confirmed this exact issue: when
appointment_id
was extracted using a custom function's response variable (not the Extract Dynamic Variables tool) , it worked correctly for later use. [(4) ]() In summary: Use the Extract Dynamic Variables tool for extracting info the user says during the call. Use Response Variables in your custom function to capture data from API responses. [(1) ]() , [(2) ](
s.retellai.com/build/single-multi-prompt/custom-function) , [(3) ]() If you can share a call ID, I can help verify whether the response variable is being captured correctly.
​ To learn more, see the sources I considered: [[1] Extract Dynamic Variables](https://docs.retellai.com/build/single-multi-prompt/extract-dv) [[2] Integrate any system with custom function](https://docs.retellai.com/build/single-multi-prompt/custom-function) [[3] Custom Function](https://docs.retellai.com/build/conversation-flow/custom-function) [[4] Custom function failure to substitute dynamic variable](https://community.retellai.com/t/custom-function-failure-to-substitute-dynamic-variable/231) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
k
@AI Evy and what if the custom function returns multiple “AccountId” which one will be chosen for the response variable
a
Thanks for the follow-up, @K Rudy. I'll get back to you soon.
### Answer When your API response contains an array with multiple items, you need to specify the index in the JSON path to indicate which one to extract. [(1) ]() For example, if your response looks like:
Copy code
json
{
  "patients": [
    {"AccountId": "123"},
    {"AccountId": "456"}
  ]
}
You would need to use a path like
patients[0].AccountId
to get the first item's AccountId. The response variable configuration requires you to specify the exact path to the value you want. Without an index, the system won't know which element in the array to select. If you need to capture multiple AccountIds, you would need to set up separate response variables for each (e.g.,
patients[0].AccountId
,
patients[1].AccountId
) , or restructure your API response to return a single value based on your business logic.
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] Custom Function API call response not being saved as dynamic variable](https://discord.com/channels/1186424376300679209/1444715331372322917) ​