https://retellai.com/?utm_source=discord&utm_medium=seo logo
Hi , i have a retell agent that i'm using to get ...
# ❓・ai-evy-support
t
Hi @AI Evy , i have a retell agent that i'm using to get status updates from a company regarding some products that have been ordered. each product has it's own ID, current status. in the tree, should i split this between child and parent or how would it be best to manage this? these details are coming from a post request as an array of objects
a
Thanks for tagging me @tabrza. I'll look through relevant sources and get back to you shortly.
### Answer I don't have specific information about managing product status arrays with parent/child structures in the available Retell AI documentation. The sources provided focus on agent configuration, API endpoints for retrieving and updating agents [(1) ]() [(2) ]() [(3) ]() , and basic SDK usage [(4) ]() , but don't cover data structure organization for handling arrays of product objects. For handling your array of product objects (each with ID and status) from a POST request, you might want to check these potentially relevant sources: - [Get Agent]() - [Update Agent]() - [Retell Python API library]() Would you like me to try to provide a general answer based on my knowledge instead?
​ To learn more, see the sources I considered: [[1] Get Agent](https://docs.retellai.com/api-references/get-agent) [[2] Get Agent Versions](https://docs.retellai.com/api-references/get-agent-versions) [[3] Update Agent](https://docs.retellai.com/api-references/update-agent) [[4] Retell Python API library](https://github.com/RetellAI/retell-python-sdk/blob/main/README.md) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
t
@AI Evy - can a single node in the prompt tree handle multiple product update requests or does it have to split into a second child node?
a
Thanks for the follow-up, @tabrza. I'll get back to you soon.
### Answer A single conversation node can handle multiple product update requests without requiring separate child nodes [(1) ]() . The conversation node is designed to support multi-turn conversations within a single node, so you don't need to create a new node for every interaction . The documentation specifically notes that "agent can have a multi turn conversation inside a single node, so you don't necessarily need to create a new conversation node for every sentence the agent needs to say" . It's recommended to split nodes only when there's a logic split or when the instruction becomes too long . For your use case with multiple product updates, you could: 1. Keep all product status handling in one conversation node if the logic is similar across products 2. Only split into separate nodes if you need different handling logic for different types of products or statuses The node can process your array of product objects through its instruction prompt, whether you choose the Prompt option for dynamic generation or Static Sentence for a fixed initial response .
​ To learn more, see the sources I considered: [[1] Conversation Node](https://docs.retellai.com/build/conversation-flow/conversation-node) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
t
@AI Evy - how will my agent know if there are multiple products that require an update? what is the best way to let the agent know?
a
Thanks for the follow-up, @tabrza. I'll get back to you soon.
### Answer I don't have specific information in the available sources about how agents detect multiple products requiring updates or the best practices for conveying this information to the agent. The sources cover agent architecture options [(1) ]() , conversation flow components [(2) ]() [(3) ]() , and general prompt engineering principles [(4) ]() , but don't address data handling patterns for multiple product scenarios or methods for communicating array sizes to agents. For handling your specific use case of letting the agent know about multiple products requiring updates, you might want to check these potentially relevant sources: - [Single/Multi Prompt Agent Overview]() - [Conversation Flow Overview]() - [Prompt Engineering Guide]() Would you like me to try to provide a general answer based on my knowledge instead?
​ To learn more, see the sources I considered: [[1] Single/Multi Prompt Agent Overview](https://docs.retellai.com/build/single-multi-prompt/prompt-overview) [[2] Conversation Flow Overview](https://docs.retellai.com/build/conversation-flow/overview) [[3] Retell AI’s Advanced Conversation Flow | Retell AI](https://www.retellai.com/blog/unlocking-complex-interactions-with-retell-ais-conversation-flow) [[4] Prompt Engineering Guide](https://docs.retellai.com/build/prompt-engineering-guide) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
t
yes please provide a general answer based on your knowledge
@AI Evy - yes please provide a general answer based on your knowledge
a
Thanks for the follow-up, @tabrza. I'll get back to you soon.
### Answer Based on general conversational AI principles, here are several effective ways to let your agent know about multiple products requiring updates: 1. Dynamic Variables Approach You can use dynamic variables to pass the product count and details into your agent's context. This would involve setting variables like
{{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.
message has been deleted
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
t
@AI Evy - would this prompt be correct? You have {{shipment_count}} shipments to get an update on. Please ensure you capture updates for all shipments. When the caller provides an update, capture structured details: - Status (e.g., in transit, delayed, delivered) - Estimated Time of Arrival (ETA) or Estimated Time of Departure (ETD) (if mentioned) - Obstacles or issues (if mentioned) - Preference for email-only communication (log this in summary but do not push to email). If there are more than one shipments, please collect the information from the caller about this is as well. Example: "Thank you. We also have shipment {{next_shipment_id}} going from {{next_origin}} to {{next_destination}}. Could you share the current status of this shipment as well?" Call shipment_update function - if the caller asks a general question about Moved -> transition to faq - if the caller is upset, confused, asks for a human or does not want to provideor have any updates at this time -> transition to fallback
a
Thanks for the follow-up, @tabrza. I'll get back to you soon.
### Answer Your prompt structure looks good and follows Retell AI's best practices for function calling instructions [(1) ]() . Here are some refinements based on the documentation: Strengths of your prompt: - Uses dynamic variables correctly ({{shipment_count}}, {{next_shipment_id}}, etc.) - Provides clear trigger conditions for function calls - Includes specific transition logic for different scenarios Suggested improvements based on best practices: 1. More explicit tool calling instructions - The documentation recommends defining exact conditions for tool usage:
Copy code
## 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.
​ To learn more, see the sources I considered: [[1] Prompt Engineering Guide](https://docs.retellai.com/build/prompt-engineering-guide) [[2] Conversation Node](https://docs.retellai.com/build/conversation-flow/conversation-node) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
t
@AI Evy - can you please create an updated prompt? i would like to ensure that the shipment_update function is only called after all the shipment details are captured and not just one. the following is the post request from n8n: { "override_agent_id": "", "from_number": "", "to_number": "", "coordinator_name": "John Doe", "company_name": "Movd Logistics", "shipment_count": 3, "shipments": [ { "shipment_number": "SHP-1001", "origin": "New York, USA", "destination": "Hamburg, Germany", "status": "In Transit", "obstacles": "Customs delay", "notes": "Expected clearance tomorrow" }, { "shipment_number": "SHP-1002", "origin": "Los Angeles, USA", "destination": "Tokyo, Japan", "status": "Delivered", "obstacles": "", "notes": "Arrived on time" }, { "shipment_number": "SHP-1010", "origin": "Rotterdam, Netherlands", "destination": "Dubai, UAE", "status": "Pending Pickup", "obstacles": "Port congestion", "notes": "Awaiting truck assignment" } ] }
a
Thanks for the follow-up, @tabrza. I'll get back to you soon.
### Answer Based on your requirements and the data structure, here's an updated prompt that ensures the
shipment_update
function is only called after collecting updates for ALL shipments [(1) ]() :
Copy code
You 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 → pro
Copy code
ceed 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 shipment
​ To learn more, see the sources I considered: [[1] Function Calling Overview](https://docs.retellai.com/build/single-multi-prompt/function-calling) [[2] Integrate Function Calling](https://docs.retellai.com/integrate-llm/integrate-function-calling) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
This prompt structure follows Retell AI's function calling best practices by clearly defining when the function should be triggered and ensures systematic data collection before any function execution [(2) ]() .
t
@AI Evy - how will the retell agent know which shipment array it's working through? is {{shipments.0.shipment_number}} etc. a standard way in which retell agents handle arrays of data?
a
Thanks for the follow-up, @tabrza. I'll get back to you soon.
### Answer No,
{{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:
Copy code
{
  "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 .
​ To learn more, see the sources I considered: [[1] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[2] dynamic variables in function query parameters are not parsed](https://discord.com/channels/1186424376300679209/1414306451656151291) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
t
@AI Evy - in this case, because the number of shipments is dynamic, please update the prompt to ensure we can process a dynamic amount of shipments. also, please share the update post request data that i should send retell
a
Thanks for the follow-up, @tabrza. I'll get back to you soon.
### Answer Based on the dynamic variables documentation, you'll need to handle the dynamic nature differently since Retell AI dynamic variables must be strings and don't support array indexing [(1) ]() . Here's an updated approach: ## Updated Prompt for Dynamic Shipments
Copy code
You 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:
Copy code
json
{
  "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) ]() .
​ To learn more, see the sources I considered: [[1] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[2] Integrate any system with custom function](https://docs.retellai.com/build/single-multi-prompt/custom-function) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
t
@AI Evy - it sounds like passing it through a custom function to handle the array processing sounds like the better approach. please provide the function, the prompt and confirm that we can continue with this post request or if we need to update it: { "override_agent_id": "", "from_number": "", "to_number": "", "coordinator_name": "John Doe", "company_name": "Movd Logistics", "shipment_count": 3, "shipments": [ { "shipment_number": "SHP-1001", "origin": "New York, USA", "destination": "Hamburg, Germany", "status": "In Transit", "obstacles": "Customs delay", "notes": "Expected clearance tomorrow" }, { "shipment_number": "SHP-1002", "origin": "Los Angeles, USA", "destination": "Tokyo, Japan", "status": "Delivered", "obstacles": "", "notes": "Arrived on time" }, { "shipment_number": "SHP-1010", "origin": "Rotterdam, Netherlands", "destination": "Dubai, UAE", "status": "Pending Pickup", "obstacles": "Port congestion", "notes": "Awaiting truck assignment" } ] }
a
Thanks for the follow-up, @tabrza. I'll get back to you soon.
### Answer ### Answer Yes, using a custom function is the better approach for handling array processing [(1) ]() . Here's the complete solution: ## Custom Function Configuration Function Name:
get_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:
Copy code
json
{
  "type": "object",
  "properties": {},
  "required": []
}
## Updated Prompt
Copy code
You 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 fallback
## POST Request Structure Your current POST request structure can remain the same. The custom function will receive this data in the
call
object [(2) ]() [(1) ]() :
Copy code
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 :
Copy code
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 .
​ To learn more, see the sources I considered: [[1] Integrate any system with custom function](https://docs.retellai.com/build/single-multi-prompt/custom-function) [[2] Custom Function](https://docs.retellai.com/build/conversation-flow/custom-function) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
t
@AI Evy - how will the agent know that there are one or more than one shipments to get details of using this custom function?
a
Thanks for the follow-up, @tabrza. I'll get back to you soon.
### Answer The agent will know about the number of shipments through the custom function's response and the call context data [(1) ]() . When your custom function is called, it receives the full call object containing your original POST request data, including the
shipment_count
and
shipments
array . Your custom function endpoint will receive:
Copy code
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:
Copy code
"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 .
​ To learn more, see the sources I considered: [[1] Custom Function](https://docs.retellai.com/build/conversation-flow/custom-function) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
t
@AI Evy - ok, understood. pls share the algorithm i should use for the custom function to be able to do this
a
Thanks for the follow-up, @tabrza. I'll get back to you soon.
### Answer Based on the custom function documentation, here's the algorithm for your custom function endpoint [(1) ]() : ## Custom Function Algorithm
Copy code
javascript
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 Alternative
Copy code
python
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 .
​ To learn more, see the sources I considered: [[1] Integrate any system with custom function](https://docs.retellai.com/build/single-multi-prompt/custom-function) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
t
@AI Evy - i believe the easier option for me is to build the post request in a way that can be easily consumed by retell agent. please share the exact structure that i should send the post request as
a
Thanks for the follow-up, @tabrza. I'll get back to you soon.
### Answer Based on the dynamic variables documentation, here's the exact POST request structure you should use for your outbound call with multiple shipments [(1) ]() :
Copy code
json
{
  "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:
Copy code
You 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 fallback
This approach uses Retell AI's standard dynamic variable syntax and avoids the complexity of custom functions while still handling multiple shipments effectively [(1) ]() .
​ To learn more, see the sources I considered: [[1] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[2] Make x Retell Tutorial | How to trigger a call from google sheet](

https://www.youtube.com/watch?v=pjm8y3uILg4▾

) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
t
perfect. now, for the shipment_update custom function post request, what would that look like considering we have multiple shipments
@AI Evy perfect. now, for the shipment_update custom function post request, what would that look like considering we have multiple shipments
a
Thanks for the follow-up, @tabrza. I'll get back to you soon.
### Answer For the
shipment_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) ]() :
Copy code
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"
  }
}
[(1) ]() [(2) ]() ## Function Parameters Schema Your
shipment_update
function should have parameters that accommodate all possible shipments [(1) ]() :
Copy code
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) ]() .
​ To learn more, see the sources I considered: [[1] Custom Function](https://docs.retellai.com/build/conversation-flow/custom-function) [[2] Integrate any system with custom function](https://docs.retellai.com/build/single-multi-prompt/custom-function) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
t
@AI Evy - ok, so i don't need to define anything in the parameters?
a
Thanks for the follow-up, @tabrza. I'll get back to you soon.
### Answer --- You do need to define parameters for your
shipment_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:
Copy code
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 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) ]() .
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](https://docs.retellai.com/build/conversation-flow/custom-function) [[2] Integrate any system with custom function](https://docs.retellai.com/build/single-multi-prompt/custom-function) ​
t
@AI Evy - considering the input could be one or many shipments, how should i define this in the parameters?
a
Thanks for the follow-up, @tabrza. I'll get back to you soon.
### Answer Based on the custom function documentation, for handling dynamic numbers of shipments, you have two approaches [(1) ]() [(2) ]() : ## Option 1: Define Maximum Expected Parameters Since Retell AI custom functions require predefined JSON schema parameters [(1) ]() , you can define parameters for the maximum number of shipments you expect:
Copy code
json
{
  "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 :
Copy code
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:
Copy code
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 delivery
This approach works because all response formats get converted to string before sending to the LLM for processing [(1) ]() [(2) ]() . Your endpoint can then parse this structured text to extract the individual shipment updates. The single parameter approach is more flexible since it doesn't require you to predefine the exact number of shipments, while still maintaining the required JSON schema structure that Retell AI expects [(1) ]() .
​ To learn more, see the sources I considered: [[1] Custom Function](https://docs.retellai.com/build/conversation-flow/custom-function) [[2] Integrate any system with custom function](https://docs.retellai.com/build/single-multi-prompt/custom-function) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.