s
Hi
t
Thanks for reaching out, Sujith. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hi there! How can I help you today? I'm here to make sure you get the support you need.
s
Give an working agent code to make outboundcall and lk dispatcg
t
I'm happy to guide you through creating a working agent for making outbound calls using LiveKit Dispatch. Just follow these steps, and feel free to reach out if anything feels unclear along the way: 1. Set Up Outbound Trunk: First, you'll want to configure an outbound SIP trunk in LiveKit. Connect with your SIP trunking provider and then retrieve the
sip_trunk_id
by running this command:
lk sip outbound list
. This will get you started on the right foot. 2. Use the Python Agent Framework: Next, clone the outbound caller Python example. After that, install the necessary dependencies and set your environment variables, including
LIVEKIT_URL
,
LIVEKIT_API_KEY
,
LIVEKIT_API_SECRET
, and
SIP_OUTBOUND_TRUNK_ID
. This setup is key for your agent to work smoothly. 3. Modify Agent Code: In your
agent.py
, you’ll want to use the
CreateSIPParticipant
API to dial numbers. Here’s a little example to help you visualize:
Copy code
sip_participant = await lkapi.sip.create_sip_participant(
    api.CreateSIPParticipantRequest(
        room_name=room_name,
        sip_trunk_id=os.getenv("SIP_OUTBOUND_TRUNK_ID"),
        sip_call_to=phone_number,
        participant_identity="phone_user",
    )
)
4. Dispatch the Agent: When you’re ready, use the LiveKit CLI or Python API to dispatch your agent and kick off the call. Here’s an example CLI command for you:
Copy code
lk dispatch create \
  --new-room \
  --agent-name outbound-caller \
  --metadata '{"phone_number": "+1234567890", "transfer_to": "+9876543210"}'
5. Run the Agent Worker: Finally, start the agent worker so it can listen for dispatches by running:
python3 agent.py dev
. This will keep everything running smoothly. If you'd like to dive deeper, the Voice AI Telephony Guide and Making Outbound Calls documentation are fantastic resources. And of course, if you have any questions or need a hand with any step, I’m here to help! Sources: Agents telephony integration | LiveKit Docs | Using Wavix to accept and make calls | LiveKit Docs | README.md | telephony/survey_caller/make_survey_calls.py | Making outbound calls | LiveKit Docs
s
Thia code not working properly how run this
t
I'd love to help you with the issue you're experiencing with the code. Could you please share a bit more detail? For instance: • Are you seeing any specific error messages? • Is the agent having trouble connecting to the room or making the call? • Have you double-checked that the environment variables are set up correctly (like
LIVEKIT_URL
,
LIVEKIT_API_KEY
,
SIP_OUTBOUND_TRUNK_ID
)? Once I have a clearer picture, I'll do my best to guide you through resolving the problem.
s
Showing error creating sip participant twrip error
t
It looks like the "creating SIP participant twrip error" can be a bit tricky, but don’t worry—I’m here to help you through it! This error usually pops up because of some hiccups with the SIP trunk setup, phone number formatting, or authentication. Let’s walk through some steps together to get this sorted: 1. Check SIP Trunk Configuration: First, please make sure your
SIP_OUTBOUND_TRUNK_ID
is correctly set and starts with
ST_
. Also, double-check that your authentication credentials (username/password) are accurate and accepted by your SIP provider. 2. Validate Phone Number Format: It’s important that your phone number is in the E.164 format, which includes the country code (for example,
+1
if you’re in the US). Removing any non-digit characters and confirming the number has the right amount of digits can make a big difference. 3. Review Error Metadata: Taking a closer look at the error details like
sip_status_code
and
sip_status
can really help pinpoint the issue. For instance, a 403 error might suggest an authentication problem, while a 404 could mean the number isn’t valid. 4. Monitor Call Status: Keep an eye on whether the SIP participant is added to the room and watch events such as
sip.callStatus
to track how the call is progressing. 5. Confirm Service Availability: Lastly, please verify that the SIP service is up and running, and that you have the necessary administrative permissions for SIP operations. If you happen to have the specific
sip_status_code
or error message handy, feel free to share it with me. That way, I can give you more personalized guidance to get this resolved smoothly. Sources: Making outbound calls | LiveKit Docs | agent.py | packages/sip--make-a-call/src/make-call.ts | Secure trunking | LiveKit Docs | pkg/service/sip.go
s
Need to use sid auth token for outbound call. It work without for inbound calls
t
To help you use a SID and auth token for outbound SIP calls in LiveKit, here’s a simple step-by-step guide you can follow: 1. Configure an Outbound SIP Trunk: Start by using your SID as the
auth_username
and your auth token as the
auth_password
when setting up the trunk. Here’s an example configuration to give you a clear idea:
Copy code
{
  "trunk": {
    "name": "twilio-outbound",
    "address": "twilio.pstn.example.com",
    "numbers": [
      "+1234567890"
    ],
    "auth_username": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "auth_password": "your_auth_token"
  }
}
2. Initiate the Call: Next, you can use the
CreateSIPParticipant
API to place the call through your configured trunk. Here’s how it might look:
Copy code
{
  "sip_trunk_id": "trunk_abc123",
  "sip_call_to": "+1987654321",
  "room_name": "meeting-room-1",
  "sip_number": "+1234567890"
}
3. Monitor Call Status: It’s important to keep an eye on attributes like
sip.callStatus
to see how the call is progressing—whether it’s
dialing
,
ringing
, or
active
. Just a quick reminder to keep your credentials safe and avoid hardcoding them. If you run into any questions or need help with a specific SIP provider or SDK, please don’t hesitate to reach out—I’m here to assist you! Sources: packages/sip--um-actually/src/setup-twilio.ts | SIP APIs | LiveKit Docs | livekit-api/livekit/api/sip_service.py | lib/livekit/sip_service_client.rb | livekit-protocol/src/livekit.rs