Build a SIP Integration: VideoSDK & Twilio for Inbound Outbound Calls! Step-by-Step
Imagine joining an online meeting using just your phone—no apps, no browsers, no internet. This powerful option allows participants to connect via traditional telephony, by creating a bridge between phone systems and modern video conferencing platforms. In this post, we’ll explore how to build a SIP integration using VideoSDK and Twilio for both inbound and outbound VoIP calls.
We’ll break down the flow of calls, set up the project, and show you how to bring this functionality to life using Next.js.
What Is a SIP Integration?
SIP, or Session Initiation Protocol, enables voice and video communications over internet-based networks. With SIP integrations, traditional phone systems can connect to online platforms .
By integrating SIP with VideoSDK’s SIP address and Twilio, you can handle both inbound and outbound calls while linking them to video meetings. This integration is particularly helpful for situations where participants lack internet access, allowing them to simply dial in to join a meeting or receive phone calls initiated by meeting participants.
Understanding Inbound and Outbound Call Flows
Inbound Calls
Inbound calls are initiated by a user or customer dialing a phone number, such as a Twilio-provisioned number. Here’s how the process works:
- User Dialing: A participant dials the Twilio number tied to the SIP integration.
- Call Routing: Twilio receives the call and notifies your server with call details.
- Server Processing: Your server processes the request and sends an invite SIP request to the VideoSDK SIP address.
- Connection Established: Once validated, the caller is connected to the specific video meeting through VideoSDK.
For example, if a customer wants to join a video conference using their phone, they can call a designated number. Following this process, the integration connects them to the meeting.
Outbound Calls
Outbound calls begin with a participant or agent in an online meeting initiating a call to a customer’s phone. The process involves the following steps:
- Call Request Initiated: A participant requests your server to call a specific phone number.
- Server Action: The server notifies Twilio to establish the call.
- User Accepts Call: When the user accepts, the connection is forwarded to the video meeting through VideoSDK.
This two-way communication ensures smooth interaction between online participants and phone users.
Step-by-Step Guide to Setting Up the Project
Clone the Repository
- Start by cloning the project repository. The source code is available on GitHub.
git clone https://github.com/videosdk-community/videosdk-sip-integration
- Navigate to project directory
cd videosdk-sip-integration
- Install dependencies that are required for you application to work
npm install
Configure the Environment
- Set Up the
.env
File: Copy the.env.example
file in the repository and rename it to.env
. - Add VideoSDK Details: Obtain the SIP username, password, and authentication token from the VideoSDK dashboard.
- Generate an authentication token under “API Keys.”
- Get your SIP username and password from the “SIP Config” section.
- Add these details to the
.env
file.
- Configure Twilio: Sign in to your Twilio console.
- Copy your Twilio phone number, Account SID, and Auth Token.
- Paste these values into the
.env
file.
TWILIO_ACCOUNT_SID=your-twilio-account-sid
TWILIO_AUTH_TOKEN=your-twilio-auth-token
VIDEOSDK_SIP_USERNAME=your-videosdk-sip-username
VIDEOSDK_SIP_PASSWORD=your-videosdk-sip-password
NEXT_PUBLIC_TWILIO_PHONE_NUMBER=your-twilio-phone-number
NEXT_APP_URL=http://localhost:3000 # Replace with your production URL
Your .env
file should now contain all necessary credentials.
Running the Application
Once the configurations are complete, start the project using the following command:
npm run dev
The application will run locally on port 3000.