How to create an inbound call agent? That will acc...
# ask-ai
s
How to create an inbound call agent? That will accept inbound call and greet? I have telenyx SIP
t
Thanks for reaching out, Rahul. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To create an inbound call agent that accepts SIP calls from Telnyx and greets the caller, follow these steps: 1. Set up your environment variables with your LiveKit credentials:`export LIVEKIT_URL=<your LiveKit server URL> export LIVEKIT_API_KEY=<your API key> export LIVEKIT_API_SECRET=<your API secret>` 2. Create a voice agent using the LiveKit CLI:`lk app create --template voice-pipeline-agent-python`Assign a unique
agent_name
(e.g., "inbound-agent") in your agent code for dispatch configuration. 3. Set up an inbound SIP trunk for your Telnyx number. Create a file like `inbound-trunk.json`:`{ "trunk": { "name": "My inbound trunk", "numbers": ["+15105550100"] } }`Then run:`lk sip inbound create inbound-trunk.json` 4. Configure a dispatch rule to route inbound calls to your agent. Create `dispatch-rule.json`:`{ "rule": { "dispatchRuleIndividual": { "roomPrefix": "call-" } }, "roomConfig": { "agents": [{ "agentName": "inbound-agent" }] } }`Then run:`lk sip dispatch create dispatch-rule.json` 5. Add a greeting in your agent code after the session starts:`await session.generate_reply( instructions="Greet the user and offer your assistance." )` 6. Start your agent:`python agent.py dev` With this setup, inbound calls to your Telnyx number will be routed to a LiveKit room, where your agent will join and greet the caller automatically.
s
will it work locally?
t
Hey there! Let's talk about running a LiveKit inbound SIP call agent on your local machine. If you're looking to test things out with an external SIP provider like Telnyx, there are a couple of things you'll want to keep in mind. • Your local SIP service needs to be internet-accessible. This means you'll need a public IP address and open up those SIP signaling (5060) and media (10000–20000) ports to let external traffic flow through. • Docker users, pro tip: Use host networking when running your container. SIP uses a lot of UDP ports, and standard Docker networking can make that tricky to manage. I know it might sound a bit technical, but here's the deal: if your local setup isn't publicly reachable, those inbound calls from Telnyx won't make it to your agent. No worries, though! For local testing, you can always use mock SIP clients or local test tools. Just keep in mind that to get real inbound calls, you'll need to make your service publicly accessible. Sources: test/integration/sip_test.go | Self-hosted SIP server | LiveKit Docs