-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Problem Statement
Inside a bot, it's useful to have access to call data from a telephony provider. For example, Twilio call_sid. This is not currently easy or clean to access.
When using create_transport, the websocket already has to be parsed in order to find out which provider is used and information like the call_sid. However, the twilio example shows you have to manually parse the websocket and create a serializer to get the call_sid. If you try to parse the websocket twice, by manually doing so and using create_transport, you get an error.
I was able to obtain call info as such by accessing "private" members on the transport. However, this does not feel right.
from operator import attrgetter
def get_call_sid(transport: BaseTransport) -> str | None:
try:
return str(attrgetter("_params.serializer._call_sid")(transport))
except AttributeError:
return NoneI wish there was a simple way to get call data like the call_sid from the transport.
Proposed Solution
Add a parameter to BaseTransport, maybe called transport_details which is populated at runtime depending on which provider is used. Twilio gets call_sid. Other telephony get their respective fields. WebRTC has its own additional details.