I just deployed an agent and I want to make a call...
# ask-ai
b
I just deployed an agent and I want to make a call. No sip exists
t
Thanks for reaching out, Wesley. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m sorry you ran into that. I’m responding to your note that you “just deployed an agent and want to make a call” but are seeing “No sip exists.” That message means your deployment doesn’t have a configured SIP trunk yet, which is required to make/receive phone calls. I can help get you past this. Quick questions so I can give exact next steps: • Are you using LiveKit Phone Numbers (bought via the LiveKit Console) or a third‑party SIP provider (Twilio, etc.)? • Do you want to make an outbound call (agent calls a PSTN number) or receive an inbound call to your agent? • What are the agent name and room name where the agent is running? • If you’ve already tried anything, please share the exact CLI/API command or error log you saw. While you gather that, here are the two common ways to fix it: • If you want the easiest path (inbound + trunk config handled for you): Purchase a phone number in the LiveKit Console under Telephony > Phone Numbers — that automatically configures an inbound trunk. • If you prefer a third‑party SIP provider: Configure that provider to route calls to LiveKit and then create an outbound/inbound SIP trunk in LiveKit pointing at the provider. And for making an outbound call once a trunk exists: 1. Create or confirm a dispatch rule that assigns your agent to a room (so agents are available to handle the call). 2. Create a SIP participant for the room using the SIP trunk id and target phone number (example call uses the LiveKit API). Tell me which SIP option you’re using and the agent/room names and I’ll give the exact commands and a short checklist to verify everything (trunk id, dispatch rule, room state). Sources: Agents telephony integration | LiveKit Documentation | Outbound Calling Script | LiveKit Documentation
b
can I make the call via API? From a python application
t
Yes — you can make calls via the LiveKit API from a Python application. I’ll walk you through the required pieces and give a concise example to create an outbound SIP participant (which places the call). First, a few prerequisites and a quick checklist so the call will succeed. What you need before calling: • A configured SIP trunk (either a LiveKit phone number or a third‑party SIP trunk). “No sip exists” means a trunk hasn’t been configured yet. • A room where your agent is running and the agent is present/available. • API credentials (API key/secret or whatever your deployment requires) accessible to your Python app. Quick checklist to verify: • Confirm a SIP trunk ID with
lk sip outbound list
(or from the Console). • Confirm your agent is connected in the target room (room name and agent identity). • Confirm network/auth from your Python app can reach the LiveKit control API. Python example (outline): 1) Install the LiveKit Python client (if you already have the SDK, use it; otherwise use the requests HTTP client). 2) Call the Create SIP Participant endpoint with the room name, trunk id, and the number to call. Minimal example using a generic HTTP POST (replace placeholders):
Copy code
import requests
import os

LIVEKIT_API_URL = "<https://api.livekit.example/v1>"   # replace with your LiveKit control API base URL
API_KEY = os.environ.get("LIVEKIT_API_KEY")
API_SECRET = os.environ.get("LIVEKIT_API_SECRET")
ROOM_NAME = "my-room"
SIP_TRUNK_ID = "ST_..."         # obtain from lk sip outbound list or Console
TO_NUMBER = "+1234567890"       # number you want to call
PARTICIPANT_ID = "caller"

# Example payload - adapt field names to your control API's request schema
payload = {
  "room_name": ROOM_NAME,
  "sip_trunk_id": SIP_TRUNK_ID,
  "sip_call_to": TO_NUMBER,
  "participant_identity": PARTICIPANT_ID
}

# Simple auth header example — adapt to your auth method (API key/secret, bearer token, etc.)
headers = {
  "Authorization": f"Basic {API_KEY}:{API_SECRET}",
  "Content-Type": "application/json"
}

resp = <http://requests.post|requests.post>(f"{LIVEKIT_API_URL}/sip/participants", json=payload, headers=headers)
print(resp.status_code, resp.text)
Notes and next steps: • If you use the official LiveKit Python SDK, the function name will be similar to
create_sip_participant
(use the SDK’s request object and auth). • If you get authentication errors, confirm your API credentials and endpoint URL. • If you get a “No sip exists” error again, confirm the SIP trunk ID and that the trunk is active. If you want, tell me: • The SIP method you’re using (LiveKit phone number vs third‑party provider). • The room name and agent identity. I’ll provide a tailored Python snippet using the LiveKit Python client (or exact HTTP endpoint and required JSON schema) and the exact auth header format you should use.
b
dont want a sip, I just want to make the call. You know, similar to console run, but from the server
t
Thanks — I hear you: you want to initiate a phone call from your server (like the Console’s “Run” action) but without configuring a SIP trunk. I’ll clarify what’s possible and ask one quick question so I can give the exact next step. Short answer: • To place or receive PSTN (regular phone number) calls, a SIP trunk is required. There isn’t a way to reach the public telephone network (PSTN) without a SIP trunk or a LiveKit phone number (which configures a trunk for you). • If you do not need to call a PSTN phone and instead want to create a WebRTC call (server-to-client or client-to-client), you can do that from your server without SIP by creating rooms and participants via the API/SDK. Please tell me which of these you mean: • Do you need to call a PSTN phone number (a regular cellphone/landline)? — if yes, a SIP trunk (or buying a LiveKit phone number which handles the trunk) is required. • Or do you want to initiate an in-app WebRTC call (connect a server/agent to a browser or mobile client)? — if yes, I’ll show the API/SDK steps to create a room and add a participant from your Python server. If you confirm “PSTN” I’ll show the simplest path (buy a LiveKit phone number via the Console which auto-provisions the trunk) and the exact server API call used by the Console to place the call. If you confirm “WebRTC”, I’ll provide a concise Python example to create a room and create a participant (the server-side equivalent of the Console run).
b
can I do it using node?
t
Thanks — I can help with that. I’m responding to your question about initiating a call from your server using Node.js (like the Console “Run” feature). Quick clarification so I give the right code: • Do you want to call a PSTN phone number (a real cellphone/landline)? If yes, note that reaching PSTN requires a SIP trunk or a LiveKit phone number (the Console uses a trunk behind the scenes). • Or do you want to initiate an in‑app WebRTC call (connect an agent/server to a browser or mobile client) without PSTN? Tell me which one you need. Once you confirm, I’ll provide a concise Node.js example showing the exact API/SDK call and the auth/parameters you should use.
b
WebRTC
t
Thanks — I’m responding to your confirmation that you want to initiate a WebRTC call from a Node.js server (no SIP/PSTN involved). You can do this by creating a room and generating participant tokens on the server; clients (browser/mobile) then connect using those tokens and establish a WebRTC session. Below is a concise Node.js recipe you can use. 1) Install the server SDK
Copy code
npm install livekit-server-sdk
2) Server-side: create room / generate join tokens • Use
RoomServiceClient
to manage rooms if you need server-side control (optional — rooms are auto-created when participants join). • Use
AccessToken
to mint tokens for each participant/agent. Example (ES module):
Copy code
import { RoomServiceClient, AccessToken, Grants } from 'livekit-server-sdk';

// Set these env vars: LIVEKIT_API_KEY, LIVEKIT_API_SECRET, LIVEKIT_URL (e.g. "<https://your-livekit-host>")
const apiKey = process.env.LIVEKIT_API_KEY;
const apiSecret = process.env.LIVEKIT_API_SECRET;
const livekitHost = process.env.LIVEKIT_URL; // should include protocol and host

// Optional: use RoomServiceClient when you want to create/update rooms or list participants
const roomService = new RoomServiceClient(apiKey, apiSecret, { host: livekitHost });

// Helper to create a JWT token for a participant
function createJoinToken(identity, roomName) {
  const at = new AccessToken(apiKey, apiSecret, { identity });
  // grant join to a single room
  const grants = new Grants({ roomJoin: true, room: roomName });
  at.addGrant(grants);
  return at.toJwt();
}

// Example usage
const roomName = 'my-webrtc-room';
const agentIdentity = 'agent-123';
const userIdentity = 'user-456';

// Optionally ensure room exists (rooms are usually auto-created on join)
async function ensureRoom(name) {
  try {
    await roomService.createRoom({ name });
  } catch (err) {
    // ignore if already exists or handle errors as needed
  }
}

(async () => {
  await ensureRoom(roomName);

  const agentToken = createJoinToken(agentIdentity, roomName);
  const userToken = createJoinToken(userIdentity, roomName);

  // Return these tokens to the clients that will connect (agent and user)
  console.log('agent token:', agentToken);
  console.log('user token:', userToken);
})();
3) Client-side (browser or Node WebRTC client) • Clients use the tokens you generated to connect via the LiveKit client SDK (livekit-client). • Example (browser):
Copy code
import { Room } from 'livekit-client';

const room = new Room();
await room.connect("<wss://your-livekit-ws-host>", agentToken);
// publish tracks or subscribe as needed
Notes and tips • If you want the server itself to act as a participant (publish audio/video from the server), you can use a headless WebRTC client or a server-side WebRTC implementation to join the room with the token you generated for the server identity. • Use
RoomServiceClient
when you need explicit room lifecycle management (create, list participants, force disconnect, etc.). If you only need to mint tokens, creating tokens alone is sufficient because rooms are created automatically when the first participant joins. • Keep tokens short-lived in production for security; mint them per-join request and return to authenticated clients. • Ensure your LIVEKIT_URL (and WS URL used by clients) match your deployment and that your server can reach the LiveKit control endpoint. If you’d like, I can: • Provide a full example where the server creates an "agent" token and immediately triggers a web client connection (useful to simulate Console Run). • Show how to publish an audio track from a Node.js process (server-side participant) if you need the server to actively send audio into the room. Which of those would help you next — a server-as-participant example, or full client + server token flow? Sources: Server-side | livekit/livekit_composite | DeepWiki