awf
03/20/2025, 4:53 PMawf
03/20/2025, 5:06 PMawf
03/20/2025, 5:12 PM~Stu~ CoreAspect.Agency
03/21/2025, 5:28 AM~Stu~ CoreAspect.Agency
03/21/2025, 5:30 AMShubham Bajaj
03/22/2025, 6:51 AMjavascript
{
"assistantId": "f4632dda-f6f8-46e2-b6d1-00a6319959e1",
"assistantOverrides": {
"variableValues": {
"CurrentDayAndTime": "Thursday, March 20, 2025 12:00 AM",
"TodaysDate": "Thursday, March 20, 2025",
"TomorrowsDate": "Friday, March 21, 2025",
"today_start": "2025-03-20",
"today_end": "2025-03-20",
"tomorrow_start": "2025-03-21",
"tomorrow_end": "2025-03-21",
"thisWeekend_start": "2025-03-21",
"thisWeekend_end": "2025-03-23",
"nextWeekend_start": "2025-03-28",
"nextWeekend_end": "2025-03-30"
}
}
}
Important: As mentioned, VAPI only supports string values without line breaks in variableValues, which is why I've flattened the nested structure from your original JSON.
### Configure your assistant's system prompt to reference these values:
You are an assistant with access to accurate date and time information.
IMPORTANT: Always use the following real-time data when discussing dates or times:
- Current date and time: {{CurrentDayAndTime}}
- Today's date: {{TodaysDate}}
- Tomorrow's date: {{TomorrowsDate}}
For date ranges, refer to the following predefined periods:
- Today: {{today_start}} to {{today_end}}
- Tomorrow: {{tomorrow_start}} to {{tomorrow_end}}
- This weekend: {{thisWeekend_start}} to {{thisWeekend_end}}
- Next weekend: {{nextWeekend_start}} to {{nextWeekend_end}}
NEVER use your training data's date information. Always refer to the provided values above.
### Implementation Steps:
1. Update your assistant's system prompt to reference these variable names using the double curly brace syntax: {{VariableName}}
2. Create a function in your application that prepares the assistantOverrides object before each call:
javascript
function prepareAssistantOverrides() {
const now = new Date();
// Generate all the date strings
const currentDateTime = formatDate(now, {includeTime: true});
const todaysDate = formatDate(now);
const tomorrow = new Date(now);
tomorrow.setDate(now.getDate() + 1);
const tomorrowsDate = formatDate(tomorrow);
// Create weekend dates
const thisWeekendStart = getNextDayOfWeek(now, 5); // Friday
const thisWeekendEnd = new Date(thisWeekendStart);
thisWeekendEnd.setDate(thisWeekendStart.getDate() + 2); // Sunday
const nextWeekendStart = new Date(thisWeekendStart);
nextWeekendStart.setDate(thisWeekendStart.getDate() + 7); // Next Friday
const nextWeekendEnd = new Date(nextWeekendStart);
nextWeekendEnd.setDate(nextWeekendStart.getDate() + 2); // Next Sunday
return {
variableValues: {
"CurrentDayAndTime": currentDateTime,
"TodaysDate": todaysDate,
"TomorrowsDate": tomorrowsDate,
"today_start": formatDateISO(now),
"today_end": formatDateISO(now),
"tomorrow_start": formatDateISO(tomorrow),
"tomorrow_end": formatDateISO(tomorrow),
"thisWeekend_start": formatDateISO(thisWeekendStart),
"thisWeekend_end": formatDateISO(thisWeekendEnd),
"nextWeekend_start": formatDateISO(nextWeekendStart),
"nextWeekend_end": formatDateISO(nextWeekendEnd)
}
};
}
// Helper functions
function formatDate(date, options = {}) {
return date.toLocaleString('en-US', {
weekday: 'long',
month: 'long',
day: 'numeric',
year: 'numeric',
...(options.includeTime ? {
hour: 'numeric',
minute: 'numeric',
hour12: true
} : {})
});
}
function formatDateISO(date) {
return date.toISOString().split('T')[0];
}
function getNextDayOfWeek(date, dayOfWeek) {
const resultDate = new Date(date);
resultDate.setDate(date.getDate() + (7 + dayOfWeek - date.getDay()) % 7);
return resultDate;
}Shubham Bajaj
03/22/2025, 6:51 AMjavascript
const response = await vapi.calls.create({
assistantId: "your-assistant-id",
assistantOverrides: prepareAssistantOverrides(),
// other call parameters...
});