I am creating an outbound call, that I want an age...
# ask-ai
p
I am creating an outbound call, that I want an agent to handle, so far I have the call being made and received, but then there is just silcence and the agent doesn't talk at all
t
Thanks for reaching out, Matthew. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I understand how frustrating it can be when the agent stays silent during an outbound call. Let’s work through this together step-by-step to get it sorted out: • Verify Agent Dispatch: First, make sure the agent is properly dispatched by assigning a name in the dispatch rules and matching it with the agent configuration. This helps ensure the call reaches the right place. • Agent Logic: It’s important to confirm that the agent’s logic is set to wait for user input before responding, especially for outbound calls. This way, the agent knows when to jump in. • Silence Detection: Double-check if silence detection is configured correctly so the system can handle moments when no response is detected. • Outbound Trunk Configuration: Take a look at the SIP endpoint in the trunk configuration to make sure the call connects properly without any hiccups. • Function Tool Behavior: If the agent uses any tools, ensure they either return a response or explicitly manage cases where no reply is generated. This helps avoid unexpected silence. Please feel free to reach out if you’d like me to walk you through any of these steps in more detail or if there’s anything else I can assist you with. I’m here to help! Sources: src/room/track/LocalAudioTrack.ts | livekit-plugins/livekit-plugins-gladia/livekit/plugins/gladia/stt.py | SIP troubleshooting guide | LiveKit Docs | Agents telephony integration | LiveKit Docs | Speech & Audio Processing | livekit/livekit_composite | DeepWiki
p
All of those are setup correctly, and the agent works with inbound calls - it just doesn't seem to do anything with outbound calls. I am using nodejs
t
It sounds like you're experiencing an issue where the agent works well for inbound calls but stays silent during outbound calls. Let’s walk through some Node.js-specific troubleshooting steps together to help get this sorted out: • AgentSession Configuration: It’s important to make sure the agent session is properly set up with VAD, STT, and TTS providers. Here’s an example to guide you:
Copy code
const session = new AgentSession({
  stt: new DeepgramSTT(),
  llm: new OpenAILLM(),
  tts: new CartesiaTTS(),
  vad: new SileroVAD(),
});
Room Name Matching: Double-check that the room name you’re using in the
CreateSIPParticipant
API exactly matches the room the agent should join. This little detail can sometimes cause unexpected behavior. • Agent Logic: For outbound calls, it’s normal for the agent to wait silently until the other person starts speaking. So, make sure your agent is designed to listen for user input before responding. • Silence Detection: Adding silence monitoring can be really helpful, especially to handle situations like voicemail or long pauses. Here’s a simple way to implement it:
Copy code
let userLastSpokeTime = Date.now();
const SILENCE_THRESHOLD = 5000; // 5 seconds

session.on("user_started_speaking", () => {
  userLastSpokeTime = Date.now();
});

setInterval(() => {
  if (Date.now() - userLastSpokeTime > SILENCE_THRESHOLD) {
    console.log("Silence detected; ending call");
    session.disconnect();
  }
}, 1000);
SIP Trunk Configuration: Lastly, please verify that your SIP endpoint settings are correct and align with your provider’s requirements. If you try these steps and still run into issues, please don’t hesitate to reach out. I’m here to help, and we can dive deeper with more diagnostics or examples to get this resolved together. Sources: Speech & Audio Processing | livekit/livekit_composite | DeepWiki | Agents telephony integration | LiveKit Docs | How to detect and handle silence during calls | Understanding "silence detected on local audio track" warning | SIP troubleshooting guide | LiveKit Docs
p
When I do session.start I am using room: ctx.room - but it seems that might be null? What should I be using when its outbound
t
Hi there! When you see that
ctx.room
is null for outbound calls, it usually means the room context hasn’t been set up properly yet. In Node.js, you’ll want to create and manage the room instance explicitly for those outbound calls. Here’s a friendly guide on how to do that: • Create the Room: Use the LiveKit SDK to explicitly create a room instance specifically for your outbound call. • Pass the Room to the Agent: Make sure you pass this room instance to the agent session when you start it. For example:
Copy code
const room = await connectLiveKitRoom({
  url: 'your-livekit-server-url',
  token: 'your-access-token',
});

const session = new AgentSession({
  room: room,
  stt: new DeepgramSTT(),
  llm: new OpenAILLM(),
  tts: new CartesiaTTS(),
  vad: new SileroVAD(),
});

session.start();
Verify Room Connection: Double-check that the room has connected successfully before you pass it along to the agent session. If you’d like, I’m here to help you step-by-step with setting up the room or managing the agent session. Just let me know! Sources: Agents telephony integration | LiveKit Docs | packages/livekit-rtc/README.md | packages/react/src/context/room-context.ts | docs/functions/LiveKitRoom.html
p
Does outbound only work with Python?
t
I’m happy to share that LiveKit outbound call agents aren’t limited to Python—they work wonderfully with Node.js too! There are official examples and documentation available that show you how to implement outbound calling in Node.js, including how to create SIP participants and dial phone numbers programmatically. If you’d like, I’d be more than happy to guide you to some specific examples or help you troubleshoot your Node.js setup. Just let me know how I can support you! Sources: Agents telephony integration | LiveKit Docs | OpenAI Realtime API and LiveKit | LiveKit Docs | OpenAI Realtime API and LiveKit | LiveKit Docs | packages/sip--make-a-call/package.json | README.md
p
If I give you the code can you check what is broken?
t
I understand how frustrating it can be when things aren’t working as expected. While I can’t directly review or debug your code, I’m here to help you every step of the way. If you could share a bit more about the specific issue you’re facing or some relevant parts of your code, I’d be happy to guide you through some troubleshooting steps or help spot where things might be going wrong. Please don’t hesitate to share the details of the part that’s giving you trouble—I’m here to support you and will do my best to assist!
p
It's like the agent isn't in the same room
t
I understand how important it is for the agent to be in the same room as the outbound call. This usually happens when there’s a mismatch between the room the agent joins and the room specified in the
CreateSIPParticipant
API call. Let’s work through this together: • Room Name Matching: Please make sure the room name used when starting the agent exactly matches the
room_name
parameter in the
CreateSIPParticipant
request. A helpful tip is to use
ctx.room.name
to dynamically pass the correct room name. • Agent Dispatch: When dispatching the agent, try using the
--new-room
flag. This helps ensure both the agent and the outbound call connect to the same dynamically created room. • Verify SIP Participant: After you call
createSIPParticipant
, keep an eye on the
sip.callStatus
attribute to see if the call moves to an active state. If you’d like, I’m here to guide you through these steps or help troubleshoot any issues with room synchronization. Just let me know! Sources: Agents telephony integration | LiveKit Docs | Making calls using SIP | LiveKit Docs | Making calls using SIP | LiveKit Docs | Making outbound calls | LiveKit Docs | packages/sip--make-a-call/README.md