https://retellai.com/?utm_source=discord&utm_medium=seo logo
what's the correct way to prompt and sequence CHEC...
# ❓・ai-evy-support
m
@AI Evy what's the correct way to prompt and sequence CHECK and BOOK cal.com in conversation flow? it's unclear what's built-into the function vs what needs to be prompted, and when. https://cdn.discordapp.com/attachments/1302816169367044149/1456400093392535776/image.png?ex=695839c8&is=6956e848&hm=a82721d491ddcdb14357fd8461f1dc6904464432ce0fb8a5992641f13ab761b4&
a
Thanks for tagging me @mush. I'll look through relevant sources and get back to you shortly.
## Key Transition Logic Use transition conditions to ensure proper flow: - From Check Availability → Conversation Node (to speak results) - From Conversation Node → Book Appointment (only when user confirms a time) - Consider separate paths for available vs unavailable results [(3) ]() A common issue is sending both available and unavailable results into the same booking path—make sure your transitions differentiate these cases.
### Answer --- Here's the recommended way to sequence Check Availability and Book Appointment in a Conversation Flow: ## What's Built Into the Functions The Cal.com preset functions handle the API calls automatically—you provide the API key, Event Type ID, and optionally a timezone when configuring them. [(1) ]() [(2) ]() ## Recommended Sequence & Prompting 1. Check Availability Function Node - Prompt the agent to call this when the user states a time range [(2) ]() - Example prompt:
Copy code
When user stated a time range, please check the calendar availability by calling the `check_calendar_availability` function and let user know whether that range work or not.
2. Add a Conversation Node After the Function - This is critical—if you send directly to the next function without a conversation node, the agent won't verbally communicate the results to the user [(3) ]() - Prompt this node to tell the user the available times from the function result 3. Book Appointment Function Node - Only transition here after the user confirms a specific slot [(1) ]() - Example prompt:
Copy code
When user selected a slot, please book the appointment by calling the `book_appointment` function.
​ To learn more, see the sources I considered: [[1] Book Calendar](https://docs.retellai.com/build/book-calendar) [[2] Check Calendar Availability](https://docs.retellai.com/build/check-availability) [[3] cal.com check availability and book appointment function](https://discord.com/channels/1186424376300679209/1438984963008757841) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
m
for the "book appointment" function, cal.com requires certain information, such as email and phone number. i know this information because it's stored as variables in my conversation. how do i pass those variables to cal.com so it can book?
@AI Evy
a
Thanks for the follow-up, @mush. I'll get back to you soon.
### Answer Based on the available sources, the built-in Cal.com
book_appointment
function in Retell has limited configuration options—you can set the tool name, API key, Event Type ID, description, and timezone. [(1) ]() However, passing custom variables like email and phone number to the booking is not supported by the preset function. As noted in the community: > "On the cal.com book_appointment, how do we pass custom variables. Right now, it just says booked with user. Can we pass email, name etc?" > > "You have to create your custom function to do that" [(2) ]() ## Recommended Solution You'll need to create a custom function that calls the Cal.com API directly, where you can include your conversation variables (email, phone, name, etc.) in the booking payload. Some users have also found success handling the booking post-call using the transcript and webhook data rather than during the live call, which can avoid issues if the user changes their mind mid-conversation. [(3) ]() Check out these potentially useful sources for building custom functions: - [Book Calendar]() - [Create Retell LLM]() Would you like a general answer on how to structure a custom function for this use case?
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] Book Calendar](https://docs.retellai.com/build/book-calendar) [[2] book_appointment variable](https://discord.com/channels/1186424376300679209/1256246690118242364) [[3] Discord message from @jayzpio on 2025-01-31](https://discord.com/channels/1186424376300679209/1294891368505937952/1334946836120604692) ​
m
do you have any more information about this and how to create the custom function?
a
Thanks for the follow-up, @mush. I'll get back to you soon.
m
@AI Evy
a
For your use case, you'd structure it similarly with
{{email}}
,
{{phone_number}}
, and
{{name}}
variables that reference what you've collected in your conversation. *6. Set response variables (optional) * - Extract confirmation details from Cal.com's response to use later in the conversation ## Key Points - The
const
field lets you inject dynamic variables directly into the API call - Query parameters and header values can also use dynamic variables - Retell sends the request with the function name, call object (including transcript) , and your defined arguments For the actual Cal.com API payload structure, you'll need to reference Cal.com's documentation for their booking endpoint requirements.
### Answer Yes! Here's how to create a custom function to book appointments with Cal.com while passing your conversation variables: ## Steps to Create a Custom Function 1. Configure the function details [(1) ]() - Name:
book_cal_appointment
(must be unique, use underscores) - Description:
Book an appointment on Cal.com with customer details
2. Select HTTP Method - Choose POST 3. Add endpoint URL - Use Cal.com's booking API endpoint 4. Set request headers - Add your Cal.com API key in headers (header values can include dynamic variables) 5. Define parameters using JSON schema You can pass your conversation variables using the
const
property with dynamic variable syntax. Example:
Copy code
json
{
  "type": "object",
  "required": [
    "order_id"
  ],
  "properties": {
    "name": {
      "type": "object",
      "description": "",
      "properties": {
        "first_name": {
          "type": "string",
          "description": "User first name"
        },
        "last_name": {
          "type": "string",
          "const": "{{last_name}}"
        }
      }
    },
    "order_id": {
      "type": "number",
      "const": 1234
    }
  }
}
​ 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.