telnyx-voice-advanced-ruby
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese<!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. -->
<!-- 由Telnyx OpenAPI规范自动生成,请勿编辑。 -->
Telnyx Voice Advanced - Ruby
Telnyx高级语音功能 - Ruby
Installation
安装
bash
gem install telnyxbash
gem install telnyxSetup
初始化
ruby
require "telnyx"
client = Telnyx::Client.new(
api_key: ENV["TELNYX_API_KEY"], # This is the default and can be omitted
)All examples below assume is already initialized as shown above.
clientruby
require "telnyx"
client = Telnyx::Client.new(
api_key: ENV["TELNYX_API_KEY"], # 这是默认配置,可省略
)以下所有示例均假设已按上述方式完成初始化。
clientUpdate client state
更新客户端状态
Updates client state
PUT /calls/{call_control_id}/actions/client_state_updateclient_stateruby
response = client.calls.actions.update_client_state("call_control_id", client_state: "aGF2ZSBhIG5pY2UgZGF5ID1d")
puts(response)更新客户端状态
PUT /calls/{call_control_id}/actions/client_state_updateclient_stateruby
response = client.calls.actions.update_client_state("call_control_id", client_state: "aGF2ZSBhIG5pY2UgZGF5ID1d")
puts(response)SIP Refer a call
SIP Refer呼叫
Initiate a SIP Refer on a Call Control call.
POST /calls/{call_control_id}/actions/refersip_addressOptional: (string), (string), (array[object]), (string), (string), (array[object])
client_statecommand_idcustom_headerssip_auth_passwordsip_auth_usernamesip_headersruby
response = client.calls.actions.refer("call_control_id", sip_address: "sip:username@sip.non-telnyx-address.com")
puts(response)在呼叫控制会话中发起SIP Refer操作。
POST /calls/{call_control_id}/actions/refersip_address可选参数:(字符串)、(字符串)、(对象数组)、(字符串)、(字符串)、(对象数组)
client_statecommand_idcustom_headerssip_auth_passwordsip_auth_usernamesip_headersruby
response = client.calls.actions.refer("call_control_id", sip_address: "sip:username@sip.non-telnyx-address.com")
puts(response)Send DTMF
发送DTMF
Sends DTMF tones from this leg.
POST /calls/{call_control_id}/actions/send_dtmfdigitsOptional: (string), (string), (int32)
client_statecommand_idduration_millisruby
response = client.calls.actions.send_dtmf("call_control_id", digits: "1www2WABCDw9")
puts(response)从当前呼叫分支发送DTMF音。
POST /calls/{call_control_id}/actions/send_dtmfdigits可选参数:(字符串)、(字符串)、(32位整数)
client_statecommand_idduration_millisruby
response = client.calls.actions.send_dtmf("call_control_id", digits: "1www2WABCDw9")
puts(response)SIPREC start
启动SIPREC会话
Start siprec session to configured in SIPREC connector SRS.
POST /calls/{call_control_id}/actions/siprec_startOptional: (string), (string), (enum), (enum), (integer), (enum), (enum)
client_stateconnector_nameinclude_metadata_custom_headerssecuresession_timeout_secssip_transportsiprec_trackruby
response = client.calls.actions.start_siprec("call_control_id")
puts(response)启动SIPREC会话,连接至已配置的SIPREC连接器SRS。
POST /calls/{call_control_id}/actions/siprec_start可选参数:(字符串)、(字符串)、(枚举)、(枚举)、(整数)、(枚举)、(枚举)
client_stateconnector_nameinclude_metadata_custom_headerssecuresession_timeout_secssip_transportsiprec_trackruby
response = client.calls.actions.start_siprec("call_control_id")
puts(response)SIPREC stop
停止SIPREC会话
Stop SIPREC session.
POST /calls/{call_control_id}/actions/siprec_stopOptional: (string), (string)
client_statecommand_idruby
response = client.calls.actions.stop_siprec("call_control_id")
puts(response)停止SIPREC会话。
POST /calls/{call_control_id}/actions/siprec_stop可选参数:(字符串)、(字符串)
client_statecommand_idruby
response = client.calls.actions.stop_siprec("call_control_id")
puts(response)Noise Suppression Start (BETA)
启动噪声抑制(测试版)
POST /calls/{call_control_id}/actions/suppression_startOptional: (string), (string), (enum), (enum), (object)
client_statecommand_iddirectionnoise_suppression_enginenoise_suppression_engine_configruby
response = client.calls.actions.start_noise_suppression("call_control_id")
puts(response)POST /calls/{call_control_id}/actions/suppression_start可选参数:(字符串)、(字符串)、(枚举)、(枚举)、(对象)
client_statecommand_iddirectionnoise_suppression_enginenoise_suppression_engine_configruby
response = client.calls.actions.start_noise_suppression("call_control_id")
puts(response)Noise Suppression Stop (BETA)
停止噪声抑制(测试版)
POST /calls/{call_control_id}/actions/suppression_stopOptional: (string), (string)
client_statecommand_idruby
response = client.calls.actions.stop_noise_suppression("call_control_id")
puts(response)POST /calls/{call_control_id}/actions/suppression_stop可选参数:(字符串)、(字符串)
client_statecommand_idruby
response = client.calls.actions.stop_noise_suppression("call_control_id")
puts(response)Switch supervisor role
切换监控人员角色
Switch the supervisor role for a bridged call.
POST /calls/{call_control_id}/actions/switch_supervisor_roleroleruby
response = client.calls.actions.switch_supervisor_role("call_control_id", role: :barge)
puts(response)切换桥接呼叫中监控人员的角色。
POST /calls/{call_control_id}/actions/switch_supervisor_roleroleruby
response = client.calls.actions.switch_supervisor_role("call_control_id", role: :barge)
puts(response)Webhooks
Webhook事件
The following webhook events are sent to your configured webhook URL.
All webhooks include and headers for verification (Standard Webhooks compatible).
telnyx-timestamptelnyx-signature-ed25519| Event | Description |
|---|---|
| Call Refer Started |
| Call Refer Completed |
| Call Refer Failed |
| Call Siprec Started |
| Call Siprec Stopped |
| Call Siprec Failed |
以下Webhook事件将发送至您配置的Webhook URL。
所有Webhook均包含和头信息用于验证(兼容标准Webhook)。
telnyx-timestamptelnyx-signature-ed25519| 事件 | 描述 |
|---|---|
| 呼叫Refer已启动 |
| 呼叫Refer已完成 |
| 呼叫Refer失败 |
| SIPREC会话已启动 |
| SIPREC会话已停止 |
| SIPREC会话失败 |
Webhook payload fields
Webhook负载字段
callReferStarted| 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 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 | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | State received from a command. |
| string | Number or SIP URI placing the call. |
| integer | SIP NOTIFY event status for tracking the REFER attempt. |
| string | Destination number or SIP URI of the call. |
callReferCompleted| 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 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 | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | State received from a command. |
| string | Number or SIP URI placing the call. |
| integer | SIP NOTIFY event status for tracking the REFER attempt. |
| string | Destination number or SIP URI of the call. |
callReferFailed| 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 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 | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | State received from a command. |
| string | Number or SIP URI placing the call. |
| integer | SIP NOTIFY event status for tracking the REFER attempt. |
| string | Destination number or SIP URI of the call. |
callSiprecStarted| 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. |
callSiprecStopped| 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 | Q850 reason why the SIPREC session was stopped. |
callSiprecFailed| 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 | Q850 reason why siprec session failed. |
callReferStarted| 字段 | 类型 | 描述 |
|---|---|---|
| 枚举 | 标识资源的类型。 |
| 枚举 | 标识所发送的事件类型。 |
| UUID | 标识资源的ID。 |
| 日期时间 | 事件发生的ISO 8601格式时间。 |
| 字符串 | 用于控制呼叫的唯一ID。 |
| 字符串 | 呼叫的唯一ID,可用于关联Webhook事件。 |
| 字符串 | 呼叫会话的唯一ID,可用于关联Webhook事件。 |
| 字符串 | 呼叫中使用的呼叫控制应用ID(原Telnyx连接ID)。 |
| 字符串 | 从命令中接收的状态。 |
| 字符串 | 发起呼叫的号码或SIP URI。 |
| 整数 | 用于跟踪REFER尝试状态的SIP NOTIFY事件状态码。 |
| 字符串 | 呼叫的目标号码或SIP URI。 |
callReferCompleted| 字段 | 类型 | 描述 |
|---|---|---|
| 枚举 | 标识资源的类型。 |
| 枚举 | 标识所发送的事件类型。 |
| UUID | 标识资源的ID。 |
| 日期时间 | 事件发生的ISO 8601格式时间。 |
| 字符串 | 用于控制呼叫的唯一ID。 |
| 字符串 | 呼叫的唯一ID,可用于关联Webhook事件。 |
| 字符串 | 呼叫会话的唯一ID,可用于关联Webhook事件。 |
| 字符串 | 呼叫中使用的呼叫控制应用ID(原Telnyx连接ID)。 |
| 字符串 | 从命令中接收的状态。 |
| 字符串 | 发起呼叫的号码或SIP URI。 |
| 整数 | 用于跟踪REFER尝试状态的SIP NOTIFY事件状态码。 |
| 字符串 | 呼叫的目标号码或SIP URI。 |
callReferFailed| 字段 | 类型 | 描述 |
|---|---|---|
| 枚举 | 标识资源的类型。 |
| 枚举 | 标识所发送的事件类型。 |
| UUID | 标识资源的ID。 |
| 日期时间 | 事件发生的ISO 8601格式时间。 |
| 字符串 | 用于控制呼叫的唯一ID。 |
| 字符串 | 呼叫的唯一ID,可用于关联Webhook事件。 |
| 字符串 | 呼叫会话的唯一ID,可用于关联Webhook事件。 |
| 字符串 | 呼叫中使用的呼叫控制应用ID(原Telnyx连接ID)。 |
| 字符串 | 从命令中接收的状态。 |
| 字符串 | 发起呼叫的号码或SIP URI。 |
| 整数 | 用于跟踪REFER尝试状态的SIP NOTIFY事件状态码。 |
| 字符串 | 呼叫的目标号码或SIP URI。 |
callSiprecStarted| 字段 | 类型 | 描述 |
|---|---|---|
| 枚举 | 标识资源的类型。 |
| 枚举 | 标识所发送的事件类型。 |
| UUID | 标识资源的ID。 |
| 日期时间 | 事件发生的ISO 8601格式时间。 |
| 字符串 | 用于通过呼叫控制API下发命令的呼叫ID。 |
| 字符串 | 呼叫中使用的呼叫控制应用ID(原Telnyx连接ID)。 |
| 字符串 | 呼叫的唯一ID,可用于关联Webhook事件。 |
| 字符串 | 呼叫会话的唯一ID,可用于关联Webhook事件。 |
| 字符串 | 从命令中接收的状态。 |
callSiprecStopped| 字段 | 类型 | 描述 |
|---|---|---|
| 枚举 | 标识资源的类型。 |
| 枚举 | 标识所发送的事件类型。 |
| UUID | 标识资源的ID。 |
| 日期时间 | 事件发生的ISO 8601格式时间。 |
| 字符串 | 用于通过呼叫控制API下发命令的呼叫ID。 |
| 字符串 | 呼叫中使用的呼叫控制应用ID(原Telnyx连接ID)。 |
| 字符串 | 呼叫的唯一ID,可用于关联Webhook事件。 |
| 字符串 | 呼叫会话的唯一ID,可用于关联Webhook事件。 |
| 字符串 | 从命令中接收的状态。 |
| 字符串 | SIPREC会话停止的Q850原因码。 |
callSiprecFailed| 字段 | 类型 | 描述 |
|---|---|---|
| 枚举 | 标识资源的类型。 |
| 枚举 | 标识所发送的事件类型。 |
| UUID | 标识资源的ID。 |
| 日期时间 | 事件发生的ISO 8601格式时间。 |
| 字符串 | 用于通过呼叫控制API下发命令的呼叫ID。 |
| 字符串 | 呼叫中使用的呼叫控制应用ID(原Telnyx连接ID)。 |
| 字符串 | 呼叫的唯一ID,可用于关联Webhook事件。 |
| 字符串 | 呼叫会话的唯一ID,可用于关联Webhook事件。 |
| 字符串 | 从命令中接收的状态。 |
| 字符串 | SIPREC会话失败的Q850原因码。 |