i have a sip call that i dispatch using ```async ...
# ask-ai
b
i have a sip call that i dispatch using
Copy code
async def main():
    livekit_api = api.LiveKitAPI()
    request = CreateSIPParticipantRequest(
        room_name=args.room,
        sip_trunk_id=args.trunk,
        sip_call_to=args.phone,
        participant_identity=f"sip-{args.call_id}",
        krisp_enabled = True,
        wait_until_answered = True,
        play_dialtone = True,
    )
    
    try:
        participant = await livekit_api.sip.create_sip_participant(request)
        print(f"Successfully created {participant}!")
    except Exception as e:
        print(f"Error creating SIP participant: {e}")
    finally:
        await livekit_api.aclose()
        #update_call_status(args.code, args.call_id,args.prenom, "closed")
        
if __name__ == "__main__":
    asyncio.run(main())
t
Thanks for reaching out, timothe. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
It looks like your code for dispatching a SIP call using the LiveKit API is well put together! To help everything run smoothly, here are a few important things to double-check: • Make sure the
sip_trunk_id
matches an outbound SIP trunk that’s properly set up in your LiveKit configuration. • The
sip_call_to
parameter should be formatted in E.164 style. • Confirm that your authorization token includes the SIP
call
grant to allow the call. • Review optional parameters like
krisp_enabled
,
wait_until_answered
, and
play_dialtone
to ensure they’re set just the way you need. If you run into any specific issues or see error messages, please don’t hesitate to share them—I’m here to help you work through it! Sources: Make outbound calls | LiveKit docs | SIP APIs | LiveKit docs | ivr-nagivator/flask_livekit/extension.py | lib/livekit/sip_service_client.rb
b
i want to stop this call instantly because it keeps going even when i stop the script
t
To quickly stop the SIP call, here are a couple of easy options you can try: • Delete the Room: You can use the
delete_room
API to end the entire room. This will disconnect everyone, including the SIP participant. It’s the simplest way to wrap up the call right away. • Transfer the SIP Participant: If you’d prefer to keep the room going but want to disconnect just the SIP participant, the
TransferSIPParticipant
API lets you transfer them out smoothly. If you’d like, I’m here to help you with the steps for either option—just let me know! Sources: Call forwarding | LiveKit docs | pkg/sip/server.go | Agents telephony integration | LiveKit Docs