https://retellai.com/?utm_source=discord&utm_medium=seo logo
,I've a problem with SMS agent, It's not picking t...
# ❓・ai-evy-support
l
@AI Evy, I've a problem with SMS agent, It's not picking the variable {{user_name}}. I've added this variable in both create chat and chat completion webhooks as follows: Create Chat: { "agent_id": "agent_xxxxxxxxxxxxx", "user_name": "{{ $('Webhook').item.json.body.first_name }}" } Chat Completion: { "chat_id": "chat_xxxxxxxxxxxx", "content": "{{ $('Webhook').item.json.body['Message Body'] }}", "user_name": "{{ $('Webhook').item.json.body.first_name }}" }
a
Thanks for tagging me @le_chemist. I'll look through relevant sources and get back to you shortly.
​ To learn more, see the sources I considered: [[1] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[2] Create Chat](https://docs.retellai.com/api-references/create-chat) [[3] Create Chat Completion](https://docs.retellai.com/deploy/create-chat-completion) ​
### Answer For chat agents, dynamic variables need to be passed in the
dynamic_variables
field, not as a top-level parameter [(1) ]() . Here's the correct format for your Create Chat request [(2) ]() :
Copy code
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) ]() :
Copy code
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 .
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
l
Thank you sir
@AI Evy I'm using this but it's still not working: { "agent_id": "agent_xxxxxxxxxxxxx", "dynamic_variables": { "user_name": "{{ $('Webhook') .item.json.body.first_name }}" } }
a
Thanks for the follow-up, @le_chemist. I'll get back to you soon.
### Answer For chat agents, the correct field name is
retell_llm_dynamic_variables
, not
dynamic_variables
[(1) ]() . Your request should be:
Copy code
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) ]() .
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
l
@AI Evy, help me to setup a custom funtion to check availability in calendar
a
Thanks for the follow-up, @le_chemist. I'll get back to you soon.
## For SMS/Chat Agents If you're working with SMS agents (as mentioned in your thread) , make sure to include the current time dynamic variable in your agent prompt for accurate availability checking [(2) ]() . Use the format:
{{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) ]() .
### Answer Retell AI provides a pre-built calendar availability function that integrates with Cal.com [(1) ]() . Here's how to set it up: ## Prerequisites First, you'll need to set up Cal.com : 1. Create a Cal.com account at [cal.com]() 2. Configure your event type in the "Event Types" section 3. Get your Event Type ID from the URL (e.g., if the URL is ` then
1427703
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 :
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.
​ To learn more, see the sources I considered: [[1] Check Calendar Availability](https://docs.retellai.com/build/check-availability) [[2] Calendar Availability](https://discord.com/channels/1186424376300679209/1395791084709347399) [[3] Function Node Overview](https://docs.retellai.com/build/conversation-flow/function-node) [[4] Function Calling Overview](https://docs.retellai.com/build/single-multi-prompt/function-calling) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
l
it's not for cal.com. i just want to run a custom function that will go to n8n which will request slots from gohighlevel
@AI Evy it's not for cal.com. i just want to run a custom function that will go to n8n which will request slots from gohighlevel
a
Thanks for the follow-up, @le_chemist. I'll get back to you soon.
Copy code
When 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) ]() .
### Answer Based on the sources, here's how to set up a custom function that calls an n8n webhook to request slots from GoHighLevel: ## Steps to Create Your Custom Function 1. Add Custom Function in Dashboard [(1) ]() Click "+ Add" in the tools section and select "Custom Function" from the dropdown menu . 2. Configure Function Details [(2) ]() [(1) ]() - Name:
check_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 :
Copy code
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:
​ 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) [[3] Calling n8n webhook from custom function not working](https://discord.com/channels/1186424376300679209/1391268662849306656) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
l
@AI Evy I need a function for booking as well
a
Thanks for the follow-up, @le_chemist. I'll get back to you soon.
Copy code
When 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) ]() .
### Answer Based on the sources, here's how to create a custom booking function that integrates with your n8n workflow and GoHighLevel: ## Steps to Create Your Custom Booking Function 1. Add Custom Function in Dashboard [(1) ]() Click "+ Add" in the tools section and select "Custom Function" from the dropdown menu. 2. Configure Function Details - Name:
book_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:
Copy code
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:
​ To learn more, see the sources I considered: [[1] Book Calendar](https://docs.retellai.com/build/book-calendar) [[2] Automate Scheduling with AI Appointment Booking | Retell AI](https://www.retellai.com/features/book-appointments) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
l
i want the time is pst
@AI Evy I want time in pst
a
Thanks for the follow-up, @le_chemist. I'll get back to you soon.
### Answer For PST time in your Retell AI agent, you can use the built-in system variable
{{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) ]() .
​ To learn more, see the sources I considered: [[1] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[2] Discord message from @zz4chy on 2025-03-08](https://discord.com/channels/1186424376300679209/1294891368505937952/1347968047993848002) [[3] timezone](https://discord.com/channels/1186424376300679209/1351244751520796722) [[4] Discord message from @nocodecreative.io on 2024-12-15](https://discord.com/channels/1186424376300679209/1186462578310910112/1317840635717222432) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
l
no, the time for booking request should be in pst @AI Evy
a
Thanks for the follow-up, @le_chemist. I'll get back to you soon.
### Answer ### Answer For ensuring your booking request times are in PST, you have a few options: 1. Add Timezone Parameter to Your Custom Function Update your booking function parameters to include timezone specification:
Copy code
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) "
    },
    "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:
Copy code
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.
​ To learn more, see the sources I considered: [[1] Custom Function](https://docs.retellai.com/build/conversation-flow/custom-function) [[2] Platform Changelogs | Retell AI](https://www.retellai.com/changelog) [[3] Build a multi-prompt agent](https://docs.retellai.com/build/single-multi-prompt/write-multi-prompt) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
l
@AI Evy, i want to pass the ghl_id variable alongwith the booking funtion data. i've defined the variable in the create chat request
a
Thanks for the follow-up, @le_chemist. I'll get back to you soon.
### Answer To pass your
ghl_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`:
Copy code
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) ]() :
Copy code
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:
Copy code
When booking appointments, include the GoHighLevel contact ID {{ghl_id}} in the booking request to associate the appointment with the correct contact.
The dynamic variable
{{ghl_id}}
will be available throughout the conversation once set during chat creation [(3) ]() . When the booking function is called, the LLM will automatically populate the
ghl_id
parameter with the value from your dynamic variable.
​ To learn more, see the sources I considered: [[1] Custom Function](https://docs.retellai.com/build/conversation-flow/custom-function) [[2] List Chat](https://docs.retellai.com/api-references/list-chat) [[3] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
l
how do I provide current date time is pst to the agent?
a
Thanks for the follow-up, @le_chemist. I'll get back to you soon.
l
@AI Evy how do I provide current date time is pst to the agent?
a
​ To learn more, see the sources I considered: [[1] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[2] Platform Changelogs | Retell AI](https://www.retellai.com/changelog) [[3] Discord message from @omar.13. on 2025-08-14](https://discord.com/channels/1186424376300679209/1186462578310910112/1405622441702854696) ​
### Answer ### Answer To provide current date and time in PST to your agent, you can use Retell AI's built-in system dynamic variables [(1) ]() . Here are your options: *1. Default Current Time (PST) * Use the default system variable which returns time in America/Los_Angeles (PST) [(2) ]() :
Copy code
{{current_time}}
[(1) ]() 2. Timezone-Specific Current Time For explicit PST time, use the timezone-specific variable [(2) ]() :
Copy code
{{current_time_America/Los_Angeles}}
[(1) ]() 3. Include in Your Agent Prompt Add the current time variable directly in your agent prompt [(3) ]() :
Copy code
# 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) ]() .
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
Thanks for the follow-up, @le_chemist. I'll get back to you soon.
l
@AI Evy, the function is sending old date, almost 14 months in past: { "type": "object", "properties": { "date": { "type": "string", "description": "The date for the appointment (YYYY-MM-DD format) " }, "ghl_id": { "type": "string", "description": "GoHighLevel contact ID: {{ghl_id}}" }, "time": { "type": "string", "description": "The time for the appointment in PST (HH:MM format) " }, "customer_name": { "type": "string", "description": "Customer's full name" } }, "required": [ "date", "time", "customer_name", "ghl_id" ] }
a
4. Verify Dynamic Variables Are Not Being Overridden Ensure that your dynamic variables are correctly passed to the function without being overridden by default values [(1) ]() . Check that your
retell_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 .
### Answer This issue with custom functions sending old dates (14 months in the past) is a known problem that has been reported in the community [(1) ]() . Based on the available sources, here are the troubleshooting steps to resolve this: 1. Ensure Strict Date Format Compliance The date format must strictly match 'YYYY-MM-DDTHH:MM:SSZ' with the 'Z' indicating UTC time . Your current format description only specifies "YYYY-MM-DD format", which may be causing the issue. 2. Update Your Function Parameter Description Modify your date parameter to be more specific about the format:
Copy code
json
{
  "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) ]() :
Copy code
Current time: {{current_time_America/Los_Angeles}}

When booking appointments, always use dates relative to the current time provided above.
​ To learn more, see the sources I considered: [[1] custom function unable to read dynamic variables as payload's input](https://discord.com/channels/1186424376300679209/1351866528680902697) [[2] Custom Function](https://docs.retellai.com/build/conversation-flow/custom-function) [[3] Integrate any system with custom function](https://docs.retellai.com/build/single-multi-prompt/custom-function) [[4] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
l
issue is in the date generation: @AI Evy
a
Thanks for the follow-up, @le_chemist. I'll get back to you soon.
​ To learn more, see the sources I considered: [[1] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[2] Date Time issue](https://discord.com/channels/1186424376300679209/1365666912557858828) [[3] Prompt Engineering](https://www.retellai.com/glossary/prompt-engineering) [[4] Platform Changelogs | Retell AI](https://www.retellai.com/changelog) ​
4. Alternative: Use Current Calendar Variable You can also use the calendar system variable which shows a 14-day calendar in PST [(1) ]() [(4) ]() :
Copy code
Available booking dates: {{current_calendar_America/Los_Angeles}}
This provides the LLM with explicit future dates to choose from, preventing past date generation.
### Answer ### Answer Since the issue is in the date generation by the LLM, here are specific solutions to fix this: 1. Add Current Time Context to Your Agent Prompt Include the current time dynamic variable directly in your agent prompt to provide proper temporal context [(1) ]() :
Copy code
Current 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) ]() :
Copy code
json
{
  "type": "object",
  "properties": {
    "date": {
      "type": "string",
      "description": "The date for the appointment: {{appointment_date}}"
    }
  }
}
Then in your chat creation request, include:
Copy code
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) ]() :
Copy code
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 dates
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.