Hello LiveKit Team and community Hi <@U08CKJH7C12...
# telephony
k
Hello LiveKit Team and community Hi @refined-appointment-81829 I'm also new in Livekit and have a issue with audio in my Outbound calls via SIP, the agent is not connected. I do my research and I think I do everything well and learn more about details but I can't see a way to fix this and find some solution. I'm using pyhon - API - Livekit Cloud Project is: p_699kw3y045w Session ID: RM_VDdNYT4XFygT Room session ID: RM_VDdNYT4XFygT I already sent you the RECAP in DM. Please help me if you can.
r
Make sure you are using a unique room name each call.
k
Thanks! there I have update my python code and I can't hear from my agent again. This is my Call ID: SCL_HbfkKpPXfvYg I will sent the PCAP in DM
r
I see multiple calls for the room that call went too. make sure you are using unique room names for each call.
k
Sure, For now I will change the name on every call. How I can fix the audio issue, as I see my agent is not connecting?
r
I think that is your issue. Fix that and see if it works
k
Copy code
I already set unique name for room and I have same issue with audio.

There is my python code from my windows 10 machine:

import time
import jwt
import requests

# ============================================================
# :closed_lock_with_key: LIVEKIT CREDENTIALS (FROM DASHBOARD)
# ============================================================

LIVEKIT_API_KEY = "My_LIVEKIT_API_KEY "
LIVEKIT_API_SECRET = "My_LIVEKIT_API_SECRET "

LIVEKIT_BASE_URL = "<https://lagent-vjsmrvrs.livekit.cloud>"

# ============================================================
# :telephone_receiver: SIP + AGENT CONFIG
# ============================================================

ROOM_NAME = "sip-room-audio-test-004"

# SIP caller
CALLER_IDENTITY = "sip-caller-004"
CALLER_NAME = "SIP Caller"
SIP_TRUNK_ID = "ST_YVKTAZjazUSa"
DIAL_NUMBER = "XXX905908"

# Agent
AGENT_ID = "CA_CXVqqec98MpN"
AGENT_IDENTITY = "audio-agent-004"
AGENT_NAME = "Audio Test Agent 004"

# ============================================================
# :globe_with_meridians: LIVEKIT API ENDPOINTS
# ============================================================

SIP_URL = f"{LIVEKIT_BASE_URL}/twirp/livekit.SIP/CreateSIPParticipant"
AGENT_URL = f"{LIVEKIT_BASE_URL}/twirp/livekit.Agents/StartAgent"

# ============================================================
# :key: ADMIN JWT (ONE TOKEN FOR EVERYTHING)
# ============================================================

def generate_admin_jwt(identity: str) -> str:
    now = int(time.time())

    payload = {
        "jti": f"admin-{now}",
        "iat": now,
        "exp": now + 3600,
        "iss": LIVEKIT_API_KEY,
        "sub": "admin",
        "identity": identity,

        # SIP permissions
        "sip": {
            "admin": True,
            "call": True,
            "connect": True
        },

        # Agent permissions
        "agent": {
            "start": True
        },

        # Room + media permissions
        "video": {
            "room": "*",
            "roomJoin": True,
            "roomCreate": True,
            "canPublish": True,
            "canSubscribe": True
        }
    }

    return jwt.encode(payload, LIVEKIT_API_SECRET, algorithm="HS256")


# ============================================================
# :arrow_forward: STEP 1 — START AGENT FIRST
# ============================================================

admin_jwt = generate_admin_jwt(AGENT_IDENTITY)

headers = {
    "Authorization": f"Bearer {admin_jwt}",
    "Content-Type": "application/json"
}

agent_body = {
    "agent_id": AGENT_ID,
    "room_name": ROOM_NAME,
    "participant_identity": AGENT_IDENTITY,
    "participant_name": AGENT_NAME
}

print("\n:arrow_forward: Starting Agent...")
agent_response = requests.post(AGENT_URL, json=agent_body, headers=headers)
print("Agent Status:", agent_response.status_code)
print(agent_response.text)

if agent_response.status_code != 200:
    raise RuntimeError(":x: Agent failed to start")

# VERY IMPORTANT: allow agent to publish audio
time.sleep(2)


# ============================================================
# :telephone_receiver: STEP 2 — CREATE SIP CALL
# ============================================================

sip_body = {
    "sip_trunk_id": SIP_TRUNK_ID,
    "sip_call_to": DIAL_NUMBER,
    "room_name": ROOM_NAME,
    "participant_identity": CALLER_IDENTITY,
    "participant_name": CALLER_NAME,
    "wait_until_answered": True,
    "play_dialtone": True
}

print("\n:telephone_receiver: Creating SIP Call...")
sip_response = requests.post(SIP_URL, json=sip_body, headers=headers)
print("SIP Status:", sip_response.status_code)
print(sip_response.text)

if sip_response.status_code != 200:
    raise RuntimeError(":x: SIP call failed")

print("\n:white_check_mark: SUCCESS — Agent + SIP should now have AUDIO")
r
You have a new call ID that is using unique room names?
I can look and see what the next issue is
k
Hello @refined-appointment-81829, Yes, I have: SCL_3zfbiny45MyN SCL_9jNasXhpi3gd SCL_pk6qL5LpxQLD Can you check please?
r
Does it work if you run the agent with
console
?
k
I have some issue with python version and then try to develop it via API
Are you suggest do same from console? what you suggest, it's better for use windows 10 for it or ubuntu machine?
r
I think either should work but I don't know anything about Windows. I would use Ubuntu
k
Sure, I will use ubuntu also then
r
Try with
python agent.py console
and see if that works
That way you can see if the issue is SIP or something else.
k
Sure, I will start setup it on my ubuntu. I need only that guide as I understand right?
r
what do you mean?
r
Make sure everything works then add in telephony
k
Sure. first I will try to connect to my cloud agent from the console and then add my SIP. Thank you for give me a direction. I will post the results there..
r
Run the console version locally first.
In cloud you will need to use
dev
or
start
🙌 1