t23
04/11/2025, 5:43 AMVapi Support Bot
04/11/2025, 5:45 AMjavascript
import express from 'express';
const app = express();
app.use(express.json());
const BUSINESS_HOURS = {
timezone: 'America/New_York', // Change to your timezone
weekdayStart: '09:00',
weekdayEnd: '17:00',
weekdayAssistantId: 'your-business-hours-assistant-id',
weekendAssistantId: 'your-after-hours-assistant-id'
};
function isBusinessHours() {
const now = new Date();
const localTime = new Intl.DateTimeFormat('en-US', {
timeZone: BUSINESS_HOURS.timezone,
hour: 'numeric',
minute: 'numeric',
weekday: 'long',
hour12: false
});
const localDateTime = localTime.format(now);
const isWeekend = localDateTime.includes('Saturday') || localDateTime.includes('Sunday');
if (isWeekend) return false;
const currentTime = localDateTime.split(', ')[1];
return currentTime >= BUSINESS_HOURS.weekdayStart && currentTime <= BUSINESS_HOURS.weekdayEnd;
}
app.post('/assistant-request', (req, res) => {
const response = {
assistantId: isBusinessHours()
? BUSINESS_HOURS.weekdayAssistantId
: BUSINESS_HOURS.weekendAssistantId
};
res.json(response);
});
app.listen(3000, () => {
console.log('Server running on port 3000');
});
Vapi Support Bot
04/11/2025, 5:45 AMhttps://your-domain.com/assistant-request
)
4. Remove any default assistant/squad assignment
This configuration tells Vapi to check with your server to determine which assistant should handle each incoming call. [Source](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1341224148667600976)
## 4. Import Your Existing USA Phone Number
If you haven't already, you'll need to import your existing USA phone number into Vapi:
- You can import phone numbers via the dashboard by navigating to the "Phone Numbers" section and clicking the "Import" button
- For providers like Twilio, you'll need to input your Account SID and Auth Token
- Alternatively, you can use the /phone-numbers/import
endpoint
[Source](https://docs.vapi.ai/quickstart/phone/inbound)
With this setup, when someone calls:
- During business hours: They'll be connected to your human assistant
- Outside business hours or on weekends: They'll automatically be handled by your Vapi assistant
Is there anything specific about this setup you'd like me to explain in more detail?
Sources:
- [Discord Thread on Time-Based Routing](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1341224148667600976)
- [Vapi Quickstart Guide for Inbound Calls](https://docs.vapi.ai/quickstart/phone/inbound)
- [Discord Thread on Importing Phone Numbers](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1334941334368419850)Vapi
04/11/2025, 8:05 PM