Skip to content

Transport should provide call data, if available #3337

@julian-hecker

Description

@julian-hecker

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 None

I 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions