telnyx-voice-conferencing-python
npx skills add https://github.com/team-telnyx/telnyx-ext-agent-skills --skill telnyx-voice-conferencing-python
Agent 安装分布
Skill 文档
Telnyx Voice Conferencing – Python
Installation
pip install telnyx
Setup
import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
All examples below assume client is already initialized as shown above.
Enqueue call
Put the call in a queue.
POST /calls/{call_control_id}/actions/enqueue â Required: queue_name
Optional: client_state (string), command_id (string), keep_after_hangup (boolean), max_size (integer), max_wait_time_secs (integer)
response = client.calls.actions.enqueue(
call_control_id="call_control_id",
queue_name="support",
)
print(response.data)
Remove call from a queue
Removes the call from a queue.
POST /calls/{call_control_id}/actions/leave_queue
Optional: client_state (string), command_id (string)
response = client.calls.actions.leave_queue(
call_control_id="call_control_id",
)
print(response.data)
List conferences
Lists conferences.
GET /conferences
page = client.conferences.list()
page = page.data[0]
print(page.id)
Create conference
Create a conference from an existing call leg using a call_control_id and a conference name.
POST /conferences â Required: call_control_id, name
Optional: beep_enabled (enum), client_state (string), comfort_noise (boolean), command_id (string), duration_minutes (integer), hold_audio_url (string), hold_media_name (string), max_participants (integer), region (enum), start_conference_on_create (boolean)
conference = client.conferences.create(
call_control_id="v3:MdI91X4lWFEs7IgbBEOT9M4AigoY08M0WWZFISt1Yw2axZ_IiE4pqg",
name="Business",
)
print(conference.data)
Retrieve a conference
Retrieve an existing conference
GET /conferences/{id}
conference = client.conferences.retrieve(
id="id",
)
print(conference.data)
Hold conference participants
Hold a list of participants in a conference call
POST /conferences/{id}/actions/hold
Optional: audio_url (string), call_control_ids (array[string]), media_name (string), region (enum)
response = client.conferences.actions.hold(
id="id",
)
print(response.data)
Join a conference
Join an existing call leg to a conference.
POST /conferences/{id}/actions/join â Required: call_control_id
Optional: beep_enabled (enum), client_state (string), command_id (string), end_conference_on_exit (boolean), hold (boolean), hold_audio_url (string), hold_media_name (string), mute (boolean), region (enum), soft_end_conference_on_exit (boolean), start_conference_on_enter (boolean), supervisor_role (enum), whisper_call_control_ids (array[string])
response = client.conferences.actions.join(
id="id",
call_control_id="v3:MdI91X4lWFEs7IgbBEOT9M4AigoY08M0WWZFISt1Yw2axZ_IiE4pqg",
)
print(response.data)
Leave a conference
Removes a call leg from a conference and moves it back to parked state.
POST /conferences/{id}/actions/leave â Required: call_control_id
Optional: beep_enabled (enum), command_id (string), region (enum)
response = client.conferences.actions.leave(
id="id",
call_control_id="c46e06d7-b78f-4b13-96b6-c576af9640ff",
)
print(response.data)
Mute conference participants
Mute a list of participants in a conference call
POST /conferences/{id}/actions/mute
Optional: call_control_ids (array[string]), region (enum)
response = client.conferences.actions.mute(
id="id",
)
print(response.data)
Play audio to conference participants
Play audio to all or some participants on a conference call.
POST /conferences/{id}/actions/play
Optional: audio_url (string), call_control_ids (array[string]), loop (object), media_name (string), region (enum)
response = client.conferences.actions.play(
id="id",
)
print(response.data)
Conference recording pause
Pause conference recording.
POST /conferences/{id}/actions/record_pause
Optional: command_id (string), recording_id (string), region (enum)
response = client.conferences.actions.record_pause(
id="id",
)
print(response.data)
Conference recording resume
Resume conference recording.
POST /conferences/{id}/actions/record_resume
Optional: command_id (string), recording_id (string), region (enum)
response = client.conferences.actions.record_resume(
id="id",
)
print(response.data)
Conference recording start
Start recording the conference.
POST /conferences/{id}/actions/record_start â Required: format
Optional: command_id (string), custom_file_name (string), play_beep (boolean), region (enum), trim (enum)
response = client.conferences.actions.record_start(
id="id",
format="wav",
)
print(response.data)
Conference recording stop
Stop recording the conference.
POST /conferences/{id}/actions/record_stop
Optional: client_state (string), command_id (string), recording_id (uuid), region (enum)
response = client.conferences.actions.record_stop(
id="id",
)
print(response.data)
Speak text to conference participants
Convert text to speech and play it to all or some participants.
POST /conferences/{id}/actions/speak â Required: payload, voice
Optional: call_control_ids (array[string]), command_id (string), language (enum), payload_type (enum), region (enum), voice_settings (object)
response = client.conferences.actions.speak(
id="id",
payload="Say this to participants",
voice="female",
)
print(response.data)
Stop audio being played on the conference
Stop audio being played to all or some participants on a conference call.
POST /conferences/{id}/actions/stop
Optional: call_control_ids (array[string]), region (enum)
response = client.conferences.actions.stop(
id="id",
)
print(response.data)
Unhold conference participants
Unhold a list of participants in a conference call
POST /conferences/{id}/actions/unhold â Required: call_control_ids
Optional: region (enum)
response = client.conferences.actions.unhold(
id="id",
call_control_ids=["v3:MdI91X4lWFEs7IgbBEOT9M4AigoY08M0WWZFISt1Yw2axZ_IiE4pqg"],
)
print(response.data)
Unmute conference participants
Unmute a list of participants in a conference call
POST /conferences/{id}/actions/unmute
Optional: call_control_ids (array[string]), region (enum)
response = client.conferences.actions.unmute(
id="id",
)
print(response.data)
Update conference participant
Update conference participant supervisor_role
POST /conferences/{id}/actions/update â Required: call_control_id, supervisor_role
Optional: command_id (string), region (enum), whisper_call_control_ids (array[string])
action = client.conferences.actions.update(
id="id",
call_control_id="v3:MdI91X4lWFEs7IgbBEOT9M4AigoY08M0WWZFISt1Yw2axZ_IiE4pqg",
supervisor_role="whisper",
)
print(action.data)
End a conference
End a conference and terminate all active participants.
POST /conferences/{id}/actions/end
Optional: command_id (string)
response = client.conferences.actions.end_conference(
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(response.data)
Gather DTMF using audio prompt in a conference
Play an audio file to a specific conference participant and gather DTMF input.
POST /conferences/{id}/actions/gather_using_audio â Required: call_control_id
Optional: audio_url (string), client_state (string), gather_id (string), initial_timeout_millis (integer), inter_digit_timeout_millis (integer), invalid_audio_url (string), invalid_media_name (string), maximum_digits (integer), maximum_tries (integer), media_name (string), minimum_digits (integer), stop_playback_on_dtmf (boolean), terminating_digit (string), timeout_millis (integer), valid_digits (string)
response = client.conferences.actions.gather_dtmf_audio(
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
call_control_id="v3:MdI91X4lWFEs7IgbBEOT9M4AigoY08M0WWZFISt1Yw2axZ_IiE4pqg",
)
print(response.data)
Send DTMF to conference participants
Send DTMF tones to one or more conference participants.
POST /conferences/{id}/actions/send_dtmf â Required: digits
Optional: call_control_ids (array[string]), client_state (string), duration_millis (integer)
response = client.conferences.actions.send_dtmf(
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
digits="1234#",
)
print(response.data)
List conference participants
Lists conference participants
GET /conferences/{conference_id}/participants
page = client.conferences.list_participants(
conference_id="conference_id",
)
page = page.data[0]
print(page.id)
Webhooks
The following webhook events are sent to your configured webhook URL.
All webhooks include telnyx-timestamp and telnyx-signature-ed25519 headers for verification (Standard Webhooks compatible).
| Event | Description |
|---|---|
callEnqueued |
Call Enqueued |
callLeftQueue |
Call Left Queue |
conferenceCreated |
Conference Created |
conferenceEnded |
Conference Ended |
conferenceFloorChanged |
Conference Floor Changed |
conferenceParticipantJoined |
Conference Participant Joined |
conferenceParticipantLeft |
Conference Participant Left |
conferenceParticipantPlaybackEnded |
Conference Participant Playback Ended |
conferenceParticipantPlaybackStarted |
Conference Participant Playback Started |
conferenceParticipantSpeakEnded |
Conference Participant Speak Ended |
conferenceParticipantSpeakStarted |
Conference Participant Speak Started |
conferencePlaybackEnded |
Conference Playback Ended |
conferencePlaybackStarted |
Conference Playback Started |
conferenceRecordingSaved |
Conference Recording Saved |
conferenceSpeakEnded |
Conference Speak Ended |
conferenceSpeakStarted |
Conference Speak Started |
Webhook payload fields
callEnqueued
| Field | Type | Description |
|---|---|---|
data.record_type |
enum | Identifies the type of the resource. |
data.event_type |
enum | The type of event being delivered. |
data.id |
uuid | Identifies the type of resource. |
data.occurred_at |
date-time | ISO 8601 datetime of when the event occurred. |
data.payload.call_control_id |
string | Call ID used to issue commands via Call Control API. |
data.payload.connection_id |
string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
data.payload.call_leg_id |
string | ID that is unique to the call and can be used to correlate webhook events. |
data.payload.call_session_id |
string | ID that is unique to the call session and can be used to correlate webhook events. |
data.payload.client_state |
string | State received from a command. |
data.payload.queue |
string | The name of the queue |
data.payload.current_position |
integer | Current position of the call in the queue. |
data.payload.queue_avg_wait_time_secs |
integer | Average time call spends in the queue in seconds. |
callLeftQueue
| Field | Type | Description |
|---|---|---|
data.record_type |
enum | Identifies the type of the resource. |
data.event_type |
enum | The type of event being delivered. |
data.id |
uuid | Identifies the type of resource. |
data.occurred_at |
date-time | ISO 8601 datetime of when the event occurred. |
data.payload.call_control_id |
string | Call ID used to issue commands via Call Control API. |
data.payload.connection_id |
string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
data.payload.call_leg_id |
string | ID that is unique to the call and can be used to correlate webhook events. |
data.payload.call_session_id |
string | ID that is unique to the call session and can be used to correlate webhook events. |
data.payload.client_state |
string | State received from a command. |
data.payload.queue |
string | The name of the queue |
data.payload.queue_position |
integer | Last position of the call in the queue. |
data.payload.reason |
enum | The reason for leaving the queue |
data.payload.wait_time_secs |
integer | Time call spent in the queue in seconds. |
conferenceCreated
| Field | Type | Description |
|---|---|---|
data.record_type |
enum | Identifies the type of the resource. |
data.event_type |
enum | The type of event being delivered. |
data.id |
uuid | Identifies the type of resource. |
data.payload.call_control_id |
string | Call ID used to issue commands via Call Control API. |
data.payload.connection_id |
string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
data.payload.call_leg_id |
string | ID that is unique to the call and can be used to correlate webhook events. |
data.payload.call_session_id |
string | ID that is unique to the call session and can be used to correlate webhook events. |
data.payload.client_state |
string | State received from a command. |
data.payload.conference_id |
string | Conference ID that the participant joined. |
data.payload.occurred_at |
date-time | ISO 8601 datetime of when the event occurred. |
conferenceEnded
| Field | Type | Description |
|---|---|---|
data.record_type |
enum | Identifies the type of the resource. |
data.event_type |
enum | The type of event being delivered. |
data.id |
uuid | Identifies the type of resource. |
data.payload.call_control_id |
string | Call ID used to issue commands via Call Control API. |
data.payload.connection_id |
string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
data.payload.call_leg_id |
string | ID that is unique to the call and can be used to correlate webhook events. |
data.payload.call_session_id |
string | ID that is unique to the call session and can be used to correlate webhook events. |
data.payload.client_state |
string | State received from a command. |
data.payload.conference_id |
string | Conference ID that the participant joined. |
data.payload.occurred_at |
date-time | ISO 8601 datetime of when the event occurred. |
data.payload.reason |
enum | Reason the conference ended. |
conferenceFloorChanged
| Field | Type | Description |
|---|---|---|
record_type |
enum | Identifies the type of the resource. |
event_type |
enum | The type of event being delivered. |
id |
uuid | Identifies the type of resource. |
payload.call_control_id |
string | Call Control ID of the new speaker. |
payload.connection_id |
string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
payload.call_leg_id |
string | Call Leg ID of the new speaker. |
payload.call_session_id |
string | Call Session ID of the new speaker. |
payload.client_state |
string | State received from a command. |
payload.conference_id |
string | Conference ID that had a speaker change event. |
payload.occurred_at |
date-time | ISO 8601 datetime of when the event occurred. |
conferenceParticipantJoined
| Field | Type | Description |
|---|---|---|
data.record_type |
enum | Identifies the type of the resource. |
data.event_type |
enum | The type of event being delivered. |
data.id |
uuid | Identifies the type of resource. |
data.occurred_at |
date-time | ISO 8601 datetime of when the event occurred. |
data.payload.call_control_id |
string | Call ID used to issue commands via Call Control API. |
data.payload.connection_id |
string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
data.payload.call_leg_id |
string | ID that is unique to the call and can be used to correlate webhook events. |
data.payload.call_session_id |
string | ID that is unique to the call session and can be used to correlate webhook events. |
data.payload.client_state |
string | State received from a command. |
data.payload.conference_id |
string | Conference ID that the participant joined. |
conferenceParticipantLeft
| Field | Type | Description |
|---|---|---|
data.record_type |
enum | Identifies the type of the resource. |
data.event_type |
enum | The type of event being delivered. |
data.id |
uuid | Identifies the type of resource. |
data.occurred_at |
date-time | ISO 8601 datetime of when the event occurred. |
data.payload.call_control_id |
string | Call ID used to issue commands via Call Control API. |
data.payload.connection_id |
string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
data.payload.call_leg_id |
string | ID that is unique to the call and can be used to correlate webhook events. |
data.payload.call_session_id |
string | ID that is unique to the call session and can be used to correlate webhook events. |
data.payload.client_state |
string | State received from a command. |
data.payload.conference_id |
string | Conference ID that the participant joined. |
conferenceParticipantPlaybackEnded
| Field | Type | Description |
|---|---|---|
data.record_type |
enum | Identifies the type of the resource. |
data.event_type |
enum | The type of event being delivered. |
data.id |
uuid | Identifies the type of resource. |
data.payload.call_control_id |
string | Participant’s call ID used to issue commands via Call Control API. |
data.payload.call_leg_id |
string | ID that is unique to the call and can be used to correlate webhook events. |
data.payload.call_session_id |
string | ID that is unique to the call session and can be used to correlate webhook events. |
data.payload.client_state |
string | State received from a command. |
data.payload.connection_id |
string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
data.payload.creator_call_session_id |
string | ID that is unique to the call session that started the conference. |
data.payload.conference_id |
string | ID of the conference the text was spoken in. |
data.payload.media_url |
string | The audio URL being played back, if audio_url has been used to start. |
data.payload.media_name |
string | The name of the audio media file being played back, if media_name has been used to start. |
data.payload.occurred_at |
date-time | ISO 8601 datetime of when the event occurred. |
conferenceParticipantPlaybackStarted
| Field | Type | Description |
|---|---|---|
data.record_type |
enum | Identifies the type of the resource. |
data.event_type |
enum | The type of event being delivered. |
data.id |
uuid | Identifies the type of resource. |
data.payload.call_control_id |
string | Participant’s call ID used to issue commands via Call Control API. |
data.payload.call_leg_id |
string | ID that is unique to the call and can be used to correlate webhook events. |
data.payload.call_session_id |
string | ID that is unique to the call session and can be used to correlate webhook events. |
data.payload.client_state |
string | State received from a command. |
data.payload.connection_id |
string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
data.payload.creator_call_session_id |
string | ID that is unique to the call session that started the conference. |
data.payload.conference_id |
string | ID of the conference the text was spoken in. |
data.payload.media_url |
string | The audio URL being played back, if audio_url has been used to start. |
data.payload.media_name |
string | The name of the audio media file being played back, if media_name has been used to start. |
data.payload.occurred_at |
date-time | ISO 8601 datetime of when the event occurred. |
conferenceParticipantSpeakEnded
| Field | Type | Description |
|---|---|---|
data.record_type |
enum | Identifies the type of the resource. |
data.event_type |
enum | The type of event being delivered. |
data.id |
uuid | Identifies the type of resource. |
data.payload.call_control_id |
string | Participant’s call ID used to issue commands via Call Control API. |
data.payload.call_leg_id |
string | ID that is unique to the call and can be used to correlate webhook events. |
data.payload.call_session_id |
string | ID that is unique to the call session and can be used to correlate webhook events. |
data.payload.client_state |
string | State received from a command. |
data.payload.connection_id |
string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
data.payload.creator_call_session_id |
string | ID that is unique to the call session that started the conference. |
data.payload.conference_id |
string | ID of the conference the text was spoken in. |
data.payload.occurred_at |
date-time | ISO 8601 datetime of when the event occurred. |
conferenceParticipantSpeakStarted
| Field | Type | Description |
|---|---|---|
data.record_type |
enum | Identifies the type of the resource. |
data.event_type |
enum | The type of event being delivered. |
data.id |
uuid | Identifies the type of resource. |
data.payload.call_control_id |
string | Participant’s call ID used to issue commands via Call Control API. |
data.payload.call_leg_id |
string | ID that is unique to the call and can be used to correlate webhook events. |
data.payload.call_session_id |
string | ID that is unique to the call session and can be used to correlate webhook events. |
data.payload.client_state |
string | State received from a command. |
data.payload.connection_id |
string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
data.payload.creator_call_session_id |
string | ID that is unique to the call session that started the conference. |
data.payload.conference_id |
string | ID of the conference the text was spoken in. |
data.payload.occurred_at |
date-time | ISO 8601 datetime of when the event occurred. |
conferencePlaybackEnded
| Field | Type | Description |
|---|---|---|
data.record_type |
enum | Identifies the type of the resource. |
data.event_type |
enum | The type of event being delivered. |
data.id |
uuid | Identifies the type of resource. |
data.payload.connection_id |
string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
data.payload.creator_call_session_id |
string | ID that is unique to the call session that started the conference. |
data.payload.conference_id |
string | ID of the conference the text was spoken in. |
data.payload.media_url |
string | The audio URL being played back, if audio_url has been used to start. |
data.payload.media_name |
string | The name of the audio media file being played back, if media_name has been used to start. |
data.payload.occurred_at |
date-time | ISO 8601 datetime of when the event occurred. |
conferencePlaybackStarted
| Field | Type | Description |
|---|---|---|
data.record_type |
enum | Identifies the type of the resource. |
data.event_type |
enum | The type of event being delivered. |
data.id |
uuid | Identifies the type of resource. |
data.payload.connection_id |
string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
data.payload.creator_call_session_id |
string | ID that is unique to the call session that started the conference. |
data.payload.conference_id |
string | ID of the conference the text was spoken in. |
data.payload.media_url |
string | The audio URL being played back, if audio_url has been used to start. |
data.payload.media_name |
string | The name of the audio media file being played back, if media_name has been used to start. |
data.payload.occurred_at |
date-time | ISO 8601 datetime of when the event occurred. |
conferenceRecordingSaved
| Field | Type | Description |
|---|---|---|
data.record_type |
enum | Identifies the type of the resource. |
data.event_type |
enum | The type of event being delivered. |
data.id |
uuid | Identifies the type of resource. |
data.payload.call_control_id |
string | Participant’s call ID used to issue commands via Call Control API. |
data.payload.call_session_id |
string | ID that is unique to the call session and can be used to correlate webhook events. |
data.payload.client_state |
string | State received from a command. |
data.payload.channels |
enum | Whether recording was recorded in single or dual channel. |
data.payload.conference_id |
uuid | ID of the conference that is being recorded. |
data.payload.connection_id |
string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
data.payload.format |
enum | The audio file format used when storing the call recording. |
data.payload.recording_ended_at |
date-time | ISO 8601 datetime of when recording ended. |
data.payload.recording_id |
uuid | ID of the conference recording. |
data.payload.recording_started_at |
date-time | ISO 8601 datetime of when recording started. |
conferenceSpeakEnded
| Field | Type | Description |
|---|---|---|
data.record_type |
enum | Identifies the type of the resource. |
data.event_type |
enum | The type of event being delivered. |
data.id |
uuid | Identifies the type of resource. |
data.payload.connection_id |
string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
data.payload.creator_call_session_id |
string | ID that is unique to the call session that started the conference. |
data.payload.conference_id |
string | ID of the conference the text was spoken in. |
data.payload.occurred_at |
date-time | ISO 8601 datetime of when the event occurred. |
conferenceSpeakStarted
| Field | Type | Description |
|---|---|---|
data.record_type |
enum | Identifies the type of the resource. |
data.event_type |
enum | The type of event being delivered. |
data.id |
uuid | Identifies the type of resource. |
data.payload.connection_id |
string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
data.payload.creator_call_session_id |
string | ID that is unique to the call session that started the conference. |
data.payload.conference_id |
string | ID of the conference the text was spoken in. |
data.payload.occurred_at |
date-time | ISO 8601 datetime of when the event occurred. |