Pulling in Date and Time
# support
f
Can someone take a look at my screen recording to understand why date and time from N8N isn't being passed to VAPI correctly? I'm still new, but I've been on this for 3 days (in spare time) https://www.awesomescreenshot.com/video/37768592?key=65317a3b054c30f5bfb1ba45dec49d0e
j
Best way to pull in date and time is through VAPI's liquid js dynamic variable. https://docs.vapi.ai/assistants/dynamic-variables
a
Hey Frank, Jonas is exactly right. We make it really easy to pull that information in dynamically through this feature. Here is a list of our default dynamic variables:
f
Thanks guys, but how do I use this to make sure my calendars etc are using the correct timezone?
s
@Frank Jaegar🦾🦊 VAPI uses LiquidJS for dynamic variables, which allows for powerful date/time formatting with timezone support. By default, VAPI uses UTC for all its date/time variables (
{{now}}
,
{{date}}
,
{{time}}
, etc.). To handle specific timezones, you can use the date filter with a timezone parameter:
Copy code
{{ "now" | date: "%b %d, %Y, %I:%M %p", "America/New_York" }}
### 2. Passing Date/Time from N8N to VAPI When sending data from N8N to VAPI, you should: 1. **Format the date in N8N**: Ensure your N8N workflow outputs dates in a consistent format (ISO 8601 is recommended:
YYYY-MM-DDTHH:mm:ss.sssZ
) 2. **Pass the date to VAPI**: In your N8N-to-VAPI integration, set up the variable values:
Copy code
json
{
  "assistantId": "your-assistant-id",
  "assistantOverrides": {
    "variableValues": {
      "appointmentDate": "2024-03-15T14:30:00.000Z"  // Example date from N8N
    }
  },
  "customer": {
    "number": "+1xxxxxxxxxx"
  },
  "phoneNumberId": "your-phone-id"
}
3. **Use timezone formatting in VAPI**: In your VAPI assistant message templates, use the date filter with the appropriate timezone:
Copy code
Your appointment is scheduled for {{ appointmentDate | date: "%b %d, %Y at %I:%M %p", "America/Los_Angeles" }}
### 3. Handling Different Timezones for Different Users If you need to support users in different timezones: 1. **Store user timezone in N8N**: Keep the user's timezone preference in your database 2. **Pass timezone as a variable**: Send both the date and the timezone as variables:
Copy code
json
{
  "assistantOverrides": {
    "variableValues": {
      "appointmentDate": "2024-03-15T14:30:00.000Z",
      "userTimezone": "America/Chicago"
    }
  }
}
3. **Use the dynamic timezone in VAPI**:
Copy code
Your appointment is scheduled for {{ appointmentDate | date: "%b %d, %Y at %I:%M %p", userTimezone }}
### 4. Debugging Tips If you're still experiencing issues: 1. **Verify N8N output format**: Ensure N8N is outputting dates in a consistent, standard format 2. **Log the variables**: Add debug logging to verify what VAPI is receiving 3. **Test with static values**: Try hardcoding values first to verify your template works 4. **Check timezone names**: Ensure you're using valid IANA timezone names (e.g., "America/New_York", not "EST")
f
Thanks
6 Views