https://retellai.com/?utm_source=discord&utm_medium=seo logo
Custom Function Not substituting variable
# ❓・bug-report
o
I am having an issue with a custom function. I am instructing the agent clearly to substitute the filter in the query params. At my endpoint i am receiveing {{phone_number}} instead of properly substituting the variable. ([v0] URL: api/find-patient?filter=%7B%7Bphone_number%7D%7D) this is how its being recieved. I have tried several different methods to get this working. This ussually is not an issue however at this point I am almost certain this is a retell issue. Can you or anyone please advise how to fix this? Oddly enough in the tool log it shows "tool invocation filter: '123456789' so in retell it appears as if its working. But whats actually being sent is not getting substituted with the correct variable. Any suggestions?? Call ID - call_fb19510d184183b83bdd92c5a40 https://cdn.discordapp.com/attachments/1450867178906714123/1450867179346985061/Screenshot_2025-12-17_at_10.06.47_AM.png?ex=694418db&is=6942c75b&hm=359776ddcbe97530a16b45f12e70d00626bde7fbce85b54f2a6b5afa52d5a443&
o
Hello @OfficeMate-Ai , I can't see any vairable called phone_number?
o
Not sure what you mean by this. In the query params it clearly shows filter: {{phone_number}} this is supposed to be substituted and appended to the url for the api call....
@Omar Ashraf | Community Lead
o
Yes, the {{phone_number}} must have a value , but I don't see you have a variable that is called phone_number, to replace with its value
o
are you referring to the post call data extrctions?
@Omar Ashraf | Community Lead
o
I will explain to you what i mean
You want to send the phone number as query param , to do that you must first have a variable have this phone number , here you are using the variable phone_number , but dosen't exit on this call , you didn't give it a value or set it up , so there is not value to replace , that's what the agent send the query as it as variable now , not the value since there is not value
the solution
o
how wuld i define the value if there is no json schema on a GET function
o
if the phone number you want to use it the user phone number , that is calling you now , you can use this variable instead {{user_number}}
use this variable instead of {{phone_number}}
o
ok ill try this
not working - /api/find-patient?filter=%7B%7Buser_number%7D%7D still did not get substituted. Here is the instruction for the agent. and the query params im using ### 1. The "Find Patient" Sequence (Authentication) REQUIRED: Before booking, canceling, or rescheduling for an existing patient, you MUST identify them first. CRITICAL: The find_patient tool returns ALL contacts in the database (hundreds or thousands). You MUST search through the entire list to find the one matching the caller's phone number. DO NOT just check the first contact. Steps: 1. Ask for Phone Number (Primary method) - "May I have your phone number to look up your account?" 2. Format the Phone Number - CRITICAL: - ALWAYS remove ALL dashes, spaces, parentheses, and any other formatting - Extract ONLY the 10 digits - Examples: - Patient says: "954-729-5697" → You use:
9547295697
- Patient says: "(954) 729-5697" → You use:
9547295697
- Patient says: "954 729 5697" → You use:
9547295697
- Patient says: "nine five four, seven two nine, five six nine seven" → You use:
9547295697
3. Call
find_patient
- CRITICAL: You MUST pass the phone number in a parameter called
filter
- The parameter name is
filter
and the value is the 10-digit phone number with no formatting - Example tool call format:
{"filter": "9547295697"}
- DO NOT use parameter names like
phone_number
or
phone
- it MUST be called
filter
- Pass the phone number as digits only (no dashes, spaces, or formatting) https://cdn.discordapp.com/attachments/1450867178906714123/1450879479487533219/Screenshot_2025-12-17_at_10.56.52_AM.png?ex=6944244f&is=6942d2cf&hm=85e3c4859e4aedb76429a659c064b92f790e9a68396e017a37ee04cfd114c3a4&
how would i define this variable so the sytem knows to substitute its still not doing this i hear what your saying but this isnt working
o
you test it on a web call right ?
o
yes this was tested on the chat, but either way ive tested voice also does the same thing do i need to test it live with an actual call for this to work?
o
the valuable user_number is coming from the user phone number so if you're using the web testing, there is no phone number so it will be empty so it will not work
Yes, you need to used a phone call to work
o
ok, understood. However, in cases where a users number on file is NOT the number they are calling from. This still needs to properly send the correct number, so in this case how am i supposed to define this variable i cannot rely on user number everytime
o
o
ahhh thank you. this makes sense! Dk how I missed this.
ok last question. Ive defined the variable in extracted variables. Ive listed it properly in the query i believe., and still passed as phone_number. does this just not work at all in text testing?
@Omar Ashraf | Community Lead tested this on voice also not working man
o
can you share the call id
o
call_6a51a98cdbcace7f9bdcb429e2e
int eh query params is the variable supposed to be in single or double curly braces? {phone_number or {{phone_number}}... im just guessing at this point what else could be wrong
o
{{}} double
o
ok thats how it is
in the tool log i can see my number this is whats so confusing... in the logs for my api its showing the text not substituted...
o
You didn't use the extract function so still, there is no variable
o
ok can you pelase be more specific and give me a resolution on HOW to fix this
o
Use the function on the prompt and mention when you want to use it
o
finally!!! what a feeling lol thank you sir
@Omar Ashraf | Community Lead hey Omar, having another issue with tool call not appending the variable into the url. call id - call_1796f2c8361d9e3a0d11c6b9ef8 i have the appointment_id se up as an extracted variable as you advised. I can see the payload the data that we need is there. My url for the rescehdule appointment is 100% correct, however its not passing the appointment Id variable though... im saving it both in extracted variables as a custom function and as a response variable from check appointments. this needs to be at the path level so i cannot use it as a query param. Any suggestions on this?
@Colin - Integrations @ Retell AI would you be able to check this out?
o
Hello @OfficeMate-Ai , create a seperate ticket for this.
o
done