how many sip twilio numbers can i assign to a clou...
# ask-ai
l
how many sip twilio numbers can i assign to a cloud deployed agent in livekit. depending on which number the caller is calling into(inbound call), can i switch the data instructions?
t
Thanks for reaching out, Istiaque. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Great news! You can definitely assign multiple Twilio SIP numbers to a cloud-deployed agent in LiveKit. The system is designed to support multiple numbers per inbound trunk, and there’s no strict limit on how many numbers you can assign. Each number can be set up to trigger specific data instructions based on the inbound call, which gives you a lot of flexibility. Here’s how you can get started: • Use the
sip.trunkPhoneNumber
attribute to identify which number the caller dialed. • Configure dispatch rules or custom SIP participant attributes to create different behaviors or workflows depending on the inbound number. • Decide whether you want to set up a single trunk with multiple numbers or multiple trunks with unique configurations—whichever fits your needs best. If you have any specific details about how many Twilio numbers you’re working with or the kinds of data instructions you want to manage, please share them with me. I’d be happy to offer more tailored guidance to help you along the way! Sources: SIP APIs | LiveKit Docs | SIP inbound trunk | LiveKit Docs | livekit-protocol/livekit/protocol/sip.py | SIP participant | LiveKit Docs | packages/sip--um-actually/README.md
l
how do i use this sip.trunkPhoneNumber with js or nodejs?
t
I'm happy to help you understand the
sip.trunkPhoneNumber
attribute! This attribute is automatically assigned to SIP participants in a LiveKit room and represents the phone number linked to the SIP trunk used for the call. Let me walk you through how you can use it with JavaScript or Node.js: 1. Create an Outbound SIP Trunk:
Copy code
import { SipClient } from 'livekit-server-sdk';

const sipClient = new SipClient(
  process.env.LIVEKIT_URL,
  process.env.LIVEKIT_API_KEY,
  process.env.LIVEKIT_API_SECRET
);

const trunk = await sipClient.createSipOutboundTrunk(
  'my-outbound-trunk',
  'sip.twilio.com',
  ['+1234567890'],
  {
    authUsername: 'your-twilio-username',
    authPassword: 'your-twilio-password'
  }
);
2. Initiate a SIP Call:
Copy code
await sipClient.createSipParticipant({
  sipTrunkId: trunk.sipTrunkId,
  sipCallTo: '+0987654321',
  roomName: 'my-room',
});
3. Access the Attribute in the Room: Once your SIP participant joins the room, you can easily retrieve their attributes, including
sip.trunkPhoneNumber
, through room participant events or APIs:
Copy code
// Example of expected attributes on SIP participant
const expectedAttributes = {
  'sip.trunkPhoneNumber': '+1234567890', // Trunk's outbound number
  'sip.phoneNumber': '+0987654321',     // Callee number
  'sip.callStatus': 'active',
  'sip.trunkID': trunk.sipTrunkId,
};
These attributes are really helpful for customizing your app’s behavior based on the call context. If you have any questions or need a hand with anything else, please don’t hesitate to reach out—I’m here to support you! Sources: SIP participant | LiveKit Docs | test/lktest/sip.go