https://retellai.com/?utm_source=discord&utm_medium=seo logo
I have a custom function set up, GET with query pa...
# ❓・ai-evy-support
v
@AI Evy I have a custom function set up, GET with query parameters name, start_time, phone, email all with values that are dynamic variables. However when testing, the tool_invocation for the custom function is just sending this: tool_call_id: tool_call_e6f5f4 { "message": "Book Josh for onboarding on Wednesday, November 19th at 4:30pm." } which of course won't work because it is a GET request expecting the parameters I specified. tool_call_id: tool_call_e6f5f4 {"error":"Missing required fields: start_time, name, email, phone"} What do I need to do to fix this
a
Thanks for tagging me @vodmordia. I'll look through relevant sources and get back to you shortly.
### Answer Based on the available sources, there's a known limitation with GET requests and dynamic variables in query parameters. [(1) ]() [(2) ]() The Issue: When using GET requests with query parameters that reference dynamic variables, the variables may not be properly substituted with their actual values. Instead, the variable names themselves (like
{{variable_name}}
) get passed in the URL. The Solution: Switch to using a POST request instead of GET. [(1) ]() For POST, PATCH, and PUT requests, you can define parameters using JSON schema format, and the LLM will properly extract and pass the values. [(3) ]() [(4) ]() Here's what you need to do: 1. Change your HTTP method from GET to POST 2. Define your parameters using JSON schema format For example:
Copy code
json
{
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "The customer's name"
    },
    "start_time": {
      "type": "string",
      "description": "The appointment start time"
    },
    "phone": {
      "type": "string",
      "description": "The customer's phone number"
    },
    "email": {
      "type": "string",
      "description": "The customer's email address"
    }
  },
  "required": ["name", "start_time", "phone", "email"]
}
3. Update your prompt to explicitly tell the agent when to call this function and what information to extract. [(4) ]() For example:
Copy code
When the user provides their name, appointment time, phone number, and email, call the booking function with these details.
The POST request will send the parameters in the request body as JSON, which properly handles dynamic variable substitution. [(3) ]() [(4) ]() Alternative (if you must use GET) : If your backend requires GET, you could use a POST request to an intermediary service (like n8n or Make.com) that extracts the data and then makes the GET request to your actual endpoint. [(1) ]()
​ To learn more, see the sources I considered: [[1] How to pass query URL parameters from conversation to GET request](https://discord.com/channels/1186424376300679209/1384523020110008420) [[2] dynamic variables in function query parameters are not parsed](https://discord.com/channels/1186424376300679209/1414306451656151291) [[3] Custom Function](https://docs.retellai.com/build/conversation-flow/custom-function) [[4] 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.
v
can I use the dynmic variables in the json then? or how should I get them into the request?
@AI Evy can I use the dynmic variables in the json then? or how should I get them into the request?
a
Thanks for the follow-up, @vodmordia. I'll get back to you soon.
### Answer No, you don't use dynamic variables in the JSON parameter schema for POST requests. The LLM automatically extracts the values from the conversation and passes them to your function. [(1) ]() [(2) ]() Here's how it works: In your parameter schema, you define the structure without dynamic variables:
Copy code
json
{
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "The customer's name"
    },
    "start_time": {
      "type": "string",
      "description": "The appointment start time"
    },
    "phone": {
      "type": "string",
      "description": "The customer's phone number"
    },
    "email": {
      "type": "string",
      "description": "The customer's email address"
    }
  },
  "required": ["name", "start_time", "phone", "email"]
}
[(1) ]() , [(2) ]() The LLM will: 1. Listen to the conversation 2. Extract the relevant information (Josh, Wednesday November 19th at 4:30pm, phone, email) 3. Automatically populate these parameters in the request body [(1) ]() [(2) ]() Your backend will receive: [(1) ]()
Copy code
json
{
  "name": "get_booking_details",
  "call": { ... },
  "args": {
    "name": "Josh",
    "start_time": "Wednesday, November 19th at 4:30pm",
    "phone": "...",
    "email": "..."
  }
}
The key is in your prompt - you need to explicitly tell the agent when to call the function and what information to extract:
Copy code
When the user provides their name, appointment time, phone number, and email, call the booking function with these details.
Dynamic variables (like
{{customer_name}}
) are used in different contexts - in prompts, begin messages, or tool descriptions - but not in the parameter schema itself. [(3) ]()
​ 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.
v
@AI Evy The bot will be initiated with incoming variables though: name, phone, email and will not be asking on the call for those things. Will the bot 'know' to use the already existing variables?
a
Thanks for the follow-up, @vodmordia. I'll get back to you soon.
### Answer Yes, the bot can use dynamic variables that are passed at call initiation, but you need to configure this properly. When you initiate a call (either inbound or outbound) , you pass dynamic variables in the
retell_llm_dynamic_variables
field. [(1) ]() For outbound calls, this is done via the Create Phone Call API. For inbound calls, you supply them through the Inbound Call Webhook. To make the LLM use these pre-existing variables in your custom function: 1. Reference the dynamic variables in your function's tool description - You can use dynamic variables in tool descriptions to provide context to the LLM. 2. Update your prompt to instruct the agent to use the pre-existing information. For example:
Copy code
You have access to the customer's information: name is {{name}}, phone is {{phone}}, and email is {{email}}. When booking an appointment, use these existing details along with the appointment time the customer provides.
The LLM will then know to use these pre-populated values when calling your custom function, rather than asking the customer for them again. Important note: All values in
retell_llm_dynamic_variables
must be strings. If you're experiencing issues where the agent isn't using the dynamic variables even though they're being sent, make sure you're setting them correctly in the call initiation. [(2) ]() One user reported success by structuring the return as:
Copy code
json
{
  "call_inbound": {
    "dynamic_variables": {
      "caller_name": " "
    }
  }
}
​ To learn more, see the sources I considered: [[1] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[2] Dynamic Variables](https://discord.com/channels/1186424376300679209/1356680357084135558) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
v
@AI Evy I added initial dynamic variables for customer_name, email, and phone with test values When trying to make the request the phone and email were blank, but it picked up the name. tool_call_id: tool_call_c5147e { "name": "Josh Morlan", "start_time": "2025-11-20 14:00", "phone": "", "email": "" } What can I do to make sure we get all the existing variables without having to ask the user on the call?
a
Thanks for the follow-up, @vodmordia. I'll get back to you soon.
### Answer --- Based on the issue you're experiencing, there's a mismatch between your dynamic variable names and what you're referencing in your custom function. The LLM picked up
customer_name
(which you set) but couldn't find
phone
and
email
because those exact variable names need to be referenced. Here's what you need to do: 1. Match your dynamic variable names exactly in your prompt and tool description. You set
customer_name
,
email
, and
phone
as dynamic variables, so reference them exactly that way. [(1) ]() 2. Update your prompt to explicitly tell the agent to use these pre-existing variables:
Copy code
You have access to the customer's information through dynamic variables:
- Customer name: {{customer_name}}
- Phone number: {{phone}}
- Email address: {{email}}

When booking an appointment, you MUST use these existing details. Do not ask the customer for this information - it is already available to you.
3. In your custom function's tool description, reference the dynamic variables: [(2) ]() For example, in the description field of your parameters:
Copy code
json
{
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "Use the customer name from {{customer_name}}"
    },
    "start_time": {
      "type": "string",
      "description": "The appointment start time provided by the customer"
    },
    "phone": {
      "type": "string",
      "description": "Use the phone number from {{phone}}"
    },
    "email": {
      "type": "string",
      "description": "Use the email address from {{email}}"
    }
  },
  "required": ["name", "start_time", "phone", "email"]
}
4. Verify your dynamic variables are being set correctly. When initiating the call, ensure you're passing them in
retell_llm_dynamic_variables
with all values as strings: [(1) ]()
Copy code
json
{
  "customer_name": "Josh Morlan",
  "phone": "+1234567890",
  "email": "josh@example.com"
}
The key issue is that the LLM needs explicit instructions in both the prompt and the tool description to map the dynamic variables to the function parameters. Without this guidance, it won't automatically know to use
{{phone}}
for the
phone
parameter in your function call. **
​ To learn more, see the sources I considered: [[1] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[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.