This guide explains how to set up outbound calls via SIP using your LiveKit agent. By integrating SIP trunking with your LiveKit Agent, you can initiate calls to phone numbers and interact with users over the phone. This setup is useful for:
- Call center callbacks: Automatically return calls to customers.
- Product check-ins: Follow up on purchased items.
- Sales calls: Reach out to potential customers.
- Appointment reminders: Notify clients of upcoming appointments.
- Surveys: Collect feedback through automated calls.
Prerequisites
- Phone number on one of the SIP Trunk providers (like Twilio or Telnyx)
- LiveKit Cloud project or a self-hosted instance of LiveKit server
- LiveKit CLI
Steps:
1. Set Up Your SIP Trunk
Follow the SIP Quickstart guide to configure your SIP trunk and phone number. This will allow your LiveKit server to initiate outbound calls to phone numbers via SIP.
Ensure you complete the following in the SIP Quickstart:
- Configure the SIP server: Choose either LiveKit Cloud or your self-hosted SIP server.
- Create a SIP trunk with your provider: Establish a connection between your phone number and the LiveKit SIP server.
- Add an Outbound Trunk in LiveKit: Register your provider's Outbound Trunk with LiveKit, including authentication credentials.
2. Set Up Your Agent
Once you've finished the SIP quickstart guide, set up your agent using one of the Agent Quickstart guides. This creates the agent that interacts with the people you are calling.
You'll need to choose one of the following agent types:
- Speech-to-Speech MultimodalAgent: Processes speech directly and responds with speech for natural low-latency conversations.
- Component-based VoicePipelineAgent: Uses a Text-to-Speech (TTS) -> Large-Language-Model (LLM) -> Speech-to-Text (STT) pipeline for fine grained control over conversation steps.
In most cases, we recommend using the Speech-to-Speech MultimodalAgent for its simplicity, low latency, and natural conversation flow.
Follow the steps in the Agent Quickstart to create and start your agent.
3. Make Outbound Call
Now that your SIP trunk and agent are set up, you can initiate outbound calls from any backend server. This includes the process where you're running the Agent itself.
First, create a JSON file with your participant details. For example:
{"sip_trunk_id": "<your-trunk-id>","sip_call_to": "<phone-number-to-dial>","room_name": "my-sip-room","participant_identity": "sip-test","participant_name": "Test Call"}
Then, create the SIP participant using the LiveKit CLI:
lk sip participant create sipParticipant.json
4. Test your outbound agent
Test the outbound calling setup by initiating a call to your own phone number:
- Initiate the Call: Use your LiveKit CLI, Python, or Node application code to start the call.
- Answer the Call: When your phone rings, answer it to join the LiveKit room.
- Interact with the Agent: Have a conversation with your agent over the phone.