How samarth30/ai-voice-agent works
Project type and purpose
• This is a single‐service Node.js application that acts as a real‐time “voice assistant,” connecting incoming phone calls on a Twilio voice‐capable number to OpenAI’s Realtime API via bi‐directional audio streaming. Users call a Twilio number, Twilio forwards audio to your Node.js app, which then streams it to OpenAI, receives AI responses, and sends synthesized speech back through Twilio.
File structure
• Top level:
• index.js – the single Express‐style HTTP/WebSocket server entrypoint
• .env.example – outlines required environment variables (Twilio creds, OpenAI API key, port)
• package.json / package-lock.json – Node.js dependencies including twilio and openai SDKs
• README, LICENSE, CODE_OF_CONDUCT, .gitignore – documentation and metadata
• No subdirectories; all logic lives in index.js. Deployment and build are trivial (just “node index.js”).
README for additional insights
• Describes use of Ngrok to expose the local server to Twilio’s webhooks at /incoming-call
• Explains two WebSocket connections: one to Twilio Media Streams and one to OpenAI Realtime API
• Lists Twilio products (Programmable Voice, Media Streams) and OpenAI Realtime API as core technologies