https://retellai.com/?utm_source=discord&utm_medium=seo logo
can retell ai can get a variable (id ) and store i...
# ❓・ai-evy-support
j
@AI Evy can retell ai can get a variable (id ) and store it like an input you give .. or how can we achive that
a
Thanks for tagging me @jhon1212_jhones. I'll look through relevant sources and get back to you shortly.
### Answer --- Yes, Retell AI can get a variable (like an ID) and store it as input. You can achieve this using Dynamic Variables [(1) ]() . ## How to Store and Use Variables ### 1. Pass Variables When Creating a Call When making an outbound call via the API, you can pass variables in the
retell_llm_dynamic_variables
field :
Copy code
json
{
  "user_name": "John Smith",
  "product_name": "Premium Plan",
  "account_status": "active"
}
All values in
retell_llm_dynamic_variables
must be strings . ### 2. Extract Variables During the Call You can extract and store dynamic variables live during the conversation [(2) ]() . Your agent can automatically save information like names, emails, IDs, and preferences . Variable types you can collect include : - Text: Names, addresses, feedback - Numbers: Ages, quantities, prices - Boolean: Yes/no decisions, preferences - Enum: Predefined lists (services, products, etc.) ### 3. Reference Variables in Your Agent Use the
{{variable_name}}
syntax in your prompts, begin messages, tool configurations, and other settings [(1) ]() . For example:
Copy code
"Hello {{user_name}}, I understand you're interested in {{product_name}}. How can I help you today?"
### 4. Retrieve Collected Variables After the call, you can retrieve collected dynamic variables using the Get Call API [(3) ]() . The response includes a
collected_dynamic_variables
field :
Copy code
json
{
  "collected_dynamic_variables": {
    "last_node_name": "Test node"
  }
}
This works in both single, multi-prompt, and conversation flow agents [(2) ]() .
​ To learn more, see the sources I considered: [[1] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[2] Platform Changelogs | Retell AI](https://www.retellai.com/changelog) [[3] 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.
j
i mean if i want to pass a uid form a web hook which i can use for further processes is it possible
@AI Evy i mean if i want to pass a uid form a web hook which i can use for further processes is it possible
a
Thanks for the follow-up, @jhon1212_jhones. I'll get back to you soon.
### Answer --- Yes, you can pass a UID from a webhook and use it in your Retell AI agent for further processes [(1) ]() . ## For Inbound Calls When an inbound call comes in, you can use the Inbound Call Webhook to receive the call notification and return dynamic variables (including your UID) in the response . ### Webhook Response Format Your webhook endpoint should return a response like this :
Copy code
json
{
  "agent_id": "agent_12345",
  "retell_llm_dynamic_variables": {
    "user_id": "uid_67890",
    "customer_name": "John Doe"
  }
}
The
retell_llm_dynamic_variables
field allows you to pass your UID and any other variables you need . ### Setting Up the Webhook Configure the inbound webhook URL when creating or updating your phone number [(2) ]() :
Copy code
json
{
  "inbound_webhook_url": "<https://example.com/inbound-webhook%22>
}
## Using the UID in Your Agent Once passed via the webhook, you can reference the UID throughout your agent using the
{{variable_name}}
syntax [(3) ]() : - In prompts: "Processing request for user {{user_id}}" - In tool configurations and descriptions - In custom function URLs The UID will be available for the entire call session and can be used to trigger actions, look up data, or pass to other systems via tool calls [(3) ]() [(4) ]() . --- **
​ To learn more, see the sources I considered: [[1] Inbound call webhook](https://docs.retellai.com/features/inbound-call-webhook) [[2] Create Phone Number](https://docs.retellai.com/api-references/create-phone-number) [[3] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[4] Webhook](https://www.retellai.com/glossary/webhook) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
j
@AI Evy i am asking to do it while the retell ai is taking in an inbound call during the call a custom functions runs and gives some output along with an id (uid ) lets say 1. nov 3rd 2pm booking for alice 2. 2nd nov 4pm for jhon this text and i want to pass their uid as text in the webhook referencing the first (uid) to the index one booking and (uid2) to index 2 booking so when caller confirms ndex 1,2 i attach it uid as an input to be used by the nect function to cancel or reschedule that exact appoinmnet is it possible and how
a
Thanks for the follow-up, @jhon1212_jhones. I'll get back to you soon.
### Answer Yes, this is possible using Dynamic Variables in Retell AI [(1) ]() . Here's how to achieve your workflow: ## How It Works 1. **Custom Function Returns UIDs**: Your first custom function retrieves bookings and returns them with their UIDs 2. **Store UIDs in Dynamic Variables**: The function response can include UIDs that get stored as dynamic variables 3. **Reference UIDs in Subsequent Functions**: When the caller confirms a booking (e.g., "index 1") , you can use the stored UID in your next function call ## Implementation Approach ### Step 1: Return UIDs from Your First Function When your custom function returns booking data, structure it to include UIDs that can be captured as dynamic variables . ### Step 2: Use Dynamic Variables in Tool Configurations Dynamic variables can be used in custom function URLs and tool descriptions . This means you can reference the UIDs when calling your cancel/reschedule function. For example, if your first function stores
booking_1_uid
and
booking_2_uid
as dynamic variables, you can reference them using the
{{variable_name}}
syntax : -
{{booking_1_uid}}
for the first booking -
{{booking_2_uid}}
for the second booking ### Step 3: Pass UIDs to Your Next Function When the caller confirms which booking to modify, your agent can call the cancel/reschedule function with the appropriate UID using dynamic variables in the tool configuration . ## Key Points - All values in dynamic variables must be strings - Dynamic variables work in tool configurations, custom function URLs, and tool descriptions - The spaces around variable names will be trimmed when evaluating the variable This approach allows you to capture UIDs from one function's response and pass them to subsequent functions during the same call session.
​ 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.