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 setup
text
// See https://github.com/team-telnyx/telnyx-java for Maven/Gradle setup

Setup

初始化

java
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;

TelnyxClient client = TelnyxOkHttpClient.fromEnv();
All examples below assume
client
is already initialized as shown above.
java
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;

TelnyxClient client = TelnyxOkHttpClient.fromEnv();
以下所有示例均假设
client
已按照上述方式完成初始化。

Update client state

更新客户端状态

Updates client state
PUT /calls/{call_control_id}/actions/client_state_update
— Required:
client_state
java
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_update
— 必填参数:
client_state
java
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/refer
— Required:
sip_address
Optional:
client_state
(string),
command_id
(string),
custom_headers
(array[object]),
sip_auth_password
(string),
sip_auth_username
(string),
sip_headers
(array[object])
java
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/refer
— 必填参数:
sip_address
可选参数:
client_state
(字符串),
command_id
(字符串),
custom_headers
(对象数组),
sip_auth_password
(字符串),
sip_auth_username
(字符串),
sip_headers
(对象数组)
java
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_dtmf
— Required:
digits
Optional:
client_state
(string),
command_id
(string),
duration_millis
(int32)
java
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_dtmf
— 必填参数:
digits
可选参数:
client_state
(字符串),
command_id
(字符串),
duration_millis
(32位整数)
java
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_start
Optional:
client_state
(string),
connector_name
(string),
include_metadata_custom_headers
(enum),
secure
(enum),
session_timeout_secs
(integer),
sip_transport
(enum),
siprec_track
(enum)
java
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_state
(字符串),
connector_name
(字符串),
include_metadata_custom_headers
(枚举),
secure
(枚举),
session_timeout_secs
(整数),
sip_transport
(枚举),
siprec_track
(枚举)
java
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_stop
Optional:
client_state
(string),
command_id
(string)
java
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_state
(字符串),
command_id
(字符串)
java
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_start
Optional:
client_state
(string),
command_id
(string),
direction
(enum),
noise_suppression_engine
(enum),
noise_suppression_engine_config
(object)
java
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_state
(字符串),
command_id
(字符串),
direction
(枚举),
noise_suppression_engine
(枚举),
noise_suppression_engine_config
(对象)
java
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_stop
Optional:
client_state
(string),
command_id
(string)
java
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_state
(字符串),
command_id
(字符串)
java
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_role
— Required:
role
java
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_role
— 必填参数:
role
java
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
telnyx-timestamp
and
telnyx-signature-ed25519
headers for verification (Standard Webhooks compatible).
EventDescription
callReferStarted
Call Refer Started
callReferCompleted
Call Refer Completed
callReferFailed
Call Refer Failed
callSiprecStarted
Call Siprec Started
callSiprecStopped
Call Siprec Stopped
callSiprecFailed
Call Siprec Failed
以下Webhook事件将发送到您配置的Webhook URL。 所有Webhook均包含
telnyx-timestamp
telnyx-signature-ed25519
头信息用于验证(兼容标准Webhook)。
事件描述
callReferStarted
呼叫转接已启动
callReferCompleted
呼叫转接已完成
callReferFailed
呼叫转接失败
callSiprecStarted
SIPREC会话已启动
callSiprecStopped
SIPREC会话已停止
callSiprecFailed
SIPREC会话失败

Webhook payload fields

Webhook负载字段

callReferStarted
FieldTypeDescription
data.record_type
enumIdentifies the type of the resource.
data.event_type
enumThe type of event being delivered.
data.id
uuidIdentifies the type of resource.
data.occurred_at
date-timeISO 8601 datetime of when the event occurred.
data.payload.call_control_id
stringUnique ID for controlling the call.
data.payload.call_leg_id
stringID that is unique to the call and can be used to correlate webhook events.
data.payload.call_session_id
stringID that is unique to the call session and can be used to correlate webhook events.
data.payload.connection_id
stringCall Control App ID (formerly Telnyx connection ID) used in the call.
data.payload.client_state
stringState received from a command.
data.payload.from
stringNumber or SIP URI placing the call.
data.payload.sip_notify_response
integerSIP NOTIFY event status for tracking the REFER attempt.
data.payload.to
stringDestination number or SIP URI of the call.
callReferCompleted
FieldTypeDescription
data.record_type
enumIdentifies the type of the resource.
data.event_type
enumThe type of event being delivered.
data.id
uuidIdentifies the type of resource.
data.occurred_at
date-timeISO 8601 datetime of when the event occurred.
data.payload.call_control_id
stringUnique ID for controlling the call.
data.payload.call_leg_id
stringID that is unique to the call and can be used to correlate webhook events.
data.payload.call_session_id
stringID that is unique to the call session and can be used to correlate webhook events.
data.payload.connection_id
stringCall Control App ID (formerly Telnyx connection ID) used in the call.
data.payload.client_state
stringState received from a command.
data.payload.from
stringNumber or SIP URI placing the call.
data.payload.sip_notify_response
integerSIP NOTIFY event status for tracking the REFER attempt.
data.payload.to
stringDestination number or SIP URI of the call.
callReferFailed
FieldTypeDescription
data.record_type
enumIdentifies the type of the resource.
data.event_type
enumThe type of event being delivered.
data.id
uuidIdentifies the type of resource.
data.occurred_at
date-timeISO 8601 datetime of when the event occurred.
data.payload.call_control_id
stringUnique ID for controlling the call.
data.payload.call_leg_id
stringID that is unique to the call and can be used to correlate webhook events.
data.payload.call_session_id
stringID that is unique to the call session and can be used to correlate webhook events.
data.payload.connection_id
stringCall Control App ID (formerly Telnyx connection ID) used in the call.
data.payload.client_state
stringState received from a command.
data.payload.from
stringNumber or SIP URI placing the call.
data.payload.sip_notify_response
integerSIP NOTIFY event status for tracking the REFER attempt.
data.payload.to
stringDestination number or SIP URI of the call.
callSiprecStarted
FieldTypeDescription
data.record_type
enumIdentifies the type of the resource.
data.event_type
enumThe type of event being delivered.
data.id
uuidIdentifies the type of resource.
data.occurred_at
date-timeISO 8601 datetime of when the event occurred.
data.payload.call_control_id
stringCall ID used to issue commands via Call Control API.
data.payload.connection_id
stringCall Control App ID (formerly Telnyx connection ID) used in the call.
data.payload.call_leg_id
stringID that is unique to the call and can be used to correlate webhook events.
data.payload.call_session_id
stringID that is unique to the call session and can be used to correlate webhook events.
data.payload.client_state
stringState received from a command.
callSiprecStopped
FieldTypeDescription
data.record_type
enumIdentifies the type of the resource.
data.event_type
enumThe type of event being delivered.
data.id
uuidIdentifies the type of resource.
data.occurred_at
date-timeISO 8601 datetime of when the event occurred.
data.payload.call_control_id
stringCall ID used to issue commands via Call Control API.
data.payload.connection_id
stringCall Control App ID (formerly Telnyx connection ID) used in the call.
data.payload.call_leg_id
stringID that is unique to the call and can be used to correlate webhook events.
data.payload.call_session_id
stringID that is unique to the call session and can be used to correlate webhook events.
data.payload.client_state
stringState received from a command.
data.payload.hangup_cause
stringQ850 reason why the SIPREC session was stopped.
callSiprecFailed
FieldTypeDescription
data.record_type
enumIdentifies the resource.
data.event_type
enumThe type of event being delivered.
data.id
uuidIdentifies the type of resource.
data.occurred_at
date-timeISO 8601 datetime of when the event occurred.
data.payload.call_control_id
stringCall ID used to issue commands via Call Control API.
data.payload.connection_id
stringCall Control App ID (formerly Telnyx connection ID) used in the call.
data.payload.call_leg_id
stringID that is unique to the call and can be used to correlate webhook events.
data.payload.call_session_id
stringID that is unique to the call session and can be used to correlate webhook events.
data.payload.client_state
stringState received from a command.
data.payload.failure_cause
stringQ850 reason why siprec session failed.
callReferStarted
字段类型描述
data.record_type
枚举标识资源类型。
data.event_type
枚举传递的事件类型。
data.id
UUID标识资源类型。
data.occurred_at
日期时间事件发生的ISO 8601格式时间。
data.payload.call_control_id
字符串用于控制通话的唯一ID。
data.payload.call_leg_id
字符串通话的唯一ID,可用于关联Webhook事件。
data.payload.call_session_id
字符串通话会话的唯一ID,可用于关联Webhook事件。
data.payload.connection_id
字符串通话中使用的呼叫控制应用ID(原Telnyx连接ID)。
data.payload.client_state
字符串从命令中接收的状态。
data.payload.from
字符串发起通话的号码或SIP URI。
data.payload.sip_notify_response
整数用于跟踪转接尝试的SIP NOTIFY事件状态。
data.payload.to
字符串通话的目标号码或SIP URI。
callReferCompleted
字段类型描述
data.record_type
枚举标识资源类型。
data.event_type
枚举传递的事件类型。
data.id
UUID标识资源类型。
data.occurred_at
日期时间事件发生的ISO 8601格式时间。
data.payload.call_control_id
字符串用于控制通话的唯一ID。
data.payload.call_leg_id
字符串通话的唯一ID,可用于关联Webhook事件。
data.payload.call_session_id
字符串通话会话的唯一ID,可用于关联Webhook事件。
data.payload.connection_id
字符串通话中使用的呼叫控制应用ID(原Telnyx连接ID)。
data.payload.client_state
字符串从命令中接收的状态。
data.payload.from
字符串发起通话的号码或SIP URI。
data.payload.sip_notify_response
整数用于跟踪转接尝试的SIP NOTIFY事件状态。
data.payload.to
字符串通话的目标号码或SIP URI。
callReferFailed
字段类型描述
data.record_type
枚举标识资源类型。
data.event_type
枚举传递的事件类型。
data.id
UUID标识资源类型。
data.occurred_at
日期时间事件发生的ISO 8601格式时间。
data.payload.call_control_id
字符串用于控制通话的唯一ID。
data.payload.call_leg_id
字符串通话的唯一ID,可用于关联Webhook事件。
data.payload.call_session_id
字符串通话会话的唯一ID,可用于关联Webhook事件。
data.payload.connection_id
字符串通话中使用的呼叫控制应用ID(原Telnyx连接ID)。
data.payload.client_state
字符串从命令中接收的状态。
data.payload.from
字符串发起通话的号码或SIP URI。
data.payload.sip_notify_response
整数用于跟踪转接尝试的SIP NOTIFY事件状态。
data.payload.to
字符串通话的目标号码或SIP URI。
callSiprecStarted
字段类型描述
data.record_type
枚举标识资源类型。
data.event_type
枚举传递的事件类型。
data.id
UUID标识资源类型。
data.occurred_at
日期时间事件发生的ISO 8601格式时间。
data.payload.call_control_id
字符串用于通过呼叫控制API发送命令的通话ID。
data.payload.connection_id
字符串通话中使用的呼叫控制应用ID(原Telnyx连接ID)。
data.payload.call_leg_id
字符串通话的唯一ID,可用于关联Webhook事件。
data.payload.call_session_id
字符串通话会话的唯一ID,可用于关联Webhook事件。
data.payload.client_state
字符串从命令中接收的状态。
callSiprecStopped
字段类型描述
data.record_type
枚举标识资源类型。
data.event_type
枚举传递的事件类型。
data.id
UUID标识资源类型。
data.occurred_at
日期时间事件发生的ISO 8601格式时间。
data.payload.call_control_id
字符串用于通过呼叫控制API发送命令的通话ID。
data.payload.connection_id
字符串通话中使用的呼叫控制应用ID(原Telnyx连接ID)。
data.payload.call_leg_id
字符串通话的唯一ID,可用于关联Webhook事件。
data.payload.call_session_id
字符串通话会话的唯一ID,可用于关联Webhook事件。
data.payload.client_state
字符串从命令中接收的状态。
data.payload.hangup_cause
字符串SIPREC会话停止的Q850原因码。
callSiprecFailed
字段类型描述
data.record_type
枚举标识资源类型。
data.event_type
枚举传递的事件类型。
data.id
UUID标识资源类型。
data.occurred_at
日期时间事件发生的ISO 8601格式时间。
data.payload.call_control_id
字符串用于通过呼叫控制API发送命令的通话ID。
data.payload.connection_id
字符串通话中使用的呼叫控制应用ID(原Telnyx连接ID)。
data.payload.call_leg_id
字符串通话的唯一ID,可用于关联Webhook事件。
data.payload.call_session_id
字符串通话会话的唯一ID,可用于关联Webhook事件。
data.payload.client_state
字符串从命令中接收的状态。
data.payload.failure_cause
字符串SIPREC会话失败的Q850原因码。