tabrza
09/12/2025, 7:56 AMAI Evy
09/12/2025, 7:56 AMAI Evy
09/12/2025, 7:56 AMAI Evy
09/12/2025, 7:56 AMAI Evy
09/12/2025, 7:56 AMtabrza
09/12/2025, 7:58 AMAI Evy
09/12/2025, 7:58 AMAI Evy
09/12/2025, 7:58 AMAI Evy
09/12/2025, 7:58 AMAI Evy
09/12/2025, 7:58 AMtabrza
09/12/2025, 8:00 AMAI Evy
09/12/2025, 8:00 AMAI Evy
09/12/2025, 8:01 AMAI Evy
09/12/2025, 8:01 AMAI Evy
09/12/2025, 8:01 AMtabrza
09/12/2025, 8:01 AMtabrza
09/12/2025, 8:01 AMAI Evy
09/12/2025, 8:01 AMAI Evy
09/12/2025, 8:02 AM{{product_count}} and {{product_list}} that get populated from your POST request response.
2. Structured Prompt Engineering
Include the product information directly in your agent's prompt or first message. For example:
- "You have {{product_count}} products to provide updates on: {{product_details}}"
- This gives the agent immediate context about the scope of work
3. Function/Tool Integration
Create a custom function that:
- Processes your POST request response
- Counts the products requiring updates
- Returns structured data the agent can understand
- Allows the agent to iterate through products systematically
4. Conversation Flow Logic
Use a Logic Split Node to handle different scenarios:
- Single product update path
- Multiple product update path with looping logic
- Different handling based on product count thresholds
5. Context Management
Structure your conversation to:
- First establish the total number of products
- Then systematically work through each one
- Track progress ("Product 2 of 5 completed")
- Summarize at the end
The key is making the product count and details available to the agent early in the conversation flow, either through dynamic variables, structured prompts, or custom functions that process your API response data.AI Evy
09/12/2025, 8:02 AMAI Evy
09/12/2025, 8:02 AMtabrza
09/12/2025, 8:06 AMAI Evy
09/12/2025, 8:06 AMAI Evy
09/12/2025, 8:06 AM## Tool Usage Instructions
1. After collecting update details for each shipment:
→ Call function `shipment_update` with the captured information
2. When moving to next shipment:
→ First confirm current shipment details are complete
→ Then proceed to next shipment using dynamic variables
2. Clearer boundaries - Specify when NOT to call certain tools:
- Don't call shipment_update until all required details are captured
- Don't transition until all shipments are processed
3. Enhanced transition conditions - Your transition logic is good, but consider being more specific:
- "If caller explicitly states 'no updates' for remaining shipments → transition to fallback"
- "If caller asks questions about company policies → transition to faq"
The use of dynamic variables for handling multiple shipments aligns well with how conversation nodes can handle multi-turn conversations within a single node [(2) ]() . Your approach of systematically working through each shipment using the example dialogue is effective for maintaining context throughout the interaction.AI Evy
09/12/2025, 8:06 AMAI Evy
09/12/2025, 8:06 AMtabrza
09/12/2025, 8:09 AMAI Evy
09/12/2025, 8:09 AMAI Evy
09/12/2025, 8:09 AMYou are a logistics coordinator assistant for {{company_name}}. You're speaking with {{coordinator_name}} to collect status updates for {{shipment_count}} shipments.
## Your Task
Systematically collect updates for ALL {{shipment_count}} shipments before calling any functions. Work through each shipment one by one and gather the following details:
- Current status (e.g., in transit, delayed, delivered, pending pickup)
- Estimated Time of Arrival (ETA) or Estimated Time of Departure (ETD) if mentioned
- Any obstacles or issues encountered
- Additional notes or updates
- Preference for email-only communication (log this but do not push to email)
## Conversation Flow
1. Start with: "Hi {{coordinator_name}}, I'm calling to get status updates on your {{shipment_count}} shipments. Let's start with shipment {{shipments.0.shipment_number}} going from {{shipments.0.origin}} to {{shipments.0.destination}}. What's the current status?"
2. For subsequent shipments: "Thank you for that update. Now let's move to shipment {{shipments.1.shipment_number}} from {{shipments.1.origin}} to {{shipments.1.destination}}. Could you share the current status of this shipment as well?"
3. Continue this pattern for all shipments using the appropriate array indices.
## Function Calling Rules
- ONLY call `shipment_update` function AFTER you have collected updates for ALL {{shipment_count}} shipments
- Do NOT call the function after each individual shipment
- Before calling the function, confirm: "I've collected updates for all {{shipment_count}} shipments. Let me process this information now."
## Transition Conditions
- If caller asks general questions about {{company_name}} → transition to faq
- If caller is upset, confused, asks for human, or states they have no updates for remaining shipments → transition to fallback
- If all shipment updates are collected and function is called → proAI Evy
09/12/2025, 8:09 AMceed with call completion
## Important Notes
- Keep track of which shipments you've covered (1 of {{shipment_count}}, 2 of {{shipment_count}}, etc.)
- Be patient and thorough - don't rush through the collection process
- Confirm details if unclear before moving to the next shipmentAI Evy
09/12/2025, 8:09 AMAI Evy
09/12/2025, 8:09 AMtabrza
09/12/2025, 8:12 AMAI Evy
09/12/2025, 8:12 AMAI Evy
09/12/2025, 8:13 AM{{shipments.0.shipment_number}} is not the standard way Retell AI handles arrays of data [(1) ]() .
Based on the dynamic variables documentation, Retell AI dynamic variables work with simple key-value pairs where all values must be strings . The {{variable_name}} syntax is for individual variables, not array indexing .
From the Discord discussion, there's evidence that accessing nested object properties requires the correct syntax. One user found that to access array elements, they needed to use data.locations[0].id rather than locations[0].id [(2) ]() .
For your shipment array, you would need to flatten the data structure or pass individual variables. Instead of trying to access {{shipments.0.shipment_number}}, you should structure your dynamic variables like:
{
"shipment_count": "3",
"shipment_1_number": "SHP-1001",
"shipment_1_origin": "New York, USA",
"shipment_1_destination": "Hamburg, Germany",
"shipment_2_number": "SHP-1002",
"shipment_2_origin": "Los Angeles, USA",
"shipment_2_destination": "Tokyo, Japan",
"shipment_3_number": "SHP-1010",
"shipment_3_origin": "Rotterdam, Netherlands",
"shipment_3_destination": "Dubai, UAE"
}
[(1) ]()
Then in your prompt, you would reference these as {{shipment_1_number}}, {{shipment_2_number}}, etc. .
The agent won't automatically iterate through array indices - you need to explicitly provide each piece of data as separate dynamic variables with string values .AI Evy
09/12/2025, 8:13 AMAI Evy
09/12/2025, 8:13 AMtabrza
09/12/2025, 8:14 AMAI Evy
09/12/2025, 8:14 AMAI Evy
09/12/2025, 8:15 AMYou are a logistics coordinator assistant for {{company_name}}. You're speaking with {{coordinator_name}} to collect status updates for {{shipment_count}} shipments.
## Your Task
Systematically collect updates for ALL {{shipment_count}} shipments before calling any functions. For each shipment, gather:
- Current status (e.g., in transit, delayed, delivered, pending pickup)
- Estimated Time of Arrival (ETA) or Estimated Time of Departure (ETD) if mentioned
- Any obstacles or issues encountered
- Additional notes or updates
- Preference for email-only communication (log this but do not push to email)
## Conversation Flow
Start by asking about the first shipment and work through each one systematically. Use the shipment details provided in your context to reference each shipment by number, origin, and destination.
Example opening: "Hi {{coordinator_name}}, I'm calling to get status updates on your {{shipment_count}} shipments. Let's start with the first one - could you share the current status?"
Continue through all shipments, keeping track of progress: "That's shipment 1 of {{shipment_count}} complete. Now for the next shipment..."
## Function Calling Rules
- ONLY call `shipment_update` function AFTER you have collected updates for ALL {{shipment_count}} shipments
- Do NOT call the function after each individual shipment
- Before calling the function, confirm: "I've collected updates for all {{shipment_count}} shipments. Let me process this information now."
## Transition Conditions
- If caller asks general questions about {{company_name}} → transition to faq
- If caller is upset, confused, asks for human, or states they have no updates → transition to fallback
## Updated POST Request Structure
Since dynamic variables must be strings , flatten your shipment data:AI Evy
09/12/2025, 8:15 AMjson
{
"retell_llm_dynamic_variables": {
"coordinator_name": "John Doe",
"company_name": "Movd Logistics",
"shipment_count": "3",
"shipment_details": "Shipment SHP-1001 from New York, USA to Hamburg, Germany; Shipment SHP-1002 from Los Angeles, USA to Tokyo, Japan; Shipment SHP-1010 from Rotterdam, Netherlands to Dubai, UAE"
},
"from_number": "",
"to_number": ""
}
Alternatively, you can use a custom function to handle the array processing [(2) ]() . Create a function that receives the shipment array and processes it within the function logic, rather than trying to pass complex objects through dynamic variables.
The agent will need to rely on the LLM's ability to parse the shipment details from the flattened string format, as Retell AI doesn't support direct array indexing in dynamic variables [(1) ]() .AI Evy
09/12/2025, 8:15 AMAI Evy
09/12/2025, 8:15 AMtabrza
09/12/2025, 8:19 AMAI Evy
09/12/2025, 8:19 AMAI Evy
09/12/2025, 8:19 AMget_shipment_details
Description: Retrieve shipment details for the coordinator to provide updates on
HTTP Method: POST [(2) ]()
Endpoint URL: Your endpoint (e.g., `
Parameters Schema:
json
{
"type": "object",
"properties": {},
"required": []
}
## Updated PromptAI Evy
09/12/2025, 8:19 AMYou are a logistics coordinator assistant for {{company_name}}. You're speaking with {{coordinator_name}} to collect status updates on shipments.
## Your Task
1. First, call the get_shipment_details function to retrieve the shipment information
2. Once you have the shipment details, systematically collect updates for ALL shipments before calling the shipment_update function
3. For each shipment, gather:
- Current status (e.g., in transit, delayed, delivered, pending pickup)
- Estimated Time of Arrival (ETA) or Estimated Time of Departure (ETD) if mentioned
- Any obstacles or issues encountered
- Additional notes or updates
- Preference for email-only communication (log this but do not push to email)
## Conversation Flow
1. Start by calling get_shipment_details function
2. Use the returned shipment information to ask about each shipment systematically
3. Example: "Hi {{coordinator_name}}, I'm calling to get status updates. I see we have [number] shipments to review. Let's start with shipment [number] going from [origin] to [destination]. What's the current status?"
## Function Calling Rules
- Call get_shipment_details FIRST to retrieve shipment information
- ONLY call shipment_update function AFTER collecting updates for ALL shipments
- Before calling shipment_update, confirm: "I've collected updates for all shipments. Let me process this information now."
## Transition Conditions
- If caller asks general questions about {{company_name}} → transition to faq
- If caller is upset, confused, asks for human, or states they have no updates → transition to fallbackAI Evy
09/12/2025, 8:19 AMcall object [(2) ]() [(1) ]() :
json
{
"override_agent_id": "",
"from_number": "",
"to_number": "",
"coordinator_name": "John Doe",
"company_name": "Movd Logistics",
"shipment_count": 3,
"shipments": [...]
}
## Custom Function Implementation
Your endpoint will receive a request with this structure :
json
{
"name": "get_shipment_details",
"call": {
// Contains your full call context including the shipment data
},
"args": {}
}
The function should return a string containing the formatted shipment details that the agent can use to systematically work through each shipment .AI Evy
09/12/2025, 8:20 AMAI Evy
09/12/2025, 8:20 AMtabrza
09/12/2025, 8:21 AMAI Evy
09/12/2025, 8:21 AMAI Evy
09/12/2025, 8:22 AMshipment_count and shipments array . Your custom function endpoint will receive:
json
{
"name": "get_shipment_details",
"call": {
// Contains your shipment_count: 3 and shipments array
},
"args": {}
}
The custom function should return a formatted string that includes the shipment count information . For example, your function could return:
"You have 3 shipments to collect updates for:
1. Shipment SHP-1001 from New York, USA to Hamburg, Germany
2. Shipment SHP-1002 from Los Angeles, USA to Tokyo, Japan
3. Shipment SHP-1010 from Rotterdam, Netherlands to Dubai, UAE"
This response gets converted to a string and sent to the LLM for processing . The agent will then understand both the quantity (3 shipments) and the details of each shipment to systematically work through them.
You can also set response variables in your custom function configuration to extract specific values like shipment count and save them as dynamic variables for use throughout the conversation .AI Evy
09/12/2025, 8:22 AMAI Evy
09/12/2025, 8:22 AMtabrza
09/12/2025, 8:23 AMAI Evy
09/12/2025, 8:23 AMAI Evy
09/12/2025, 8:23 AMjavascript
import { Retell } from "retell-sdk";
this.app.post("/get-shipment-details", async (req: Request, res: Response) => {
// Verify request is from Retell
if (
!Retell.verify(
JSON.stringify(req.body) ,
process.env.RETELL_API_KEY,
req.headers["x-retell-signature"] as string,
)
) {
console.error("Invalid signature") ;
return;
}
const content = req.body;
// Extract shipment data from the call context
const shipmentCount = content.call.shipment_count;
const shipments = content.call.shipments;
// Format response for the agent
let response = `You have ${shipmentCount} shipments to collect updates for:\n`;
shipments.forEach((shipment, index) => {
response += `${index + 1}. Shipment ${shipment.shipment_number} from ${shipment.origin} to ${shipment.destination}\n`;
}) ;
return res.json(response) ;
}) ;
## Python AlternativeAI Evy
09/12/2025, 8:23 AMpython
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
from retell import Retell
import json
import os
retell = Retell(api_key=os.environ["RETELL_API_KEY"])
@app.post("/get-shipment-details")
async def get_shipment_details(request: Request) :
try:
post_data = await request.json()
valid_signature = retell.verify(
json.dumps(post_data, separators=(",", ":") , ensure_ascii=False) ,
api_key=str(os.environ["RETELL_API_KEY"]) ,
signature=str(request.headers.get("X-Retell-Signature") ) ,
)
if not valid_signature:
print("Received Unauthorized")
return
# Extract shipment data from call context
shipment_count = post_data["call"]["shipment_count"]
shipments = post_data["call"]["shipments"]
# Format response for agent
response = f"You have {shipment_count} shipments to collect updates for:\n"
for i, shipment in enumerate(shipments, 1) :
response += f"{i}. Shipment {shipment['shipment_number']} from {shipment['origin']} to {shipment['destination']}\n"
return JSONResponse(content=response)
except Exception as e:
print(f"Error: {e}")
return JSONResponse(content="Error processing request", status_code=500)
The algorithm extracts the shipment data from the call context and formats it into a readable string that tells the agent exactly how many shipments there are and their details . The response is capped at 15000 characters and gets converted to string before sending to the LLM .AI Evy
09/12/2025, 8:23 AMAI Evy
09/12/2025, 8:23 AMtabrza
09/12/2025, 9:08 AMAI Evy
09/12/2025, 9:08 AMAI Evy
09/12/2025, 9:08 AMjson
{
"from_number": "+1234567890",
"to_number": "+0987654321",
"override_agent_id": "your-agent-id",
"retell_llm_dynamic_variables": {
"coordinator_name": "John Doe",
"company_name": "Movd Logistics",
"shipment_count": "3",
"shipment_1_number": "SHP-1001",
"shipment_1_origin": "New York, USA",
"shipment_1_destination": "Hamburg, Germany",
"shipment_2_number": "SHP-1002",
"shipment_2_origin": "Los Angeles, USA",
"shipment_2_destination": "Tokyo, Japan",
"shipment_3_number": "SHP-1010",
"shipment_3_origin": "Rotterdam, Netherlands",
"shipment_3_destination": "Dubai, UAE"
}
}
Key Requirements:
- All values in retell_llm_dynamic_variables must be strings
- Use the flattened structure since Retell AI doesn't support array indexing in dynamic variables
- The retell_llm_dynamic_variables field is required when using dynamic variables [(2) ]()
Updated Prompt:AI Evy
09/12/2025, 9:08 AMYou are a logistics coordinator assistant for {{company_name}}. You're speaking with {{coordinator_name}} to collect status updates for {{shipment_count}} shipments.
## Your Task
Systematically collect updates for ALL {{shipment_count}} shipments before calling any functions. For each shipment, gather:
- Current status (e.g., in transit, delayed, delivered, pending pickup)
- Estimated Time of Arrival (ETA) or Estimated Time of Departure (ETD) if mentioned
- Any obstacles or issues encountered
- Additional notes or updates
- Preference for email-only communication (log this but do not push to email)
## Conversation Flow
Work through each shipment systematically:
1. "Hi {{coordinator_name}}, I'm calling to get status updates on your {{shipment_count}} shipments. Let's start with shipment {{shipment_1_number}} going from {{shipment_1_origin}} to {{shipment_1_destination}}. What's the current status?"
2. "Thank you for that update. Now let's move to shipment {{shipment_2_number}} from {{shipment_2_origin}} to {{shipment_2_destination}}. Could you share the current status of this shipment as well?"
3. Continue this pattern for all shipments: {{shipment_3_number}}, {{shipment_3_origin}}, {{shipment_3_destination}}, etc.
## Function Calling Rules
- ONLY call `shipment_update` function AFTER you have collected updates for ALL {{shipment_count}} shipments
- Do NOT call the function after each individual shipment
- Before calling the function, confirm: "I've collected updates for all {{shipment_count}} shipments. Let me process this information now."
## Transition Conditions
- If caller asks general questions about {{company_name}} → transition to faq
- If caller is upset, confused, asks for human, or states they have no updates → transition to fallbackAI Evy
09/12/2025, 9:09 AMAI Evy
09/12/2025, 9:09 AMtabrza
09/12/2025, 9:46 AMtabrza
09/12/2025, 9:46 AMAI Evy
09/12/2025, 9:46 AMAI Evy
09/12/2025, 9:47 AMshipment_update custom function, here's what the request structure will look like when Retell calls your endpoint [(1) ]() [(2) ]() :
## Custom Function Request Structure
When the agent calls your shipment_update function, Retell will send a POST request with this structure [(1) ]() :
json
{
"name": "shipment_update",
"call": {
"call_id": "...",
"from_number": "...",
"to_number": "...",
"retell_llm_dynamic_variables": {
"coordinator_name": "John Doe",
"company_name": "Movd Logistics",
"shipment_count": "3",
"shipment_1_number": "SHP-1001",
"shipment_1_origin": "New York, USA",
"shipment_1_destination": "Hamburg, Germany",
"shipment_2_number": "SHP-1002",
"shipment_2_origin": "Los Angeles, USA",
"shipment_2_destination": "Tokyo, Japan",
"shipment_3_number": "SHP-1010",
"shipment_3_origin": "Rotterdam, Netherlands",
"shipment_3_destination": "Dubai, UAE"
}
},
"args": {
"shipment_1_status": "In Transit - Customs cleared",
"shipment_1_eta": "Tomorrow morning",
"shipment_1_obstacles": "None",
"shipment_1_notes": "Cleared customs successfully",
"shipment_2_status": "Delivered",
"shipment_2_obstacles": "",
"shipment_2_notes": "Delivered on time",
"shipment_3_status": "Delayed",
"shipment_3_eta": "Friday",
"shipment_3_obstacles": "Port congestion resolved",
"shipment_3_notes": "Truck assigned, ready for pickup"
}
}AI Evy
09/12/2025, 9:47 AMshipment_update function should have parameters that accommodate all possible shipments [(1) ]() :
json
{
"type": "object",
"properties": {
"shipment_1_status": {"type": "string", "description": "Current status of shipment 1"},
"shipment_1_eta": {"type": "string", "description": "ETA for shipment 1"},
"shipment_1_obstacles": {"type": "string", "description": "Any obstacles for shipment 1"},
"shipment_1_notes": {"type": "string", "description": "Additional notes for shipment 1"},
"shipment_2_status": {"type": "string", "description": "Current status of shipment 2"},
"shipment_2_eta": {"type": "string", "description": "ETA for shipment 2"},
"shipment_2_obstacles": {"type": "string", "description": "Any obstacles for shipment 2"},
"shipment_2_notes": {"type": "string", "description": "Additional notes for shipment 2"},
"shipment_3_status": {"type": "string", "description": "Current status of shipment 3"},
"shipment_3_eta": {"type": "string", "description": "ETA for shipment 3"},
"shipment_3_obstacles": {"type": "string", "description": "Any obstacles for shipment 3"},
"shipment_3_notes": {"type": "string", "description": "Additional notes for shipment 3"}
},
"required": []
}
The LLM will populate the args object based on the conversation with the coordinator, and your endpoint will receive both the original call context and the collected shipment updates [(1) ]() [(2) ]() .AI Evy
09/12/2025, 9:47 AMAI Evy
09/12/2025, 9:47 AMtabrza
09/12/2025, 9:48 AMAI Evy
09/12/2025, 9:48 AMAI Evy
09/12/2025, 9:49 AMshipment_update custom function [(1) ]() [(2) ]() .
Based on the documentation, when defining a custom function, you must specify parameters using JSON schema format [(1) ]() . The parameters define what information the LLM can pass to your function when it's called [(1) ]() [(2) ]() .
For your shipment_update function, you should define parameters that match the shipment data structure you're working with. The JSON schema should include the "type": "object" at the top level .
Here's what your parameter schema should look like:AI Evy
09/12/2025, 9:49 AMjson
{
"type": "object",
"properties": {
"shipment_1_status": {"type": "string", "description": "Current status of shipment 1"},
"shipment_1_eta": {"type": "string", "description": "ETA for shipment 1"},
"shipment_1_obstacles": {"type": "string", "description": "Any obstacles for shipment 1"},
"shipment_1_notes": {"type": "string", "description": "Additional notes for shipment 1"},
"shipment_2_status": {"type": "string", "description": "Current status of shipment 2"},
"shipment_2_eta": {"type": "string", "description": "ETA for shipment 2"},
"shipment_2_obstacles": {"type": "string", "description": "Any obstacles for shipment 2"},
"shipment_2_notes": {"type": "string", "description": "Additional notes for shipment 2"},
"shipment_3_status": {"type": "string", "description": "Current status of shipment 3"},
"shipment_3_eta": {"type": "string", "description": "ETA for shipment 3"},
"shipment_3_obstacles": {"type": "string", "description": "Any obstacles for shipment 3"},
"shipment_3_notes": {"type": "string", "description": "Additional notes for shipment 3"}
},
"required": []
}
The parameters are only available for POST, PATCH and PUT requests [(1) ]() . These parameters tell the LLM what information it can collect and pass to your function when called [(1) ]() [(2) ]() .AI Evy
09/12/2025, 9:49 AMAI Evy
09/12/2025, 9:49 AMtabrza
09/12/2025, 9:49 AMAI Evy
09/12/2025, 9:49 AMAI Evy
09/12/2025, 9:50 AMjson
{
"type": "object",
"properties": {
"shipment_updates": {
"type": "string",
"description": "All shipment updates collected as formatted text containing status, ETA, obstacles, and notes for each shipment"
},
"total_shipments_updated": {
"type": "string",
"description": "Total number of shipments that were updated"
}
},
"required": ["shipment_updates"]
}
## Option 2: Use a Single Text Parameter
Have the LLM format all shipment updates into a single structured text parameter :
json
{
"type": "object",
"properties": {
"all_shipment_updates": {
"type": "string",
"description": "Formatted text containing all collected shipment updates with shipment numbers, statuses, ETAs, obstacles, and notes"
}
},
"required": ["all_shipment_updates"]
}
The LLM would then format the collected information as structured text like:
Shipment SHP-1001: Status - In Transit, ETA - Tomorrow, Obstacles - None, Notes - Cleared customs
Shipment SHP-1002: Status - Delivered, ETA - N/A, Obstacles - None, Notes - On time deliveryAI Evy
09/12/2025, 9:50 AMAI Evy
09/12/2025, 9:50 AMAI Evy
09/12/2025, 9:50 AM