This guide explains how to set up inbound calls via SIP to your LiveKit agent. By integrating SIP trunking with your Agent, users can call a phone number and interact directly with your AI-powered voice assistant. This setup is great for things like:
- Call centers: Automate customer interactions and reduce wait times.
- Customer service: Provide immediate assistance through an AI agent.
- Sales inquiries: Allow customers to ask questions about products or services.
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
Handling incoming calls with your Agents is a straightforward process. As long as you have a SIP trunk that can add participants to a LiveKit room, your agent will automatically join the room and start interacting with the caller.
The following steps take you through the process of creating your SIP trunk and starting an agent that can handle inbound calls. At the end of the quickstart, you'll have an Agent that is capable of speaking to a user over the phone.
1. Set Up Your SIP Trunk
Follow the SIP Quickstart guide to configure your SIP trunk and phone number. This enables users to connect to LiveKit rooms via phone calls.
Specifically, ensure you complete the following in the SIP Quickstart guide:
- 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.
- Set up an Inbound LiveKit Trunk: Instruct LiveKit to accept calls to your phone number.
- Add a Dispatch Rule: Route incoming calls to a specific LiveKit room.
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 callers.
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.
Once your agent is running, it will automatically join any new room created by the dispatch rule you created when a call is received.
3. Test your Agent
With both the SIP trunk and the agent created, test your setup:
- Call the Phone Number: Dial the phone number associated with your SIP trunk.
- Agent Joins the Room: When your call is dispatched to a LiveKit room, your Agent will automatically join the room.
- Interact with the Agent: Engage in a conversation with your agent!