livekit / sip

SIP to WebRTC bridge for LiveKit
132 stars 30 forks source link

createSipParticipant Does not have an option to specify "Outgoing" Number to use #202

Open mercuryyy opened 1 month ago

mercuryyy commented 1 month ago

createSipParticipant(sipTrunkId, number, roomName, opts?): Promise

Does not have an option to pick which (own) number to use when dialing an outbound call?

What if we have 10 numbers assigned to 1 outgoing Trunk, we can't specify the number to use?

I'v looked at -

https://docs.livekit.io/server-sdk-js/classes/SipClient.html + https://github.com/livekit/node-sdks/blob/515f379a4e4d507c9f3db7b09b22881ec81c40ad/packages/livekit-server-sdk/src/SipClient.ts#L387

I think this is an important issues

Also please consider adding a update function to accommodate createSipInboundTrunk and createSipoutboundTrunk

Meaning using updateSipInboundTrunk, we wont have to delete the trunk every time we want to add a new phone number to it.

AutoScrape123TX commented 1 month ago

https://github.com/livekit/python-sdks/blob/main/livekit-protocol/livekit/protocol/sip.pyi livekit.protocol.sip.CreateSIPParticipantRequest

You have to use the SDK and call your livekit server to choose your caller-id 👍👍👍

mercuryyy commented 1 month ago
class CreateSIPParticipantRequest(_message.Message):
    __slots__ = ("sip_trunk_id", "sip_call_to", "room_name", "participant_identity", "participant_name", "participant_metadata", "participant_attributes", "dtmf", "play_ringtone", "hide_phone_number")
    class ParticipantAttributesEntry(_message.Message):
        __slots__ = ("key", "value")
        KEY_FIELD_NUMBER: _ClassVar[int]
        VALUE_FIELD_NUMBER: _ClassVar[int]
        key: str
        value: str
        def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ...
    SIP_TRUNK_ID_FIELD_NUMBER: _ClassVar[int]
    SIP_CALL_TO_FIELD_NUMBER: _ClassVar[int]
    ROOM_NAME_FIELD_NUMBER: _ClassVar[int]
    PARTICIPANT_IDENTITY_FIELD_NUMBER: _ClassVar[int]
    PARTICIPANT_NAME_FIELD_NUMBER: _ClassVar[int]
    PARTICIPANT_METADATA_FIELD_NUMBER: _ClassVar[int]
    PARTICIPANT_ATTRIBUTES_FIELD_NUMBER: _ClassVar[int]
    DTMF_FIELD_NUMBER: _ClassVar[int]
    PLAY_RINGTONE_FIELD_NUMBER: _ClassVar[int]
    HIDE_PHONE_NUMBER_FIELD_NUMBER: _ClassVar[int]
    sip_trunk_id: str
    sip_call_to: str
    room_name: str
    participant_identity: str
    participant_name: str
    participant_metadata: str
    participant_attributes: _containers.ScalarMap[str, str]
    dtmf: str
    play_ringtone: bool
    hide_phone_number: bool
    def __init__(self, sip_trunk_id: _Optional[str] = ..., sip_call_to: _Optional[str] = ..., room_name: _Optional[str] = ..., participant_identity: _Optional[str] = ..., participant_name: _Optional[str] = ..., participant_metadata: _Optional[str] = ..., participant_attributes: _Optional[_Mapping[str, str]] = ..., dtmf: _Optional[str] = ..., play_ringtone: bool = ..., hide_phone_number: bool = ...) -> None: ...

I dont see any field for caller-id?

It is the same as the node sdk i mentioned in the ticket, there is not option to choose the caller id, unless i stayed up way too late again and i cannot tell anymore.

dennwc commented 1 month ago

The caller ID is controlled by the sip_trunk_id parameter, which points to a LiveKit SIP Outbound Trunk. That trunk may contain one or more phone numbers that will be used for the call (see numbers field).

mercuryyy commented 1 month ago

@dennwc The issue is if the sip_trunk_id has 10 numbers assigned to it, there is no way to choose which specific number to use when starting an outbound call using "createSipParticipant"

@AutoScrape123TX comment was not related to the issue.

Should probably be tagged as Bug Or "Enhancement"

dennwc commented 1 month ago

@mercuryyy That's right, if you need to select a specific number, you can make a separate Trunk with that number only. It works as intended, so I'm going to close this issue.

mercuryyy commented 1 month ago

@dennwc

We have clients with 100 numbers on 1 Trunk, we would have to delete 100 trunk_ids if they need to change the trunk settings, and create 100 trunk_ids 1 for each number if they want to be able to chose which number to dial out from.

Was that not the point when you allowed 1 trunk_id to have multiple number, to avoid that?

It only makes sense that we can chose which number to use when dialing out from the trunk_id that already supports having multiple numbers

adding :

createSipParticipant(sipTrunkId, number, caller_id, roomName, opts?)

Added "caller_id" to the request, where caller_id = one of the numbers we added to the trunk_id

dennwc commented 1 month ago

That makes sense, we could change the API to allow picking a specific number in the short term.

In the longer term, I plan to redo the outbound trunks, so that they only include auth settings, etc. Other parameters could be passed directly in the CreateSIPParticipant.

mercuryyy commented 1 month ago

@dennwc Sound great.

Thank you!

mercuryyy commented 2 weeks ago

Hey @dennwc any news/updates/plans on adding this to the next release?

dennwc commented 5 days ago

Yes, sorry for the delay. It was blocked by another change. It will be supported after https://github.com/livekit/protocol/pull/891 is merged.

rmonvfer commented 3 days ago

Is this supported now that https://github.com/livekit/protocol/pull/891 has been merged?

dennwc commented 3 days ago

Self-hosted LiveKit will support it when https://github.com/livekit/livekit/pull/3209 is merged. Cloud deployment will have to wait a bit.