I have created a self hosted voice agent on liveki...
# ask-ai
q
I have created a self hosted voice agent on livekit, Now I want to use it to make outbound calls and I k dispatch create \ --new-room \ --agent-name my-telephony-agent \ --metadata '{"phone_number": "8861643848"}' Using default project [voiceAgent] Dispatch created: id:"AD_xF4rvjE7W3gY" agent_name:"my-telephony-agent" room:"room-M9CT22nQCUxW" metadata:"{\"phone_number\": \"8861643848\"}" state{created at1757158443254492292} which shows that dispatch is created but no call rings , what step am I misssing?
t
Thanks for reaching out, Abhishek. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! To get your self-hosted voice agent making outbound calls, just follow these simple steps: 1. Set up a SIP trunk: Start by configuring an outbound SIP trunk with a provider like Twilio or Telnyx. This is what lets you actually make the calls. 2. Register the SIP trunk: Next, use the LiveKit CLI to register your SIP provider’s outbound trunk. Just create a JSON file with your SIP provider details and run:
lk sip outbound create outbound-trunk.json
3. Configure the voice agent: Make sure your agent is set up to use that SIP trunk. If you’re using Python, the outbound caller template is your friend:
lk app create --template=outbound-caller-python
For Node.js, you can grab the node-agents-examples repository and set it up from there. 4. Dispatch the agent: Finally, use the LiveKit CLI to dispatch your agent and kick off the call:
Copy code
lk dispatch create \
 --new-room \
 --agent-name outbound-caller \
 --metadata '{"phone_number": "+1234567890"}'
Just double-check that your SIP trunk is properly configured and your agent has all the right environment variables set. If the call still doesn’t ring, no worries—take another look at your SIP trunk setup and peek at the agent logs for any hiccups. Sources: Making outbound calls | LiveKit Docs | Example Applications | livekit/livekit_composite | DeepWiki | Making calls using SIP | LiveKit Docs | agent.py | packages/sip--make-a-call/package.json
q
should I host my voice agent before using it in outbound calls? or can I use self-hosted voice agent to do the outbound call?
t
Hey there! You can definitely use a self-hosted voice agent to make outbound calls. Just make sure it’s properly hosted and up and running on your own infrastructure before you start dialing. This way, it can smoothly connect to the LiveKit server and manage the call process without a hitch. If you haven’t set up your agent yet, no worries! Just get it running on your server and double-check that it’s got all the right environment variables in place — like your SIP trunk details and LiveKit credentials. Once that’s all set, you’ll be good to go and can start making outbound calls with ease.
q
LiveKit API Secret configured: true Creating SIP client... Attempting to create SIP participant... ❌ Error creating SIP participant: TwirpError [Internal Server Error]: twirp error unknown: unexpected status from INVITE response: sip status: 500: Try again later at TwirpRpc.request (/Users/abhishekgadekar/Desktop/voiceAgent/node_modules/.pnpm/livekit-server-sdk@2.13.3/node_modules/livekit-server-sdk/dist/TwirpRPC.js5913) at process.processTicksAndRejections (nodeinternal/process/task queues95:5) at async SipClient.createSipParticipant (/Users/abhishekgadekar/Desktop/voiceAgent/node_modules/.pnpm/livekit-server-sdk@2.13.3/node_modules/livekit-server-sdk/src/SipClient.ts73918) at async entry (/Users/abhishekgadekar/Desktop/voiceAgent/agent.ts19133) { status: 500, code: 'internal', metadata: { error_details: 'CA0SSHVuZXhwZWN0ZWQgc3RhdHVzIGZyb20gSU5WSVRFIHJlc3BvbnNlOiBzaXAgc3RhdHVzOiA1MDA6IFRyeSBhZ2FpbiBsYXRlcho9CiV0eXBlLmdvb2dsZWFwaXMuY29tL2xpdmVraXQuU0lQU3RhdHVzEhQI9AMSD1RyeSBhZ2FpbiBsYXRlcg==', sip_status: 'Try again later', sip_status_code: '500' } }
t
It looks like there’s an issue with creating a SIP participant, showing a 500 status code, which usually means something’s going on with the server. Don’t worry, here are some friendly steps to help you troubleshoot and hopefully fix this: 1. Double-check your SIP Trunk Configuration: Make sure the SIP trunk ID you’re using in the request is correct and set up properly. This includes verifying details like the address and authentication credentials. 2. Look at Timeout Settings: If you’re using the
wait_until_answered
option, confirm the timeout is long enough (the default is 30 seconds, or 80 seconds if
wait_until_answered
is true). 3. Dig into the Error Details: Take a peek at the metadata in the error response for SIP-specific info like
sip_status_code
and
sip_status
. These little clues can shed more light on what’s going wrong. 4. Check Your Logs: Have a look at your LiveKit server logs for detailed info. Search for call IDs, room names, and trunk IDs to trace what’s happening with the SIP call. 5. Make Sure Your SIP Server Is Ready: Confirm that your LiveKit server is all set and properly connected for SIP services. Sometimes, if it’s not ready, errors like this can pop up. If you’re still stuck after trying these, please share your specific SIP trunk setup and any extra logs you have. I’m here to help you get this sorted out! Sources: pkg/service/sip.go | cmd/lk/sip.go | agent.py | LiveKit | livekit/livekit_sip.pb.go