How can I connect two livekit agents through conso...
# ask-ai
p
How can I connect two livekit agents through console?
t
Thanks for reaching out, Mario. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Could you help me understand a bit better what you mean by connecting two LiveKit agents through the console? Are you talking about setting up a media connection, managing rooms, or something else? I’m here to help!
p
I'd like to launch two livekit agents using the
console
keyword from the
cli
. The idea is to connect the two agents, so they can talk to each other.
t
Hey there! Just a quick heads-up about the
console
mode in the LiveKit CLI—it’s mainly meant for testing a single agent’s audio and behavior locally, all on its own. It runs in a sort of bubble, without connecting to a LiveKit server or other participants. So, if you were hoping to connect two agents using the
console
keyword, that won’t quite work. But no worries! If you want two agents to interact, here’s a simple way to do it: 1. Run both agents in
dev
mode:
Copy code
uv run agent1.py dev
uv run agent2.py dev
2. Then, use the LiveKit CLI to send both agents into the same room:
Copy code
lk dispatch create --agent-name agent1 --room myroom
lk dispatch create --agent-name agent2 --room myroom
This setup will get both agents connected to a shared room on a LiveKit server, so they can chat and interact in real-time. If you hit any snags or want to chat more about this, just give me a shout—I’m here to help! Sources: Voice AI quickstart | LiveKit Docs | evaluating-agents/README.md | examples/README.md
p
what does the
dev
keyword do again?
t
Hey there! The
dev
keyword in the LiveKit CLI is a handy shortcut to make development and testing easier. It uses some predefined developer credentials—specifically, the API key
devkey
and the API secret `secret`—to connect to a local LiveKit server, usually at
http://localhost:7880
. This way, you don’t have to worry about manually entering credentials when you’re working locally. Just a heads-up, it’s meant for non-production environments and is super helpful for quick testing and debugging. If you want me to explain anything else or have questions, feel free to ask! Sources: cmd/lk/utils.go | README.md | Voice AI quickstart | LiveKit Docs
p
how can I connect an outbound agent to my inbound agent. Both are running locally
t
Could you help me understand if you're trying to simulate a call flow between the outbound and inbound agents just for testing? Also, are both agents running on the same local machine, or are they set up on different instances? Sources: Making calls using SIP | LiveKit Docs | Making calls using SIP | LiveKit Docs | test/lktest-sip-outbound/README.md
p
true for both questions
t
Hey there! If you want to connect an outbound agent to an inbound agent running locally, you can simulate the call flow with these easy steps: 1. Set up two LiveKit environments: You’ll need two LiveKit servers (or just one instance) to manage outbound and inbound calls. Make sure SIP services are turned on. 2. Configure SIP trunks: ◦ Outbound trunk: Set this up with your SIP provider, including a phone number and the necessary authentication details. ◦ Inbound trunk: Configure it to accept calls and link it to a dispatch rule. 1. Create a dispatch rule: On the inbound server, set up a rule that connects incoming calls to a room and triggers the inbound agent. 2. Deploy agents: ◦ Outbound agent: This one will initiate calls to the inbound agent's number. ◦ Inbound agent: This agent answers incoming calls and connects to the assigned room. 1. Initiate the call: Use the LiveKit API or CLI to have the outbound agent dial the inbound agent's number. This will link both agents in their respective rooms. For local testing, you can try out LiveKit's CLI tool
lktest-sip-outbound
to check the call flow and make sure everything’s working smoothly. If you want, I’m here to help with detailed examples or any other questions you have! Sources: test/lktest-sip-outbound/README.md | Making calls using SIP | LiveKit Docs | examples/warm-transfer/README.md
p
So, I have a single project, which listens for inbound connections (phone number calls). This one runs locally with
dev
command. The other agent, makes a phone call to a number that lands in the first project.
t
Hey there! If you want to set up a single LiveKit project to handle inbound calls and also simulate an outbound agent making calls locally, here’s a simple step-by-step guide to help you out: 1. Set up an inbound SIP trunk: First, create a trunk to accept incoming calls to your phone number. You can do this easily using the CLI:
lk sip inbound create inbound-trunk.json
2. Create a dispatch rule: Next, define a rule that routes incoming calls to a room and assigns an agent to handle them:
lk sip dispatch create dispatch-rule.json
3. Set up an outbound SIP trunk: Now, configure a trunk so your agent can make outbound calls. Just use the CLI with your SIP provider details to get this going. 4. Simulate an outbound call: Ready to test? Dispatch your outbound agent to call the inbound number like this:
lk dispatch create --new-room --agent-name outbound-caller --metadata '+15105550100'
5. Run locally: Finally, run the LiveKit SIP service with a local setup to test everything out. Make sure your agents are running in
dev
mode for smooth testing. With this setup, your outbound agent can call the inbound number, which gets routed to a room where the inbound agent is ready to assist. If you want me to walk you through any part or share more examples, just let me know—I’m here to help! Sources: test/integration/sip_test.go | SIP overview | LiveKit Docs | Accepting incoming calls | LiveKit Docs | Agents telephony integration | LiveKit Docs | Making calls using SIP | LiveKit Docs