https://retellai.com/?utm_source=discord&utm_medium=seo logo
<@1145576664366055464> i get this error, even whe...
# ❓・ai-evy-support
m
@AI Evy i get this error, even when the agent asks for a phone number tool_call_id: tool_call_293704 {"error":"Error calling Cal Booking API: Axios Error: error code: ERR_BAD_REQUEST, error message: Request failed with status code 400\nresponse status: 400\nresponse data: [{\"message\":\"1\",\"data\":null},\"custom in 'responses': {phone}error_required_field\"]"}
a
Thanks for tagging me @mohammed21. I'll look through relevant sources and get back to you shortly.
### Answer This error indicates that Cal.com is expecting a phone number field in the booking request, but it's not being properly passed through [(1) ]() [(2) ]() . Several users have reported similar issues where required fields like phone numbers or locations aren't being transmitted correctly to Cal.com even when the agent collects this information [(2) ]() . The error
"custom in 'responses': {phone}error_required_field"
suggests that Cal.com's event type configuration requires a phone number field that isn't being included in the booking API call [(1) ]() [(2) ]() . To troubleshoot this: 1. Check your Cal.com event type settings to see if phone number is marked as required [(2) ]() 2. Verify that your agent's prompt explicitly instructs it to collect and use the phone number when booking [(3) ]() 3. Consider that some users have found the native Cal.com integration has limitations with custom fields, and may require using the Cal.com API directly through custom functions for more complex field requirements [(4) ](

▾

) [(5) ]() One user mentioned that they had to use custom functions instead of the built-in Cal.com integration to handle additional fields properly [(5) ]() . Another approach mentio
ned was potentially using the booking function twice to gather all required information [(2) ]() . If the issue persists, you might need to examine whether your Cal.com event type configuration matches what the Retell booking function can provide, or consider implementing a custom function for more control over the booking process [(6) ]() [(5) ]() .
​ To learn more, see the sources I considered: [[1] Cal.com Appointments](https://discord.com/channels/1186424376300679209/1358842036635173104) [[2] Issues with Appointment Booking Feature.](https://discord.com/channels/1186424376300679209/1352336526025166928) [[3] Book Calendar](https://docs.retellai.com/build/book-calendar) [[4] MASTER THE FUTURE OF VOICE AI - Never Miss Another Appointment](

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

) [[5] Discord message from @neoxsaibot on 2024-11-04](https://discord.com/channels/1186424376300679209/1294891368505937952/1303073018448449557) [[6] 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.
m
@AI Evy how do i make a custom booking function
a
Thanks for the follow-up, @mohammed21. I'll get back to you soon.
### Answer To create a custom booking function in Retell AI, follow these steps: ## Creating the Custom Function 1. In your Retell dashboard, click "+ Add" in the tools section and select "Custom Function" from the dropdown menu [(1) ]() 2. Configure the function details: - Add a unique name separated with underscores (e.g.,
book_appointment_custom
) - Add a description like "Book appointment with custom fields including phone number" 3. Select the HTTP method (typically POST for booking) 4. Add your endpoint URL where Retell will send the booking request 5. Set request headers if needed (like Authorization for your calendar API) 6. Define parameters using JSON schema format :
Copy code
javascript
{
  "type": "object",
  "properties": {
    "start": {
      "type": "string",
      "description": "The start time of the appointment"
    },
    "eventTypeId": {
      "type": "number",
      "description": "The event type ID from your calendar"
    },
    "attendee": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "The attendee's name"
        },
        "email": {
          "type": "string",
          "description": "The attendee's email"
        },
        "phone": {
          "type": "string",
          "description": "The attendee's phone number"
        }
      }
    }
  },
  "required": ["start", "eventTypeId", "attendee"]
}
## Setting Up Your Endpoint Your custom function endpoint will receive requests with this structure :
Copy code
javascript
{
  "name": "book_appointment_custom",
  "call": { /* call object with context */ },
  "args": { /* the booking parameters */ }
}
## Verifying Requests To verify requests are from Retell, check the
X-Retell-Signature
header :
Copy code
javascript
import { Retell } from "retell-sdk";

this.app.post("/book-appointment", 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;
  }
  // Handle booking logic here
}) ;
## Updating Your Prompt Include explicit instructions in your agent's prompt about when to use the custom function :
Copy code
When user provides all booking details including phone number, please book the appointment by calling the `book_appointment_custom` function.
This approach gives you full control over the booking process and can handle custom fields like phone numbers that the built-in Cal.com integration might not support properly [(2) ]() .
​ 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] Discord message from @neoxsaibot on 2024-11-04](https://discord.com/channels/1186424376300679209/1294891368505937952/1303073018448449557) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.