I am using Telnyx for outbound calls - and have a ...
# ask-ai
g
I am using Telnyx for outbound calls - and have a dispatch rule set to make the call so when we make an aoutbound call the AI agent joins their own room. The call is made - but the AI does not join so it is an empty room, empty call. How can I fix this?
t
Thanks for reaching out, Kalib. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — you're describing an outbound Telnyx call where the SIP participant connects but the AI agent never joins the room. That’s likely because dispatch rules only run for inbound SIP calls; they do not trigger when you create an outbound SIP participant. What you can do to fix it (choose one): • Dispatch the agent in the room token when creating/joining the room (recommended if you can create the room via a participant token). Include
RoomConfiguration.agents
in the participant token so the agent is dispatched automatically when the room is created. • After creating the outbound call (and the room), call the AgentDispatchService API to explicitly dispatch the agent to that room. This works when the room already exists. Quick checks: • Ensure your agent has an
agent_name
(e.g.,
@server.rtc_session(agent_name="my-telephony-agent")
) so it can be dispatched. • Verify the agent server/process is running and connected so it can accept dispatch jobs. If you want, tell me which method you currently use to create the outbound call (CreateSIPParticipant or a token-based room join) and share the agent name — I’ll give exact code snippets for that path. Sources: Agent dispatch | LiveKit docs | SIP dispatch rule | LiveKit docs | Agents telephony integration | LiveKit docs
g
We are creating a SIPParticpant. And the Agent has a agent name. @breezy-insurance-66772.rtc_session(agent_name="HSFL_Regular_Calls") is there. Agent Server is running as this is in the cloud.
t
Thanks — got it: you're creating a SIPParticipant, the agent has an
agent_name
(
HSFL_Regular_Calls
), and the agent server is running. Because dispatch rules don't run for outbound SIP participants, you'll need to explicitly dispatch the agent to the room. Two simple options — pick the one that fits your flow: 1) Dispatch right after creating the SIP participant (recommended since your SIPParticipant already creates the room) • Use the AgentDispatchService to create a dispatch to the room created by
CreateSIPParticipant
. • Minimal required fields:
agent_name
and
room
(you can add
metadata
like phone number). • Example (Python-like pseudocode):
Copy code
dispatch = lkapi.agent_dispatch.create_dispatch(
  CreateAgentDispatchRequest(
    agent_name="HSFL_Regular_Calls",
    room="room-name-from-sipparticipant",
    metadata='{"phone":"+1234567890"}'
  )
)
Call this immediately after
CreateSIPParticipant
. The agent server will receive the JobContext and join the room. 2) Create the room via a participant token that includes
RoomConfiguration.agents
• When a participant joins with a token containing
RoomConfiguration
with
agents=[{agent_name:"HSFL_Regular_Calls"}]
, the agent is dispatched automatically when the room is created. • Use this if you can create the room by joining a control participant with that token before or instead of calling
CreateSIPParticipant
. Quick checks to verify: • Use the exact agent name string
HSFL_Regular_Calls
in the dispatch API. • Confirm the room name returned/used by
CreateSIPParticipant
— dispatch must target that exact room. • Ensure the agent process logs show it receives a dispatch/job after you call the dispatch API. If you want, paste: • the
room
value you get from
CreateSIPParticipant
, and • the snippet you use to call the AgentDispatchService (or tell me your language SDK), and I’ll give an exact code example tailored to your call flow.
g
I am making http requests to make the call. What endpoint should I use?
t
Use the AgentDispatchService HTTP endpoint: POST https://<your-livekit-host>/twirp/livekit.AgentDispatch/CreateDispatch Headers: • Authorization: Bearer <agent-token-with-agent-permissions> • Content-Type: application/json Body (example): { "room": "room-name-from-CreateSIPParticipant", "agent_name": "HSFL_Regular_Calls", "metadata": "{\"phone_number\":\"+1234567890\"}" } Example curl: curl -X POST "https://your-subdomain.livekit.cloud/twirp/livekit.AgentDispatch/CreateDispatch" \ -H "Authorization: Bearer <your-access-token>" \ -H "Content-Type: application/json" \ -d '{ "room": "my-sip-room", "agent_name": "HSFL_Regular_Calls", "metadata": "{\"phone_number\":\"+15105550123\"}" }' Tell me the exact room name you get from CreateSIPParticipant or the language you use and I’ll give a ready-to-use snippet. Sources: Agent dispatch | LiveKit docs
g
[ { "data": "OK" } ] is the response I get from that when I run it. But on the phone I do not hear anything.
t
Thanks — you’re seeing the dispatch API return OK but the agent never speaks. Let’s verify the most common causes and run a few quick checks so we can pinpoint the problem. 1) Confirm exact names • Confirm the
room
value you used in the dispatch request exactly matches the
room_name
passed to
CreateSIPParticipant
. • Confirm the dispatch used the exact agent name string:
HSFL_Regular_Calls
. 2) Verify the agent actually received the job • Check your agent server logs for a dispatch/job arrival right after you call CreateDispatch. Look for JobContext or “dispatch” entries. • If no job appears, the dispatch didn’t reach the agent even though the API returned OK. 3) Confirm the agent joined the room • Use ListParticipants for the room to see if the agent participant is present. • If the agent is not listed, it never joined; if it is listed but silent, proceed to step 4. 4) If agent is listed but no audio on the phone • Check the agent code path on join: ensure it calls session.start()/publish audio or runs generate_reply() as appropriate. • Outbound calls commonly expect the callee to speak first. If you want the agent to speak immediately, trigger the agent to send audio (e.g., call generate_reply() or publish audio) after the agent joins rather than waiting for input. 5) Tokens / permissions / connectivity • Ensure the token used for dispatch has agent permissions (agent or agent_admin) so the dispatch is accepted. • Confirm the agent process is connected to LiveKit and not failing auth or network-wise. 6) Quick commands/tests you can run now • List participants for the room after dispatch and paste the output here. • Paste the exact dispatch request body (with room and agent_name) you sent. • Tail the agent server logs for a few seconds while you trigger CreateSIPParticipant + CreateDispatch and paste any dispatch-related lines. If you share the room name and the dispatch request body (and a short tail of agent logs around the dispatch), I’ll point to the exact next fix. Sources: SIP troubleshooting guide | LiveKit docs | Agents telephony integration | LiveKit docs | livekit/livekit_composite | DeepWiki | Agent dispatch | LiveKit docs
g
Room name is a variable. Generated through a webhook then sent through a HTTP request in N8N "room_name": "outbound_{{ $json.body.customData.contact_id }}"
t
Thanks — since your room name is generated dynamically, let’s verify the interpolated values and logs. Please provide: 1. The exact room string produced for a failing call (copy the final interpolated value, e.g.,
outbound_12345
). 2. The exact JSON body you send to CreateSIPParticipant (mask any secrets). 3. The exact JSON body you send to the AgentDispatch CreateDispatch request (mask secrets). 4. A short tail of your agent server logs (10–20 lines) captured while you trigger the outbound call + dispatch — specifically lines showing connection/auth and any dispatch/job handling. Also confirm: • That N8N interpolation produces identical room strings for both CreateSIPParticipant and CreateDispatch (no extra spaces, braces, or URL-encoding). • The dispatch request uses agent_name "HSFL_Regular_Calls" exactly. Send those three payloads/logs and I’ll pinpoint the mismatch or next fix.
g
outbound_SBxZPdg7L4VVMRezqAhQ { "sip_trunk_id": "ST_Gkyfx9KqK8VZ", "sip_call_to": "", "sip_number": "", "room_name": "outbound_SBxZPdg7L4VVMRezqAhQ[undefined]", "participant_identity": "contact_SBxZPdg7L4VVMRezqAhQ", "job_metadata": "{\"first_name\":\"Kalib\",\"now_time\":\"07:52 AM\",\"now_date\":\"12/1/2025\",\"address\":\"undefined\",\"city\":\"\",\"zip_code\":\"\"}" } { "room_name": "contact_SBxZPdg7L4VVMRezqAhQ", "agentname": "HSFL_Regular_Calls", "metadata": "{\"first_name\":\"Kalib\",\"now_time\":\"07:52 AM\",\"now_date\":\"12/1/2025\",\"address\":\"undefined\",\"city\":\"\",\"zip_code\":\"\"}" } the agent is in the cloud currently. where can I get you those logs from?
t
Good catch — the room names don't match. Your SIPParticipant joined room: outbound_SBxZPdg7L4VVMRezqAhQ[undefined] but you dispatched the agent to: contact_SBxZPdg7L4VVMRezqAhQ Fix the interpolation so both use the exact same room string (for example, dispatch to outbound_SBxZPdg7L4VVMRezqAhQ without the "[undefined]"). If you want, tell me which platform hosts your agent (Docker, Kubernetes, systemd, Cloud Run/Heroku, etc.) and I’ll give the exact command to tail the agent logs and the exact API curl to list participants for the corrected room name.
g
done
It's a Cloud Run Agent.
t
Great — thanks for fixing the room-name mismatch. Can you confirm two quick things so I can close the loop or help further? 1. After your fix, does the agent now join the room (check participant list) and does audio play on the phone? 2. If not, tell me which host your agent runs on (Docker, Kubernetes, Cloud Run, systemd, etc.) and I’ll give the exact command to tail the agent logs and the curl to list participants for the corrected room name
outbound_SBxZPdg7L4VVMRezqAhQ
.
Thanks — since your agent runs on Cloud Run, here are the exact commands and steps to check logs and participants. 1) Tail Cloud Run logs (shows agent connecting and any dispatch jobs) • From Cloud SDK (replace SERVICE and PROJECT): gcloud logs read "projects/PROJECT/logs/run.googleapis.com%2Fcloud-run-events" --project=PROJECT --limit=200 --filter="resource.labels.service_name=SERVICE" --format="json" • Or view in Cloud Console: Cloud Run → select service → Logs. Look for lines showing job/dispatch receipt, JobContext, or errors on connection/auth. 2) List room participants (confirm agent joined) Replace LIVEKIT_HOST and BEARER_TOKEN, and use the corrected room name `outbound_SBxZPdg7L4VVMRezqAhQ`: curl -X GET "https://<LIVEKIT_HOST>/twirp/livekit.RoomService/ListParticipants?room=outbound_SBxZPdg7L4VVMRezqAhQ" \ -H "Authorization: Bearer <BEARER_TOKEN>" \ -H "Content-Type: application/json" 3) If agent joined but phone is silent • Check agent log for publish/start or generate_reply calls after join. • Confirm agent published an audio track or invoked
generate_reply()
. What to paste here if you still see a problem: • 10–20 log lines around the dispatch time (from Cloud Run) showing connection, auth, or job handling. • Output of the ListParticipants curl. If you want, tell me your Cloud Run service name and project and I’ll give the exact gcloud command you should run.
g
Sorry - It's in Livekit Cloud
t
Thanks — since the agent runs in LiveKit Cloud, please confirm: 1) After you fixed the room name, does the agent now appear in the room and does audio play on the phone? If it's still not working, please provide two things and I’ll diagnose next steps: • The output of ListParticipants for the corrected room (
outbound_SBxZPdg7L4VVMRezqAhQ
). Use this curl and paste the JSON: curl -X GET "https://<your-livekit-host>/twirp/livekit.RoomService/ListParticipants?room=outbound_SBxZPdg7L4VVMRezqAhQ" \ -H "Authorization: Bearer <your-token>" \ -H "Content-Type: application/json" • A 10–20 line snippet of LiveKit Cloud agent logs around the dispatch time showing the agent receiving the job or any errors (you can copy from the LiveKit Cloud UI). Once you paste those two outputs I’ll point to the exact fix.
g
this is the current http request - it says that get is not allowed? { "nodes": [ { "parameters": { "url": "https://voice-ai-l3blj7tr.livekit.cloud/twirp/livekit.RoomService/ListParticipants?room=outbound_SBxZPdg7L4VVMRezqAhQ", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Authorization", "value": "Bearer <API KEY>" }, { "name": "Content-Type", "value": "application/json" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ {} ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 384, -176 ], "name": "LiveKit Add Agent to Call1", "id": "76ac7dc4-8803-41ac-93d9-7d6cee87636a" } ], "connections": {}, "pinData": {}, "meta": { "templateCredsSetupCompleted": true, "instanceId": "d30b77be519dee46272db87988a1c7e050005a810009d6262ed9ec22519ebffd" } }
t
You're calling ListParticipants with GET — LiveKit requires POST with the room in the JSON body. Use this in n8n: • Method: POST • URL: https://voice-ai-l3blj7tr.livekit.cloud/twirp/livekit.RoomService/ListParticipants • Headers: ◦ Authorization: Bearer <your-token> ◦ Content-Type: application/json • Body (raw JSON): { "room": "outbound_SBxZPdg7L4VVMRezqAhQ" } Send that and paste the JSON response. If the agent still isn't in the participant list, paste 10–20 lines of LiveKit Cloud agent logs around the dispatch time and the exact dispatch request body you used; I’ll point to the next fix. Sources: Webhooks | LiveKit docs | Job lifecycle | LiveKit docs | Managing participants | LiveKit docs | Managing rooms | LiveKit docs | Log collection | LiveKit Docs
g
The cell phone is in the participants. But not the agent.
t
Thanks — since the phone participant is in the room but the agent is not, two likely causes remain: the dispatch request used the wrong room or the wrong field name for agent. Please retry dispatch exactly like this: POST https://voice-ai-l3blj7tr.livekit.cloud/twirp/livekit.AgentDispatch/CreateDispatch Headers: • Authorization: Bearer <your-agent-token> • Content-Type: application/json Body (raw JSON): { "room": "outbound_SBxZPdg7L4VVMRezqAhQ", "agent_name": "HSFL_Regular_Calls", "metadata": "{\"first_name\":\"Kalib\",\"now_time\":\"07:52 AM\"}" } Notes: • Use the exact room string shown in the participant list (
outbound_SBxZPdg7L4VVMRezqAhQ
). • The field must be
agent_name
(not
agentname
). After you run that, please paste: 1) The JSON response from CreateDispatch. 2) The output of ListParticipants for the room (POST request as I showed earlier). 3) 10–20 lines of agent logs from LiveKit Cloud around the dispatch time (if the agent still doesn’t appear). I’ll diagnose the next step as soon as you share those.
g
where can I get the logs from LiveKit Cloud?
t
In LiveKit Cloud you can view agent logs two ways: 1) LiveKit Cloud dashboard (UI) • Open https://cloud.livekit.io/ and sign in. • Select your Project → left menu Agents. • Click the agent instance you dispatched (look for recent sessions). • Open the Logs or Session timeline view and copy ~10–20 lines around the dispatch time (look for “dispatch”, “JobContext”, or errors). 2) LiveKit CLI • If you have the LiveKit CLI configured, run: ◦ List agents/sessions:
lk agent list --project <PROJECT_ID>
◦ View logs for an agent/session:
lk agent logs --id <AGENT_ID> --follow
(replace
<AGENT_ID>
with the agent/session id from the list) What to paste here: • 10–20 log lines showing the dispatch arrival, JobContext, join attempts, or errors. • The CreateDispatch response JSON (if you still have it). If you tell me your project name and the agent identity or session id, I can tell you which exact entry to open in the dashboard.