Loading...
Loading...
Stream call audio in real-time, fork media to external destinations, and transcribe speech live. Use for real-time analytics and AI integrations. This skill provides Python SDK examples.
npx skill4agent add team-telnyx/telnyx-ext-agent-skills telnyx-voice-streaming-pythonpip install telnyximport os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)clientPOST /calls/{call_control_id}/actions/fork_startclient_statecommand_idrxstream_typetxresponse = client.calls.actions.start_forking(
call_control_id="call_control_id",
)
print(response.data)POST /calls/{call_control_id}/actions/fork_stopclient_statecommand_idstream_typeresponse = client.calls.actions.stop_forking(
call_control_id="call_control_id",
)
print(response.data)POST /calls/{call_control_id}/actions/streaming_startclient_statecommand_idcustom_parametersdialogflow_configenable_dialogflowstream_auth_tokenstream_bidirectional_codecstream_bidirectional_modestream_bidirectional_sampling_ratestream_bidirectional_target_legsstream_codecstream_trackstream_urlresponse = client.calls.actions.start_streaming(
call_control_id="call_control_id",
)
print(response.data)POST /calls/{call_control_id}/actions/streaming_stopclient_statecommand_idstream_idresponse = client.calls.actions.stop_streaming(
call_control_id="call_control_id",
)
print(response.data)POST /calls/{call_control_id}/actions/transcription_startclient_statecommand_idtranscription_enginetranscription_engine_configtranscription_tracksresponse = client.calls.actions.start_transcription(
call_control_id="call_control_id",
)
print(response.data)POST /calls/{call_control_id}/actions/transcription_stopclient_statecommand_idresponse = client.calls.actions.stop_transcription(
call_control_id="call_control_id",
)
print(response.data)telnyx-timestamptelnyx-signature-ed25519| Event | Description |
|---|---|
| Call Fork Started |
| Call Fork Stopped |
| Call Streaming Started |
| Call Streaming Stopped |
| Call Streaming Failed |
| Transcription |
callForkStarted| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | Unique ID for controlling the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| enum | Type of media streamed. |
callForkStopped| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | Unique ID for controlling the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| enum | Type of media streamed. |
callStreamingStarted| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| string | Destination WebSocket address where the stream is going to be delivered. |
callStreamingStopped| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| string | Destination WebSocket address where the stream is going to be delivered. |
callStreamingFailed| Field | Type | Description |
|---|---|---|
| enum | Identifies the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| string | A short description explaning why the media streaming failed. |
| uuid | Identifies the streaming. |
| enum | The type of stream connection the stream is performing. |
transcription| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Unique identifier and token for controlling the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | Use this field to add state to every subsequent webhook. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |