Our friends at OpenAI recently launched their Realtime API, which exposed the multimodal capabilities of their GPT-4o model. At launch, we shared how you could build a voice AI assistant in Node.js you could call from your phone.
Since the launch, we've had many requests to show the opposite scenario - how do you call a phone number using OpenAI's Realtime API and Node.js using Twilio?In this tutorial, I'll show you some demo code which can dial a phone number using Twilio Voice and Media Streams, and the OpenAI Realtime API. I'll show a function which demonstrates how to check if a phone number you provided is allowed to be called, then begin a phone call. Finally, after a user picks up, we'll trigger the OpenAI API to have the AI talk first.
Start by creating and navigating to your project directory, then setting up a new Node.js project.