https://retellai.com/?utm_source=discord&utm_medium=seo logo
i have made a dynamic variable reason for calling ...
# ❓・ai-evy-support
a
@AI Evy i have made a dynamic variable reason for calling which is small summary of call, i want to extract it for all call and be sent after each call, how to do, it comes empty
a
Thanks for tagging me @ayushsharma5280. I'll look through relevant sources and get back to you shortly.
### Answer Based on the sources, here's how to extract dynamic variables during a call: ## Setting Up Variable Extraction To extract a "reason for calling" variable, you need to add an Extract Dynamic Variable Tool [(1) ]() : 1. Add the tool and configure it with your variable details 2. Set the Variable Name (e.g., "reason_for_calling") 3. Add a Description explaining what this value should be 4. Choose Variable Type - for a summary, use "Text" ## Key Step: Update Your Prompt The critical part is explicitly instructing the agent when to extract the variable . Add something like this to your prompt:
Copy code
When user states his name and phone number, please extract the information by calling the `extract_user_details` function.
For your use case, modify it to trigger extraction at the appropriate time during the call. ## Accessing Extracted Variables After the call ends, extracted variables are available in the
collected_dynamic_variables
object [(2) ]() [(3) ]() [(4) ]() . For example:
Copy code
"collected_dynamic_variables": {
  "last_node_name": "Test node"
}
[(3) ]() If your variable is coming back empty, the most likely issue is that the agent isn't being explicitly told when to call the extraction function in your prompt [(1) ]() . **
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] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[3] Update Call](https://docs.retellai.com/api-references/update-call) [[4] Register Phone Call](https://docs.retellai.com/api-references/register-phone-call) ​