le_chemist
08/24/2025, 2:30 PMAI Evy
08/24/2025, 2:30 PMAI Evy
08/24/2025, 2:30 PMAI Evy
08/24/2025, 2:30 PMdynamic_variables field, not as a top-level parameter [(1) ]() .
Here's the correct format for your Create Chat request [(2) ]() :
json
{
"agent_id": "agent_xxxxxxxxxxxxx",
"dynamic_variables": {
"user_name": "{{ $('Webhook') .item.json.body.first_name }}"
}
}
For the Chat Completion request, dynamic variables are not passed in each completion call - they're set once during chat creation and maintained throughout the conversation [(3) ]() . Your Chat Completion request should only include [(2) ]() :
json
{
"chat_id": "chat_xxxxxxxxxxxx",
"content": "{{ $('Webhook') .item.json.body['Message Body'] }}"
}
All values in dynamic variables must be strings [(1) ]() . Once set during chat creation, the agent will use {{user_name}} throughout the conversation based on the initial dynamic variables you provided .AI Evy
08/24/2025, 2:31 PMle_chemist
08/24/2025, 2:31 PMle_chemist
08/24/2025, 2:49 PMAI Evy
08/24/2025, 2:49 PMAI Evy
08/24/2025, 2:50 PMAI Evy
08/24/2025, 2:50 PMretell_llm_dynamic_variables, not dynamic_variables [(1) ]() . Your request should be:
json
{
"agent_id": "agent_xxxxxxxxxxxxx",
"retell_llm_dynamic_variables": {
"user_name": "{{ $('Webhook') .item.json.body.first_name }}"
}
}
The key difference is using retell_llm_dynamic_variables as the field name . This field accepts key-value pairs where all values must be strings [(2) ]() .
If the variable still isn't working, there are a few troubleshooting steps from community experience:
1. Test with a simple static value first to verify the variable is being received [(3) ]()
2. Check if the variable appears in your agent's welcome message for testing purposes [(4) ]()
3. Ensure your webhook is actually sending the correct data structure [(3) ]()
When a dynamic variable isn't set properly, it will remain unchanged in the output (showing as {{user_name}} instead of being replaced) [(2) ]() .AI Evy
08/24/2025, 2:50 PMle_chemist
08/25/2025, 12:16 AMAI Evy
08/25/2025, 12:16 AMAI Evy
08/25/2025, 12:16 AM{{current_time_America/New_York}} (replace with your timezone) .
This pre-built function is available for both single/multi-prompt agents and conversation flow agents [(3) ]() [(4) ]() . The function will be called automatically when the LLM determines it's appropriate based on your prompt instructions [(4) ]() .AI Evy
08/25/2025, 12:16 AM1427703 is your event type ID)
4. Get your API Key from Settings > Developer > API Keys
## Adding the Function in Retell
To add the calendar availability function :
1. Enter the following details:
- Tool name (must be unique within that agent)
- API Key from cal.com
- Event Type ID
- Tool description (example: "Checks availability for 30-minute consultation calls")
- (Optional) Add a timezone to be used in the function
2. Click "Save" to complete the setup
## Update Your Agent Prompt
Include explicit instructions in your prompt about when to invoke the function :
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.AI Evy
08/25/2025, 12:16 AMAI Evy
08/25/2025, 12:16 AMle_chemist
08/25/2025, 12:18 AMle_chemist
08/25/2025, 12:18 AMAI Evy
08/25/2025, 12:18 AMAI Evy
08/25/2025, 12:19 AMWhen the user asks about availability or wants to schedule an appointment, call the `check_ghl_availability` function to check available time slots.
## Troubleshooting Tips
Based on community experience, if your webhook isn't working [(3) ]() :
- Make sure you're using the production URL in n8n
- Ensure the HTTP method matches (POST)
- Set the n8n workflow to trigger on "last node finishes"
- Test the webhook works in a fresh agent first
Your n8n workflow will receive the request with the function parameters and can then make the API call to GoHighLevel to retrieve available slots [(1) ]() .AI Evy
08/25/2025, 12:19 AMcheck_ghl_availability (unique, separated with underscore)
- Description: Check available appointment slots from GoHighLevel calendar
3. Select HTTP Method
Choose POST method for your n8n webhook .
4. Add Endpoint URL
Add your n8n webhook URL where Retell will send the request . Make sure it's a valid URL .
5. Define Parameters
Define the parameters using JSON schema format :
json
{
"type": "object",
"properties": {
"date": {
"type": "string",
"description": "The date to check availability for (YYYY-MM-DD format) "
},
"duration": {
"type": "string",
"description": "Duration of appointment in minutes"
}
},
"required": [
"date"
]
}
6. Configure Speech Behavior [(1) ]()
- **Speak during execution**: Enable this so the agent can inform the user it's checking availability
- **Speak after execution**: Enable this so the agent can share the results
7. Update Agent Prompt [(2) ]() [(1) ]()
Include explicit instructions in your prompt:AI Evy
08/25/2025, 12:19 AMAI Evy
08/25/2025, 12:19 AMle_chemist
08/25/2025, 12:22 AMAI Evy
08/25/2025, 12:22 AMAI Evy
08/25/2025, 12:23 AMWhen user selected a slot, please book the appointment by calling the `book_appointment` function.
## Integration with Your Existing Flow
Since you already have the availability checking function set up, your conversation flow would be:
1. User asks about availability
2. Agent calls check_ghl_availability function
3. Agent presents available slots to user
4. User selects a time slot
5. Agent calls book_appointment function to complete the booking [(2) ]()
Your n8n workflow will receive the booking request with all the customer details and appointment information, then make the API call to GoHighLevel to create the appointment [(1) ]() .AI Evy
08/25/2025, 12:23 AMbook_appointment (unique, separated with underscore)
- Description: Book an appointment in GoHighLevel calendar
3. Select HTTP Method
Choose POST method for your n8n webhook.
4. Add Endpoint URL
Add your n8n webhook URL where Retell will send the booking request.
5. Define Parameters
Define the booking parameters using JSON schema format:
json
{
"type": "object",
"properties": {
"date": {
"type": "string",
"description": "The date for the appointment (YYYY-MM-DD format) "
},
"time": {
"type": "string",
"description": "The time for the appointment (HH:MM format) "
},
"duration": {
"type": "string",
"description": "Duration of appointment in minutes"
},
"customer_name": {
"type": "string",
"description": "Customer's full name"
},
"customer_email": {
"type": "string",
"description": "Customer's email address"
},
"customer_phone": {
"type": "string",
"description": "Customer's phone number"
}
},
"required": [
"date",
"time",
"customer_name"
]
}
6. Configure Speech Behavior
- **Speak during execution**: Enable this so the agent can inform the user it's processing the booking
- **Speak after execution**: Enable this so the agent can confirm the booking
7. Update Agent Prompt
Include explicit instructions in your prompt about when to invoke the booking function:AI Evy
08/25/2025, 12:23 AMAI Evy
08/25/2025, 12:23 AMle_chemist
08/25/2025, 12:23 AMle_chemist
08/25/2025, 12:24 AMAI Evy
08/25/2025, 12:24 AMAI Evy
08/25/2025, 12:24 AM{{current_time}} which returns time in PST [(1) ]() [(2) ]() .
You can also use timezone-specific dynamic variables like {{current_time_America/Los_Angeles}} for PST [(1) ]() [(3) ]() .
In your booking function parameters, you can reference the current time in your agent prompt to ensure appointments are scheduled in PST. The {{current_time}} system variable is available by default and doesn't need to be passed in your API calls [(1) ]() .
For your custom booking function, you might want to include timezone context in your prompt so the agent understands to work with PST times when processing appointment requests [(4) ]() .AI Evy
08/25/2025, 12:24 AMAI Evy
08/25/2025, 12:24 AMle_chemist
08/25/2025, 12:25 AMAI Evy
08/25/2025, 12:25 AMAI Evy
08/25/2025, 12:25 AMjson
{
"type": "object",
"properties": {
"date": {
"type": "string",
"description": "The date for the appointment (YYYY-MM-DD format) "
},
"time": {
"type": "string",
"description": "The time for the appointment in PST (HH:MM format) "
},
"timezone": {
"type": "string",
"description": "Timezone for the appointment",
"default": "America/Los_Angeles"
}
},
"required": [
"date",
"time"
]
}
[(1) ]()
2. Use Current Time Variable in Agent Prompt
Include the PST current time in your agent prompt using the system dynamic variable {{current_time}} which defaults to PST, or be more specific with {{current_time_America/Los_Angeles}} [(2) ]() . This helps the agent understand the timezone context when processing booking requests.
3. Update Your Agent Prompt
Add timezone instructions to your prompt:
When booking appointments, always confirm times are in PST (Pacific Standard Time) . Use the current time {{current_time}} as reference. When calling the book_appointment function, ensure all times are converted to PST format.
[(3) ]()
Your n8n workflow can then receive the timezone parameter and handle the PST conversion when making the API call to GoHighLevel.AI Evy
08/25/2025, 12:25 AMAI Evy
08/25/2025, 12:25 AMle_chemist
08/25/2025, 1:27 AMAI Evy
08/25/2025, 1:27 AMAI Evy
08/25/2025, 1:27 AMghl_id variable along with your booking function data, you can use dynamic variables in your custom function. Here's how to set this up:
1. Use Dynamic Variables in Custom Function Properties
You can reference dynamic variables in your custom function's parameter descriptions or URL [(1) ]() . Update your booking function parameters to include the `ghl_id`:
json
{
"type": "object",
"properties": {
"date": {
"type": "string",
"description": "The date for the appointment (YYYY-MM-DD format) "
},
"time": {
"type": "string",
"description": "The time for the appointment in PST (HH:MM format) "
},
"customer_name": {
"type": "string",
"description": "Customer's full name"
},
"ghl_id": {
"type": "string",
"description": "GoHighLevel contact ID: {{ghl_id}}"
}
},
"required": [
"date",
"time",
"customer_name",
"ghl_id"
]
}
2. Ensure Proper Dynamic Variable Setup
Since you've already defined the variable in your create chat request, make sure you're using the correct field name retell_llm_dynamic_variables [(2) ]() :
json
{
"agent_id": "agent_xxxxxxxxxxxxx",
"retell_llm_dynamic_variables": {
"ghl_id": "your_ghl_contact_id_value"
}
}
3. Update Your Agent Prompt
Include instructions in your prompt to use the dynamic variable:
When booking appointments, include the GoHighLevel contact ID {{ghl_id}} in the booking request to associate the appointment with the correct contact.AI Evy
08/25/2025, 1:27 AMAI Evy
08/25/2025, 1:27 AMle_chemist
08/25/2025, 1:54 AMAI Evy
08/25/2025, 1:54 AMle_chemist
08/25/2025, 1:54 AMAI Evy
08/25/2025, 1:55 AMAI Evy
08/25/2025, 1:55 AM{{current_time}}
[(1) ]()
2. Timezone-Specific Current Time
For explicit PST time, use the timezone-specific variable [(2) ]() :
{{current_time_America/Los_Angeles}}
[(1) ]()
3. Include in Your Agent Prompt
Add the current time variable directly in your agent prompt [(3) ]() :
# Context
current_time : {{current_time}}
business hours :
- Monday – Friday: 9:00 AM – 5:00 PM
- Saturday – Sunday: Closed
4. For Chat Agents
Since you're working with SMS/chat agents, include the current time in your agent's global prompt or begin message [(1) ]() . The variable will be automatically populated with the current PST time when the conversation starts [(2) ]() .
These system variables are available by default and don't need to be passed in your API calls [(1) ]() . The {{current_time}} variable provides the current time in "Monday, March 24, 2025 at 02:53:01 PM PDT" format [(2) ]() .AI Evy
08/25/2025, 1:55 AMAI Evy
08/25/2025, 2:03 AMle_chemist
08/25/2025, 2:03 AMAI Evy
08/25/2025, 2:04 AMretell_llm_dynamic_variables in the chat creation request includes any date-related variables if you're setting them.
5. Log the Payload for Debugging
Consider logging the payload sent to your n8n endpoint to identify where the date discrepancy is occurring . This will help determine if the issue is in the LLM's date generation or in your n8n processing.
The community has noted that GPT-4 models sometimes generate dates from October 2023 when not properly constrained with current time context .AI Evy
08/25/2025, 2:04 AMjson
{
"type": "object",
"properties": {
"date": {
"type": "string",
"description": "The date for the appointment in YYYY-MM-DDTHH:MM:SSZ format (UTC timezone) "
}
}
}
[(2) ]() , [(3) ]()
3. Include Current Time Context in Agent Prompt
Add the current time dynamic variable to your agent prompt to provide proper temporal context [(4) ]() :
Current time: {{current_time_America/Los_Angeles}}
When booking appointments, always use dates relative to the current time provided above.AI Evy
08/25/2025, 2:04 AMAI Evy
08/25/2025, 2:04 AMle_chemist
08/25/2025, 2:04 AMAI Evy
08/25/2025, 2:04 AMAI Evy
08/25/2025, 2:05 AMAI Evy
08/25/2025, 2:05 AMAvailable booking dates: {{current_calendar_America/Los_Angeles}}
This provides the LLM with explicit future dates to choose from, preventing past date generation.AI Evy
08/25/2025, 2:05 AMCurrent date and time: {{current_time_America/Los_Angeles}}
When booking appointments, always use dates that are on or after the current date shown above. Never use dates from the past.
2. Use Pass-Through Dynamic Variable for Date
Instead of letting the LLM generate the date, pass the correct current date as a dynamic variable from your chat creation request. Update your function parameter to reference this variable [(2) ]() :
json
{
"type": "object",
"properties": {
"date": {
"type": "string",
"description": "The date for the appointment: {{appointment_date}}"
}
}
}
Then in your chat creation request, include:
json
{
"agent_id": "agent_xxxxxxxxxxxxx",
"retell_llm_dynamic_variables": {
"ghl_id": "your_ghl_contact_id_value",
"appointment_date": "2025-08-25"
}
}
3. Strengthen Your Agent Prompt Instructions
Add explicit date validation instructions [(3) ]() :
IMPORTANT: Today's date is {{current_time_America/Los_Angeles}}.
- Only book appointments for dates that are today or in the future
- Never book appointments for dates in the past
- If a user requests a past date, politely explain that appointments can only be scheduled for future datesAI Evy
08/25/2025, 2:05 AM