This Node.js application demonstrates how to build a voice AI receptionist for a fictional community center.
The application uses Ultravox Realtime and Twilio. It handles both incoming and outgoing calls, with a specific focus on managing student lesson reminders and appointments. There are accompanying videos that go into detail about building the application:
This code was developed during a series of livestreams. The records are available:
- Session 1 (Thursday, January 23, 2025) Recording
- Session 2 (Friday, January 24, 2025) Recording
- Session 3 (Thursday, January 30, 2025) Recording
The application includes:
- Automated lesson reminder calls using voice AI
- Calendar management integration with Cal.com
- Student information database integration
- Dynamic call routing and transfer capabilities
- Multi-stage conversation management
- Node.js (v20 or higher)
- An Ultravox API key
- A Twilio account with:
- Account SID
- Auth Token
- A phone number
- A Cal.com account with:
- API key
- Existing event type
- SQLite database (for student information)
- A way to expose your local server to the internet (e.g., ngrok)
- Clone this repository
- Install dependencies:
pnpm install
- Configure your environment variables:
Create a file named
.env
and add the following:
ULTRAVOX_API_KEY='your_ultravox_api_key_here'
CALCOM_API_KEY='your_cal_api_key_here'
CALCOM_EVENT_TYPE_ID='your_event_type_id'
TWILIO_ACCOUNT_SID='your_twilio_account_sid'
TWILIO_AUTH_TOKEN='your_twilio_auth_token'
TWILIO_PHONE_NUMBER='your_twilio_phone_number'
DESTINATION_PHONE_NUMBER='your_transfer_destination_number'
TOOLS_BASE_URL='your_ngrok_url'
-
Set up your database:
- Place your students.csv file in the
data/
directory - The CSV should contain columns for: first_name, last_name, email, phone, emergency_contact, emergency_contact_phone
- Place your students.csv file in the
-
Start your server:
pnpm start
This application uses nodemon to provide automatic reloading if files are updated.
- Expose your local server:
ngrok http 3000
- Update your Twilio webhook:
- Go to your Twilio phone number settings
- Set the webhook URL for incoming calls to:
https://your-ngrok-url/twilio/incoming
- Set HTTP method to POST
- Automatic connection to AI agent
- Natural language understanding
- Dynamic tool selection based on conversation context
- Call transfer capabilities to human agents
- Scheduled lesson reminders
- Integration with Cal.com calendar
- Student database lookup
- Emergency contact management
- Rescheduling capabilities
- Provides a GitHub Action (dailyreminders.yml) that will run daily to send reminders
- Call transfer functionality
- Calendar availability checking
- Appointment booking/rescheduling
- Active call tracking
├── index.js # Main application entry point
├── db.js # Database configuration and operations
├── ultravox-config.js # AI configuration and system prompts
├── ultravox-utils.js # Utility functions for Ultravox API
├── .github/
│ ├── dailyreminders.yml # Daily job to send reminders
├── routes/
│ ├── twilio.js # Call handling and Twilio integration
│ ├── cal.js # Calendar operations and reminders
│ └── rag.js # Knowledge base integration
└── data/
└── students.csv # Student information database
- POST
/incoming
- Handle incoming calls - POST
/transferCall
- Transfer active call - GET
/active-calls
- List current active calls - POST
/makeOutboundCall
- Initiate outbound call
- POST
/checkAvailability
- Check calendar availability - POST
/createBooking
- Create new appointment - GET
/upcomingBookings
- List upcoming appointments - POST
/sendLessonReminders
- Process and send reminder calls
- Start the server and expose it via ngrok
- Call your Twilio number to test incoming call handling
- Use the
/cal/sendLessonReminders
endpoint to test reminder calls
Server running on port 3000
Successfully imported X students
Incoming call received
Creating Ultravox call...
Got joinUrl: [URL]
Call initiated: [CallSID]
Common issues and solutions:
-
Calls not connecting:
- Verify Ultravox API key
- Check ngrok URL in Twilio settings
- Verify server is running and accessible
- Check server logs for errors
-
Reminder calls failing:
- Verify student phone numbers are in E.164 format
- Check database connection
- Verify Cal.com API key and event type ID
- Monitor call logs in Twilio console
-
Calendar integration issues:
- Verify Cal.com API key permissions
- Check event type ID exists
- Verify timezone settings
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the Apache 2.0 - see the LICENSE file for details.