livekit/python-sdks

Answer SIP call

Closed this issue · 2 comments

Hi there, I'd like to know how can I answer a SIP call using the sdk...

what I'd like to do is attach a "controller" to a room created by a SIP call, and listen to room events and then do some stuff, but I'm facing the problem that the call isn't answered.

this is some code, which I hope provides more context:

### main.py
from livekit.agents import AutoSubscribe, JobContext, WorkerOptions, cli

async def entrypoint(ctx: JobContext):

    # Connect to the LiveKit room
    # indicating that the agent will only subscribe to audio tracks
    await ctx.connect(auto_subscribe=AutoSubscribe.AUDIO_ONLY)

    agent = TestAgent()

    await asyncio.sleep(1)

    agent.start(ctx.room)

if __name__ == "__main__":
    cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))

### TestAgent.py

class TestAgent:

    def start(self, room: rtc.Room):
        print("Room: ", room)
        
        @room.on("participant_connected")
        def on_participant_connected(participant: RemoteParticipant):
            self._on_participant_connected(participant)
        
        @room.on("sip_dtmf_received")
        def on_sip_dtmf(dtmf: rtc.SipDTMF):
            self._on_sip_dtmf(dtmf)

Thanks in advance for any help.

what do you mean by answer a SIP call using the sdk? for inbound calls, the agent gets dispatched automatically into the caller's room.

Yes, according to the logs in the console, both of the participants are connected to the room, but, in the practice the call keeps ringing, here's a diagram that shows what I mean:

{714F38F9-B99E-4B7F-9495-475FC1CEFE07}

and these are the logs:

{CD971A97-DBDA-41CF-8ADC-AACE9249BFA0}