telnyx-voice-advanced-java
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese<!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. -->
<!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. -->
Telnyx Voice Advanced - Java
Telnyx高级语音功能 - Java版
Installation
安装
text
// See https://github.com/team-telnyx/telnyx-java for Maven/Gradle setuptext
// See https://github.com/team-telnyx/telnyx-java for Maven/Gradle setupSetup
初始化
java
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
TelnyxClient client = TelnyxOkHttpClient.fromEnv();All examples below assume is already initialized as shown above.
clientjava
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
TelnyxClient client = TelnyxOkHttpClient.fromEnv();以下所有示例均假设已按照上述方式完成初始化。
clientUpdate client state
更新客户端状态
Updates client state
PUT /calls/{call_control_id}/actions/client_state_updateclient_statejava
import com.telnyx.sdk.models.calls.actions.ActionUpdateClientStateParams;
import com.telnyx.sdk.models.calls.actions.ActionUpdateClientStateResponse;
ActionUpdateClientStateParams params = ActionUpdateClientStateParams.builder()
.callControlId("call_control_id")
.clientState("aGF2ZSBhIG5pY2UgZGF5ID1d")
.build();
ActionUpdateClientStateResponse response = client.calls().actions().updateClientState(params);更新客户端状态
PUT /calls/{call_control_id}/actions/client_state_updateclient_statejava
import com.telnyx.sdk.models.calls.actions.ActionUpdateClientStateParams;
import com.telnyx.sdk.models.calls.actions.ActionUpdateClientStateResponse;
ActionUpdateClientStateParams params = ActionUpdateClientStateParams.builder()
.callControlId("call_control_id")
.clientState("aGF2ZSBhIG5pY2UgZGF5ID1d")
.build();
ActionUpdateClientStateResponse response = client.calls().actions().updateClientState(params);SIP Refer a call
SIP呼叫转接
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_headersjava
import com.telnyx.sdk.models.calls.actions.ActionReferParams;
import com.telnyx.sdk.models.calls.actions.ActionReferResponse;
ActionReferParams params = ActionReferParams.builder()
.callControlId("call_control_id")
.sipAddress("sip:username@sip.non-telnyx-address.com")
.build();
ActionReferResponse response = client.calls().actions().refer(params);在呼叫控制通话中发起SIP Refer操作。
POST /calls/{call_control_id}/actions/refersip_address可选参数:(字符串), (字符串), (对象数组), (字符串), (字符串), (对象数组)
client_statecommand_idcustom_headerssip_auth_passwordsip_auth_usernamesip_headersjava
import com.telnyx.sdk.models.calls.actions.ActionReferParams;
import com.telnyx.sdk.models.calls.actions.ActionReferResponse;
ActionReferParams params = ActionReferParams.builder()
.callControlId("call_control_id")
.sipAddress("sip:username@sip.non-telnyx-address.com")
.build();
ActionReferResponse response = client.calls().actions().refer(params);Send DTMF
发送DTMF信号
Sends DTMF tones from this leg.
POST /calls/{call_control_id}/actions/send_dtmfdigitsOptional: (string), (string), (int32)
client_statecommand_idduration_millisjava
import com.telnyx.sdk.models.calls.actions.ActionSendDtmfParams;
import com.telnyx.sdk.models.calls.actions.ActionSendDtmfResponse;
ActionSendDtmfParams params = ActionSendDtmfParams.builder()
.callControlId("call_control_id")
.digits("1www2WABCDw9")
.build();
ActionSendDtmfResponse response = client.calls().actions().sendDtmf(params);从当前通话支路发送DTMF音。
POST /calls/{call_control_id}/actions/send_dtmfdigits可选参数:(字符串), (字符串), (32位整数)
client_statecommand_idduration_millisjava
import com.telnyx.sdk.models.calls.actions.ActionSendDtmfParams;
import com.telnyx.sdk.models.calls.actions.ActionSendDtmfResponse;
ActionSendDtmfParams params = ActionSendDtmfParams.builder()
.callControlId("call_control_id")
.digits("1www2WABCDw9")
.build();
ActionSendDtmfResponse response = client.calls().actions().sendDtmf(params);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_trackjava
import com.telnyx.sdk.models.calls.actions.ActionStartSiprecParams;
import com.telnyx.sdk.models.calls.actions.ActionStartSiprecResponse;
ActionStartSiprecResponse response = client.calls().actions().startSiprec("call_control_id");启动SIPREC会话,连接到已配置的SIPREC连接器SRS。
POST /calls/{call_control_id}/actions/siprec_start可选参数:(字符串), (字符串), (枚举), (枚举), (整数), (枚举), (枚举)
client_stateconnector_nameinclude_metadata_custom_headerssecuresession_timeout_secssip_transportsiprec_trackjava
import com.telnyx.sdk.models.calls.actions.ActionStartSiprecParams;
import com.telnyx.sdk.models.calls.actions.ActionStartSiprecResponse;
ActionStartSiprecResponse response = client.calls().actions().startSiprec("call_control_id");SIPREC stop
停止SIPREC会话
Stop SIPREC session.
POST /calls/{call_control_id}/actions/siprec_stopOptional: (string), (string)
client_statecommand_idjava
import com.telnyx.sdk.models.calls.actions.ActionStopSiprecParams;
import com.telnyx.sdk.models.calls.actions.ActionStopSiprecResponse;
ActionStopSiprecResponse response = client.calls().actions().stopSiprec("call_control_id");停止SIPREC会话。
POST /calls/{call_control_id}/actions/siprec_stop可选参数:(字符串), (字符串)
client_statecommand_idjava
import com.telnyx.sdk.models.calls.actions.ActionStopSiprecParams;
import com.telnyx.sdk.models.calls.actions.ActionStopSiprecResponse;
ActionStopSiprecResponse response = client.calls().actions().stopSiprec("call_control_id");Noise Suppression Start (BETA)
启动噪声抑制(测试版)
POST /calls/{call_control_id}/actions/suppression_startOptional: (string), (string), (enum), (enum), (object)
client_statecommand_iddirectionnoise_suppression_enginenoise_suppression_engine_configjava
import com.telnyx.sdk.models.calls.actions.ActionStartNoiseSuppressionParams;
import com.telnyx.sdk.models.calls.actions.ActionStartNoiseSuppressionResponse;
ActionStartNoiseSuppressionResponse response = client.calls().actions().startNoiseSuppression("call_control_id");POST /calls/{call_control_id}/actions/suppression_start可选参数:(字符串), (字符串), (枚举), (枚举), (对象)
client_statecommand_iddirectionnoise_suppression_enginenoise_suppression_engine_configjava
import com.telnyx.sdk.models.calls.actions.ActionStartNoiseSuppressionParams;
import com.telnyx.sdk.models.calls.actions.ActionStartNoiseSuppressionResponse;
ActionStartNoiseSuppressionResponse response = client.calls().actions().startNoiseSuppression("call_control_id");Noise Suppression Stop (BETA)
停止噪声抑制(测试版)
POST /calls/{call_control_id}/actions/suppression_stopOptional: (string), (string)
client_statecommand_idjava
import com.telnyx.sdk.models.calls.actions.ActionStopNoiseSuppressionParams;
import com.telnyx.sdk.models.calls.actions.ActionStopNoiseSuppressionResponse;
ActionStopNoiseSuppressionResponse response = client.calls().actions().stopNoiseSuppression("call_control_id");POST /calls/{call_control_id}/actions/suppression_stop可选参数:(字符串), (字符串)
client_statecommand_idjava
import com.telnyx.sdk.models.calls.actions.ActionStopNoiseSuppressionParams;
import com.telnyx.sdk.models.calls.actions.ActionStopNoiseSuppressionResponse;
ActionStopNoiseSuppressionResponse response = client.calls().actions().stopNoiseSuppression("call_control_id");Switch supervisor role
切换监控席角色
Switch the supervisor role for a bridged call.
POST /calls/{call_control_id}/actions/switch_supervisor_rolerolejava
import com.telnyx.sdk.models.calls.actions.ActionSwitchSupervisorRoleParams;
import com.telnyx.sdk.models.calls.actions.ActionSwitchSupervisorRoleResponse;
ActionSwitchSupervisorRoleParams params = ActionSwitchSupervisorRoleParams.builder()
.callControlId("call_control_id")
.role(ActionSwitchSupervisorRoleParams.Role.BARGE)
.build();
ActionSwitchSupervisorRoleResponse response = client.calls().actions().switchSupervisorRole(params);在桥接通话中切换监控席的角色。
POST /calls/{call_control_id}/actions/switch_supervisor_rolerolejava
import com.telnyx.sdk.models.calls.actions.ActionSwitchSupervisorRoleParams;
import com.telnyx.sdk.models.calls.actions.ActionSwitchSupervisorRoleResponse;
ActionSwitchSupervisorRoleParams params = ActionSwitchSupervisorRoleParams.builder()
.callControlId("call_control_id")
.role(ActionSwitchSupervisorRoleParams.Role.BARGE)
.build();
ActionSwitchSupervisorRoleResponse response = client.calls().actions().switchSupervisorRole(params);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| 事件 | 描述 |
|---|---|
| 呼叫转接已启动 |
| 呼叫转接已完成 |
| 呼叫转接失败 |
| 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 | 标识资源类型。 |
| 日期时间 | 事件发生的ISO 8601格式时间。 |
| 字符串 | 用于控制通话的唯一ID。 |
| 字符串 | 通话的唯一ID,可用于关联Webhook事件。 |
| 字符串 | 通话会话的唯一ID,可用于关联Webhook事件。 |
| 字符串 | 通话中使用的呼叫控制应用ID(原Telnyx连接ID)。 |
| 字符串 | 从命令中接收的状态。 |
| 字符串 | 发起通话的号码或SIP URI。 |
| 整数 | 用于跟踪转接尝试的SIP NOTIFY事件状态。 |
| 字符串 | 通话的目标号码或SIP URI。 |
callReferCompleted| 字段 | 类型 | 描述 |
|---|---|---|
| 枚举 | 标识资源类型。 |
| 枚举 | 传递的事件类型。 |
| UUID | 标识资源类型。 |
| 日期时间 | 事件发生的ISO 8601格式时间。 |
| 字符串 | 用于控制通话的唯一ID。 |
| 字符串 | 通话的唯一ID,可用于关联Webhook事件。 |
| 字符串 | 通话会话的唯一ID,可用于关联Webhook事件。 |
| 字符串 | 通话中使用的呼叫控制应用ID(原Telnyx连接ID)。 |
| 字符串 | 从命令中接收的状态。 |
| 字符串 | 发起通话的号码或SIP URI。 |
| 整数 | 用于跟踪转接尝试的SIP NOTIFY事件状态。 |
| 字符串 | 通话的目标号码或SIP URI。 |
callReferFailed| 字段 | 类型 | 描述 |
|---|---|---|
| 枚举 | 标识资源类型。 |
| 枚举 | 传递的事件类型。 |
| UUID | 标识资源类型。 |
| 日期时间 | 事件发生的ISO 8601格式时间。 |
| 字符串 | 用于控制通话的唯一ID。 |
| 字符串 | 通话的唯一ID,可用于关联Webhook事件。 |
| 字符串 | 通话会话的唯一ID,可用于关联Webhook事件。 |
| 字符串 | 通话中使用的呼叫控制应用ID(原Telnyx连接ID)。 |
| 字符串 | 从命令中接收的状态。 |
| 字符串 | 发起通话的号码或SIP URI。 |
| 整数 | 用于跟踪转接尝试的SIP NOTIFY事件状态。 |
| 字符串 | 通话的目标号码或SIP URI。 |
callSiprecStarted| 字段 | 类型 | 描述 |
|---|---|---|
| 枚举 | 标识资源类型。 |
| 枚举 | 传递的事件类型。 |
| UUID | 标识资源类型。 |
| 日期时间 | 事件发生的ISO 8601格式时间。 |
| 字符串 | 用于通过呼叫控制API发送命令的通话ID。 |
| 字符串 | 通话中使用的呼叫控制应用ID(原Telnyx连接ID)。 |
| 字符串 | 通话的唯一ID,可用于关联Webhook事件。 |
| 字符串 | 通话会话的唯一ID,可用于关联Webhook事件。 |
| 字符串 | 从命令中接收的状态。 |
callSiprecStopped| 字段 | 类型 | 描述 |
|---|---|---|
| 枚举 | 标识资源类型。 |
| 枚举 | 传递的事件类型。 |
| UUID | 标识资源类型。 |
| 日期时间 | 事件发生的ISO 8601格式时间。 |
| 字符串 | 用于通过呼叫控制API发送命令的通话ID。 |
| 字符串 | 通话中使用的呼叫控制应用ID(原Telnyx连接ID)。 |
| 字符串 | 通话的唯一ID,可用于关联Webhook事件。 |
| 字符串 | 通话会话的唯一ID,可用于关联Webhook事件。 |
| 字符串 | 从命令中接收的状态。 |
| 字符串 | SIPREC会话停止的Q850原因码。 |
callSiprecFailed| 字段 | 类型 | 描述 |
|---|---|---|
| 枚举 | 标识资源类型。 |
| 枚举 | 传递的事件类型。 |
| UUID | 标识资源类型。 |
| 日期时间 | 事件发生的ISO 8601格式时间。 |
| 字符串 | 用于通过呼叫控制API发送命令的通话ID。 |
| 字符串 | 通话中使用的呼叫控制应用ID(原Telnyx连接ID)。 |
| 字符串 | 通话的唯一ID,可用于关联Webhook事件。 |
| 字符串 | 通话会话的唯一ID,可用于关联Webhook事件。 |
| 字符串 | 从命令中接收的状态。 |
| 字符串 | SIPREC会话失败的Q850原因码。 |