ayushsharma5280
09/24/2025, 5:08 PMAI Evy
09/24/2025, 5:08 PMAI Evy
09/24/2025, 5:08 PMjson
{
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "The city of the weather"
}
},
"required": [
"city"
]
}
4. In your agent prompts or flows, set or update the dynamic variables so they are available when the function is called. You can also extract dynamic variables from API responses for use later in the conversation [(1) ]() .
5. Test your setup to ensure the variables are being passed and replaced correctly in the function call [(2) ]() .
If you need to use a dynamic variable in a URL, header, or parameter, just use the {{variable_name}} format in the configuration [(2) ]() [(1) ]() .AI Evy
09/24/2025, 5:08 PMAI Evy
09/24/2025, 5:08 PMayushsharma5280
09/24/2025, 5:33 PMayushsharma5280
09/24/2025, 5:33 PMAI Evy
09/24/2025, 5:33 PMAI Evy
09/24/2025, 5:33 PMAI Evy
09/24/2025, 5:33 PMAI Evy
09/24/2025, 5:33 PMayushsharma5280
09/24/2025, 5:36 PMAI Evy
09/24/2025, 5:36 PMAI Evy
09/24/2025, 5:36 PMAI Evy
09/24/2025, 5:36 PMAI Evy
09/24/2025, 5:36 PMjavascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const conversationFlowResponse = await client.conversationFlow.retrieve('conversation_flow_id') ;
console.log(conversationFlowResponse.conversation_flow_id) ;
[(3) ]()
For a full example of the flow structure:
json
{
"global_prompt": "You are a helpful customer service agent.",
"tools": [
{
"type": "custom",
"name": "get_customer_info",
"description": "Get customer information from database",
"tool_id": "tool_001",
"url": "<https://api.example.com/customer%22,>
"method": "GET"
}
],
"start_node_id": "start",
"nodes": [
{
"id": "start",
"type": "conversation",
"instruction": {
"type": "prompt",
"text": "Greet the customer and ask how you can help them."
},
"edges": [
{
"id": "edge_1",
"transition_condition": {
"type": "prompt",
"prompt": "Customer wants to book appointment"
},
"destination_node_id": "book_appointment"
}
]
}
],
"conversation_flow_id": "<string>",
"version": 123
}
, [(4) ]()
For more details, see:
- [Conversation Flow Overview]()
- [Get Conversation Flow]()
- [Retell AI’s Advanced Conversation Flow | Retell AI]()AI Evy
09/24/2025, 5:36 PMAI Evy
09/24/2025, 5:36 PMayushsharma5280
09/25/2025, 7:11 AMAI Evy
09/25/2025, 7:11 AMAI Evy
09/25/2025, 7:11 AMAI Evy
09/25/2025, 7:11 AMAI Evy
09/25/2025, 7:11 AMayushsharma5280
09/26/2025, 1:33 PMAI Evy
09/26/2025, 1:33 PMAI Evy
09/26/2025, 1:33 PMAI Evy
09/26/2025, 1:33 PMAI Evy
09/26/2025, 1:33 PMayushsharma5280
09/26/2025, 1:34 PMAI Evy
09/26/2025, 1:34 PMAI Evy
09/26/2025, 1:34 PMAI Evy
09/26/2025, 1:34 PMAI Evy
09/26/2025, 1:35 PMAI Evy
09/26/2025, 1:35 PMayushsharma5280
09/26/2025, 1:37 PMAI Evy
09/26/2025, 1:37 PMAI Evy
09/26/2025, 1:38 PMAI Evy
09/26/2025, 1:38 PMAI Evy
09/26/2025, 1:38 PMayushsharma5280
09/26/2025, 1:38 PMAI Evy
09/26/2025, 1:38 PMAI Evy
09/26/2025, 1:38 PMAuthorization: Bearer {{user_token}})
- Passing user IDs, organization IDs, or other identifiers (X-User-ID: {{user_id}})
- Custom metadata that your backend expects for logging, routing, or personalization
The value in the header will be replaced with the current value of the dynamic variable at runtime, so you can flexibly support scenarios beyond just authentication if needed [(1) ]() [(2) ]() [(3) ]() .AI Evy
09/26/2025, 1:38 PMAI Evy
09/26/2025, 1:38 PMayushsharma5280
09/26/2025, 2:14 PMAI Evy
09/26/2025, 2:14 PMAI Evy
09/26/2025, 2:14 PMjson
{
"type": "object",
"properties": {
"example": {
"type": "string",
"description": "A description of the example"
}
},
"required": ["example"]
}
If you set a property to a static value like 123, but do not provide a description, or if you do not use the correct JSON schema structure (including "type": "object" at the top level and proper descriptions) , the function will not save or work properly. Make sure every property in your schema has a description string, even for static values [(1) ]() .AI Evy
09/26/2025, 2:14 PMAI Evy
09/26/2025, 2:14 PMayushsharma5280
10/09/2025, 4:44 AMAI Evy
10/09/2025, 4:44 AMAI Evy
10/09/2025, 4:44 AMAI Evy
10/09/2025, 4:44 AMAI Evy
10/09/2025, 4:44 AMAI Evy
10/09/2025, 4:44 AMayushsharma5280
10/09/2025, 4:46 AMAI Evy
10/09/2025, 4:46 AMAI Evy
10/09/2025, 4:47 AMjavascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const llmResponse = await client.llm.create() ;
console.log(llmResponse.llm_id) ;
Configure your LLM with dynamic variables and structured prompts :
json
{
"general_prompt": "You are ...",
"begin_message": "Hey I am a virtual assistant calling from Retell Hospital.",
"default_dynamic_variables": {
"customer_name": "John Doe"
}
}
## 2. Structure Your Prompt with Sectional Design
Use sectional prompts for better organization [(2) ]() :
///## Identity
You are a friendly AI assistant for [Company Name].
Your role is to [specific purpose].
You have expertise in [relevant domains].
///## Style Guardrails
Be concise: Keep responses under 2 sentences unless explaining complex topics.
Be conversational: Use natural language, contractions, and acknowledge what the caller says.
Be empathetic: Show understanding for the caller's situation.
///## Response Guidelines
Return dates in spoken form: Say "January fifteenth" not "1/15".
Ask one question at a time: Avoid overwhelming the caller with multiple questions.
Confirm understanding: Paraphrase important information back to the caller.AI Evy
10/09/2025, 4:47 AM{{current_time}} | Current time in America/Los_Angeles | "Thursday, March 28, 2024 at 11:46:04 PM PST" |
| {{user_number}} | User's phone number | +12137771234 |
| {{call_id}} | Current call session id | call_12345678906eaa0222bd3dd2a6c |
| {{direction}} | Call direction | inbound or outbound |
## 6. Handling Missing Variables
When variables aren't provided, they remain as raw text :
- Prompt: "Hello {{user_name}}, how can I help you today?"
- If user_name not provided: "Hello {{user_name}}, how can I help you today?"
- If user_name is "John": "Hello John, how can I help you today?"
## 7. Important Constraints
All dynamic variable values must be strings . Numbers, booleans, or other data types are not supported .
For outbound calls, you can supply dynamic variables through the Inbound Call Webhook or directly in the Create Phone Call API .
This flow ensures proper integration of dynamic variables with custom actions while maintaining the structured approach recommended by Retell AI.AI Evy
10/09/2025, 4:47 AM"Hello {{user_name}}, I understand you're interested in {{product_name}}. How can I help you today?"
## 4. Making Outbound Calls with Dynamic Variables
When creating phone calls, pass dynamic variables in the API request [(4) ]() :
javascript
const phoneCallResponse = await client.call.createPhoneCall({
from_number: '+14157774444',
to_number: '+12137774445',
}) ;
console.log(phoneCallResponse.agent_id) ;
Include dynamic variables in the request body :
json
{
"retell_llm_dynamic_variables": {
"customer_name": "John Doe"
}
}AI Evy
10/09/2025, 4:47 AMAI Evy
10/09/2025, 4:47 AMayushsharma5280
10/09/2025, 5:15 AMAI Evy
10/09/2025, 5:15 AMAI Evy
10/09/2025, 5:16 AM///## Dynamic Variables
Available variables:
- {{customer_name}}: Customer's full name (fallback: "valued customer")
- {{order_id}}: Current order number (fallback: ask for order details)
- {{appointment_date}}: Scheduled appointment date (fallback: check calendar)
- {{department}}: Target department for transfer (fallback: general support)
Variable handling rules:
- If a variable shows as {{variable_name}}, it wasn't provided - use the fallback approach
- Always confirm variable values with the customer before proceeding
- For missing critical variables, politely ask the customer to provide the information
## Default Behavior for Missing Variables
When dynamic variables aren't provided, they remain as raw text in the format {{variable_name}} [(1) ]() . You can set default values at the agent level, which serve as fallbacks when specific variables aren't included in the call request .
## Best Practices for Variable Handling
**In Prompts**: Check for unset variables by instructing the agent to recognize when variables appear as {{variable_name}} and handle them appropriately .
**Default System Variables**: Retell automatically provides system variables like {{current_time}}, {{current_agent_state}}, and {{session_duration}} that don't require configuration .
**Variable Requirements**: All values in retell_llm_dynamic_variables must be strings - numbers, booleans, or other data types are not supported .
This approach ensures your agent gracefully handles both provided and missing variables while maintaining a natural conversation flow.AI Evy
10/09/2025, 5:16 AMAI Evy
10/09/2025, 5:16 AMayushsharma5280
10/09/2025, 5:18 AMAI Evy
10/09/2025, 5:18 AMAI Evy
10/09/2025, 5:18 AM///## Dynamic Variables
Available variables and fallback handling:
- {{user_id}}: Customer's unique identifier (fallback: use "1" as default user ID)
- {{order_id}}: Current order reference number (fallback: use "123" as default order ID)
- {{first_name}}: Customer's first name (fallback: use "there" to address customer)
- {{last_name}}: Customer's last name (fallback: ask "Could you please provide your last name for verification?")
Variable handling rules:
- If a variable appears as {{variable_name}}, it wasn't provided - apply the specified fallback
- For critical missing information like {{last_name}}, politely request it from the customer
- Use fallback values for non-critical variables to maintain conversation flow
- Always confirm important details with the customer before proceeding with actions
Example responses:
- If {{first_name}} is missing: "Hello there, how can I help you today?"
- If {{last_name}} is missing: "Hi {{first_name}}, could you please provide your last name for verification?"
- If {{order_id}} is missing: "I'll help you with order 123, or please provide your specific order number"
This approach follows Retell AI's default behavior where unset variables remain in their raw {{variable_name}} format, allowing you to detect and handle them appropriately [(1) ]() . You can also set default values at the agent level using the default_dynamic_variables field, which serve as fallbacks when specific variables aren't included in the call request .
Remember that all dynamic variable values must be strings - numbers, booleans, or other data types are not supported .AI Evy
10/09/2025, 5:18 AMAI Evy
10/09/2025, 5:18 AMayushsharma5280
10/09/2025, 5:24 AMAI Evy
10/09/2025, 5:24 AMAI Evy
10/09/2025, 5:24 AM///## Dynamic Variables
Available variables and fallback handling:
- {{user_id}}: Customer's unique identifier (fallback: use "1" as user ID)
- {{order_id}}: Current order reference number (fallback: use "123" as order ID)
- {{first_name}}: Customer's first name (fallback: use "there" as First Name)
- {{last_name}}: Customer's last name (fallback: Not provided)
## Key Issues with Your Original Format:
1. **Missing line breaks**: Your variables are all on one line, which makes it harder to read [(1) ]()
2. **Missing bullet points**: Adding dashes or bullets improves readability [(2) ]()
3. **Spacing inconsistency**: Some variables have extra spaces [(3) ]()
## Important Considerations:
**Variable Syntax**: Make sure there are no extra spaces in your variable names - {{user_id}} works but {{ user_id }} doesn't
**Default Behavior**: When dynamic variables aren't provided, they remain as raw text like {{variable_name}} [(1) ]() . Your fallback instructions help the agent recognize this and respond appropriately
**String Values Only**: All dynamic variable values must be strings - numbers, booleans, or other data types are not supported
Your approach of defining fallbacks in the prompt is good practice for handling missing variables gracefully while maintaining conversation flow .AI Evy
10/09/2025, 5:24 AMAI Evy
10/09/2025, 5:24 AMayushsharma5280
10/09/2025, 5:27 AMAI Evy
10/09/2025, 5:27 AMAI Evy
10/09/2025, 5:27 AM///## Variable Handling Rules:
- If a variable appears as {{variable_name}}, it wasn't provided - apply the specified fallback
- For critical missing variables, politely request it from the customer
- Use fallback values for variables if actual not present to maintain conversation flow
- Always confirm important details with the customer before proceeding with actions
## Why This Approach Works Well:
**Default Behavior Recognition**: When dynamic variables aren't provided, they remain as raw text in the {{variable_name}} format, which your rules correctly identify [(1) ]() .
**Fallback Strategy**: Your approach of using fallbacks for non-critical variables while requesting critical ones maintains natural conversation flow .
**Confirmation Protocol**: Always confirming important details before actions is a best practice that prevents errors .
## Additional Considerations:
**Nested Variables**: You can also use nested variables like {{user.name}} if your data structure supports it .
**System Variables**: Remember that Retell provides automatic system variables like {{current_time}} and {{call_id}} that don't require fallback handling .
**String Requirement**: All dynamic variable values must be strings - numbers, booleans, or other data types are not supported .
Your rules provide a comprehensive framework for graceful variable handling while maintaining conversational quality.AI Evy
10/09/2025, 5:27 AMAI Evy
10/09/2025, 5:27 AMayushsharma5280
10/09/2025, 5:35 AMAI Evy
10/09/2025, 5:35 AMAI Evy
10/09/2025, 5:35 AMAI Evy
10/09/2025, 5:35 AM///## Custom Functions & Dynamic Variable Management
### Available Custom Functions:
1. get_user_details: Retrieves user information based on name and ID
- Method: POST
- Parameters: {"name": "string", "user_id": "string"}
- Response Variables: Extract user_name, user_email, user_status
- When to call: When user provides their name or ID for lookup
2. check_order_status: Checks current order information
- Method: GET
- Query Parameters: order_id={{order_id}}
- Response Variables: Extract order_status, delivery_date, tracking_number
- When to call: When user asks about order status or provides order number
3. extract_user_details: Captures user information from conversation
- Type: Extract Dynamic Variable Tool
- Variables: user_name (Text) , phone_number (Text) , preferred_time (Text)
- When to call: When user states their name and phone number
### Function Execution Flow:
1. EXTRACT FIRST: Use extract_user_details when user provides personal information
2. PROCESS NEXT: Use extracted variables in subsequent custom function calls
3. CONFIRM ALWAYS: Verify extracted information before proceeding
### Custom Function Handling Rules:
- Call extract_user_details BEFORE calling other functions that need user data
- Use {{variable_name}} syntax in query parameters and headers
- For POST/PATCH/PUT: Include variables in request body parameters
- For GET/DELETE: Use variables in URL, headers, and query parameters only
- Always speak during execution for user-facing actions
- Always speak after execution to continue conversation flow
### Response Variable Extraction:
- Extract key data from API responses using Response Variables section
- Save extracted data as dynamic variables for later use
- Use format: variable_name -> response.path.to.value
- Example: user_email -> data.user.email
### Error Handling:
- If function call failAI Evy
10/09/2025, 5:35 AMs, apologize and ask user to try again
- If required variables are missing, use extract_user_details first
- If API returns error, explain the issue and offer alternatives
- Always maintain conversation flow even during errors
### Variable Usage in Functions:
- Headers: Authorization: Bearer {{auth_token}}
- Query Params: ?user_id={{user_id}}&status={{order_status}}
- Request Body: {"customer_name": "{{user_name}}", "phone": "{{phone_number}}"}
- URLs: Avoid path variables like /users/{{user_id}} - use query params insteadAI Evy
10/09/2025, 5:35 AM{{user_name}} .
**Request Specifications**: Retell sends requests with specific headers including X-Retell-Signature for verification, and the request body includes the function name, call object, and arguments .
**Variable Parsing Limitations**: Be aware that dynamic variables in path parameters may not parse correctly [(5) ]() . It's recommended to use query parameters instead of path variables for dynamic dAI Evy
10/09/2025, 5:35 AMAI Evy
10/09/2025, 5:35 AM