DEV Community

Ayyaz Zafar
Ayyaz Zafar

Posted on

Twilio Phone Calls with Node js - AI Voice Agent Part 1

In this video (Part 1), I set up Twilio to dial actual phone numbers and stream audio back to my Node.js server. This is the foundation for building automated sales calls, appointment reminders, and AI cold callers.

Watch Video: https://www.youtube.com/watch?v=tq8055cA2sM

πŸ“‹ What we cover:
0:00 - Introduction & Goals
0:46 - Project Setup (Node.js + TypeScript)
2:27 - Environment Variables
3:06 - WebSocket Server Setup
3:43 - Twilio Webhook for Voice Calls
5:03 - Handling WebSocket Messages
7:17 - Make Outbound Call Function
9:05 - Twilio Account Setup
10:07 - Buying a Phone Number
12:00 - ngrok Setup for Local Development
13:35 - Testing the Call
15:58 - Recap & What's Next

πŸ› οΈ Tech Stack:
β€’ Node.js + Express
β€’ TypeScript
β€’ Twilio Voice API
β€’ WebSocket
β€’ ngrok

πŸ“¦ Dependencies:
npm install express twilio ws dotenv
npm install -D typescript ts-node @types/node @types/express @types/ws

πŸ”— Resources:
β€’ Twilio: https://www.twilio.com
β€’ ngrok: https://ngrok.com
β€’ Source Code: [GitHub link if available]

πŸ“Ί Series Playlist:
Part 1: Twilio Setup (This video)
Part 2: ElevenLabs Integration (Coming soon)
Part 3: Full AI Conversation Demo (Coming soon)
Part 4: Custom Knowledge Base (Coming soon)

πŸ’‘ What's Next?
In Part 2, I'll connect ElevenLabs so the AI can actually talk back and have real conversations!

Top comments (0)