Provide the Agent with the current date.
# support
s
Hi guys, I've already spoken to support, who unfortunately can't help me. Does anyone happen to know how I can give the agent the correct data about today's date and time in the “model”? It works if I say “this year 2025” so that I at least get the correct year in my webhook when I give a date and time in the conversation. But for a request like “can I book an appointment for tomorrow” of course it doesn't work. Thanks in advance. Note: I ve already tried this : "{("now" | date: "Gb %d, %Y, %1:%M %p", "Europe/Berlin"}}" #1211483291191083018 https://cdn.discordapp.com/attachments/1345747524165697537/1345747524417228991/SPOILER_Bildschirmfoto_2025-02-25_um_11.11.42_PM.png?ex=67c5ac8c&is=67c45b0c&hm=210ea4743f1578c9162a1904ecb8046ad9761dafbfece1a02e56f8eb11070791&
v
Hey Steve! 😊 It sounds like you're trying to get the Vapi agent to correctly interpret relative dates like "tomorrow." Here’s how you can handle that: 1. **Capture User's Timezone**: Make sure you're capturing the user's timezone accurately. This can be done by prompting the user or automatically detecting it from their device. 2. **Dynamic Date Handling**: When you want to interpret "tomorrow," you need to adjust the date based on the user's local timezone. For example, if today is February 27, 2025, and the user is in the "Europe/Berlin" timezone, you should calculate tomorrow's date accordingly. 3. **Use the Correct Format**: For your webhook, ensure you're using the correct date format. You can use something like:
Copy code
json
   {
     "date": "{{now | date: 'YYYY-MM-DD', 'Europe/Berlin'}}"
   }
This will give you the correct date for tomorrow based on the user's timezone. 4. **Confirmation Message**: Always confirm the appointment details in the user's local timezone before finalizing. For example:
Copy code
plaintext
   "Great, I've scheduled your appointment for tomorrow at [appointment_time] your local time (Europe/Berlin). Please confirm that this is correct."
By following these steps, you should be able to handle requests for "tomorrow" effectively! If you have any more questions or need further assistance, feel free to ask! 🌟 Sources: - [Detailed Report: Providing Date and Time Data to the VAPI Agent for Booking Appointments](https://discord.com/channels/1211482211119796234/1211483291191083018/1275993578950103141) - [Detailed Report on Date and Time Input Format in VAPI Model for Scheduling Appointments](https://discord.com/channels/1211482211119796234/1211483291191083018/1336345690393149452) - [Detailed Report on Vapi's Handling of Relative Dates](https://discord.com/channels/1211482211119796234/1211483291191083018/1275993578950103141)
l
@Steve.teichmann we have solved this problem through prompt engineering (100% success rate so far). It's a combination of giving the assistant the correct date and examples on how to extrapolate dates like "tomorrow", "next week", etc Note, we update our assistants prompt daily (at midnight) so it has the right date and relevant examples. Below is the section I would recommend adding to your prompt. The variation we use is more robust than this but it is specific to our use case. So you will probably need to tweak this or add more for your use case. -------- [Date Handling] You are capable of interpreting various date inputs and converting them into specific, future dates. The current date is: '03/02/2025'. Always assume the user is referring to a future date, never a past date. Follow these rules when interpreting date inputs: 1. If a specific year is not mentioned, assume the next occurrence of the date. 2. For month names or seasons without a year, assume the next occurrence. 3. For day numbers without a month or year, assume the next occurrence of that day. 4. "Mid-month" typically refers to the 15th of the month. 5. For inputs like "next week" or "in 3 days", calculate based on the current date. Here are some examples of correct interpretations: - "mid-April" → 04/15/2025 - "March 4th" → 03/04/2025 - "February 28th" → 02/28/2026 - "next Tuesday" → 03/04/2025 - "in two weeks" → 03/16/2025
s
@Steve.teichmann I don't see any of your support tickets and don't know with whom you have spoken with.
3 Views