Making an outbound call to Twilio number, call is ...
# ask-ai
a
Making an outbound call to Twilio number, call is going but agent is not joining that call. I have not set "agent_name" in WorkerOption so that it can be dispatched automatically when any request comes to this livekit server on which the agent is connected.
t
Thanks for reaching out, Hiren. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I want to help you make sure an agent joins an outbound call to a Twilio number smoothly, especially when
agent_name
isn’t set in
WorkerOptions
. If everything is set up correctly, automatic dispatch should do the trick. Here are some important steps to keep in mind: • Make sure the agent worker is up and ready to take on jobs. • Start the agent session before dialing so you don’t miss that initial connection. • Use the
create_sip_participant
API to kick off the call and wait for the participant to connect. If you find automatic dispatch a bit unreliable, no worries! You might want to try explicit dispatch for more control. Just let me know if you’d like me to walk you through either method or help troubleshoot any specific issues you’re facing—I’m here to support you every step of the way. Sources: Agent dispatch | LiveKit Docs | Agents telephony integration | LiveKit Docs | README.md
s
@abundant-father-33863 I just posted that: https://livekit-users.slack.com/archives/C088ZNU7QQ5/p1761820048826089 Is it similar ?
t
Thank you so much for sharing the link! I’m sorry, but I’m not able to access external Slack links directly. If you could kindly share a brief summary of the issue or question from the Slack post, that would be really helpful. This way, I can better understand if it relates to what you’re experiencing and offer you the best support possible.
a
I'm creating that participant using livekit cli command and not from my code
t
When creating a participant using the LiveKit CLI, you can easily make sure an agent joins the call by embedding agent dispatch in the access token. Here’s a simple way to do it: 1. First, create a token with the
--agent
flag to specify the agent, and include any metadata you need using
--job-metadata
. For example:
Copy code
lk token create --room "my-room" --identity "my-participant" --join --agent "test-agent" --job-metadata '{"key":"value"}' --valid-for 1h
1. Next, use this token when creating the participant. For SIP participants, you can run:
Copy code
lk sip participant create --room "my-room" --identity "sip-participant" --trunk "your-trunk-id" --call "+1234567890" --wait
This way, the agent will be automatically dispatched as soon as the participant joins. If you have any questions or need a hand with this, please don’t hesitate to ask—I’m here to help! Sources: SIP Integration & Telephony | livekit/livekit_composite | DeepWiki | cmd/lk/sip.go | examples/agent-dispatch/index.ts | examples/agent_dispatch.py