https://retellai.com/?utm_source=discord&utm_medium=seo logo
I'm having an issue with custom functions in singl...
# ❓・ai-evy-support
k
@AI Evy I'm having an issue with custom functions in single prompt agents for a cal.com integration: How do I get a custom function endpoint URL to dynamically update? I'm trying to call the cancel booking endpoint and have configured the URL as https://api.cal.com/v2/bookings/{bookingUid}/cancel, however when sending the agent literally calls that URL instead of updating with a previously gathered booking id such as 4fW9jQeqNnUmizNgytpzab full error message below - the response also says I'm tells me I'm sending extra fields on the JSON body but these should be sorted once we call the correct endpoint: Axios Error: error code: ERR_BAD_REQUEST, error message: Request failed with status code 400 response status: 400 response data: [{"status":"1","timestamp":"2","path":"3","error":"4"},"error","2026-02-10T15:13:44.761Z","/v2/bookings/%7BbookingUid%7D/cancel?%7BbookingUid%7D=bookingUid&content-type=application%2Fjson",{"code":"5","message":"6","details":"7"},"BadRequestException","call property is wrong,property call should not exist , name property is wrong,property name should not exist , args property is wrong,property args should not exist ",{"message":"6","error":"8","statusCode":400},"Bad Request"]
a
Thanks for tagging me @K. I'll look through relevant sources and get back to you shortly.
### Answer The issue is that you're using single curly braces
{bookingUid}
instead of double curly braces
{{bookingUid}}
. [(1) ]() To use dynamic variables in your custom function URL path, you must use the
{{variable_name}}
syntax. Your URL should be:
Copy code
<https://api.cal.com/v2/bookings/%7B%7BbookingUid%7D%7D/cancel>
[(2) ]() , [(1) ]() **Important requirement**: For the variable to be substituted in the URL path, you need to extract it as a dynamic variable before the custom function is called. If you're extracting
bookingUid
from a previous tool call's response, you should use the Extract Dynamic Variables function to save it, not just the response variable extraction within the custom function itself. [(3) ]() A community member reported a similar issue where variables weren't populating in path parameters—the resolution was: - Use the variable name directly like
{{bookingUid}}
(double curly braces) - Extract the variable using the Extract Dynamic Variables tool before calling the custom function that uses it in the URL Regarding the extra fields error (
call
,
name
,
args
properties) , this appears to be happening because the request is hitting the wrong endpoint (the literal
{bookingUid}
path) . Once you fix the URL syntax and ensure the variable is properly extracted beforehand, the correct endpoint should receive the properly formatted request body. [(2) ]()
​ 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) [[3] Custom function failure to substitute dynamic variable](https://community.retellai.com/t/custom-function-failure-to-substitute-dynamic-variable/231) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
k
@AI Evy I've fixed the dynamic variable issue but am still getting the 400 error: Axios Error: error code: ERR_BAD_REQUEST, error message: Request failed with status code 400 response status: 400 response data: [{"status":"1","timestamp":"2","path":"3","error":"4"},"error","2026-02-11T11:57:30.597Z","/v2/bookings/4fW9jQeqNnUmizNgytpzab/cancel",{"code":"5","message":"6","details":"7"},"BadRequestException","call property is wrong,property call should not exist , name property is wrong,property name should not exist , args property is wrong,property args should not exist ",{"message":"6","error":"8","statusCode":400},"Bad Request"] How do I remove these extra properties from the call?
a
Thanks for the follow-up, @K. I'll get back to you soon.
### Answer Good news—the dynamic variable is now working (the path shows the actual booking UID) . The 400 error is happening because Retell's request body includes
call
,
name
, and
args
properties by default, which the Cal.com API doesn't expect. [(1) ]() When Retell sends a POST request to your custom function endpoint, the body automatically includes: - `name`: the name of the custom function - `call`: the call object with context about the call - `args`: the arguments for the custom function as a JSON object **The issue**: Cal.com's cancel endpoint expects a specific request body format, but it's receiving Retell's standard wrapper with these extra properties. **Solution options**: 1. **Create a middleware/proxy endpoint**: Build your own server endpoint that receives Retell's request, extracts only the data Cal.com needs from the
args
object, and forwards a properly formatted request to Cal.com. 2. **Use a different HTTP method**: If Cal.com's cancel endpoint accepts DELETE requests without a body, you could try switching the HTTP method to DELETE. For GET and DELETE requests, the request body handling differs. 3. **Check if Cal.com accepts query parameters**: You could potentially pass the cancellation reason (if needed) via query parameters instead of the request body, since query parameters are appended separately from the body. , [(2) ]() The middleware approach is the most reliable solution—your proxy would receive Retell's request, extract what you need from
content.args
, and make a clean request to Cal.com with only the properties their API expects.
​ 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.
k
@AI Evy Okay, I will pick up the issue with our development team. Can you please suggest some middleware solutions that an expert API engineer might consider for this?
a
Thanks for the follow-up, @K. I'll get back to you soon.
### Answer The sources don't provide specific middleware implementation recommendations for this use case. However, based on what the documentation shows about Retell's custom function request structure, here's what your development team should know: What Retell sends to your endpoint (POST requests) : - `name`: the name of the custom function - `call`: the call object with context about the call and real-time transcript - `args`: the arguments for the custom function as a JSON object [(1) ]() , [(2) ]() **Middleware approach**: Your proxy would receive Retell's request, extract the necessary data from the
args
object, and forward a clean request to Cal.com. The documentation includes an example of handling incoming requests:
Copy code
javascript
this.app.post("/check-weather", async (req: Request, res: Response) => {
 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;
 if (content.args.city === "New York") {
 return res.json("25f and sunny") ;
 } else {
 return res.json("20f and cloudy") ;
 }
}) ;
[(1) ]() This pattern shows how to access
content.args
to extract the parameters you need, then make your own call to Cal.com with only the fields their API expects. **Security consideration**: You can verify requests are from Retell using the
X-Retell-Signature
header and the Retell SDK's verify function. , [(2) ]() For specific middleware platform recommendations (serverless functions, API gateways, etc.) , I don't have that information in the available sources. Would you like a general answer based on common industry practices?
​ 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.