telnyx-voice-gather-javascript

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
<!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. -->
<!-- 由Telnyx OpenAPI规范自动生成,请勿编辑。 -->

Telnyx Voice Gather - JavaScript

Telnyx 语音收集 - JavaScript

Installation

安装

bash
npm install telnyx
bash
npm install telnyx

Setup

设置

javascript
import Telnyx from 'telnyx';

const client = new Telnyx({
  apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
All examples below assume
client
is already initialized as shown above.
javascript
import Telnyx from 'telnyx';

const client = new Telnyx({
  apiKey: process.env['TELNYX_API_KEY'], // 这是默认设置,可省略
});
以下所有示例均假设
client
已按照上述方式完成初始化。

Add messages to AI Assistant

向AI助手添加消息

Add messages to the conversation started by an AI assistant on the call.
POST /calls/{call_control_id}/actions/ai_assistant_add_messages
javascript
const response = await client.calls.actions.addAIAssistantMessages('call_control_id');

console.log(response.data);
向通话中由AI助手发起的对话添加消息。
POST /calls/{call_control_id}/actions/ai_assistant_add_messages
javascript
const response = await client.calls.actions.addAIAssistantMessages('call_control_id');

console.log(response.data);

Start AI Assistant

启动AI助手

Start an AI assistant on the call.
POST /calls/{call_control_id}/actions/ai_assistant_start
javascript
const response = await client.calls.actions.startAIAssistant('call_control_id');

console.log(response.data);
在通话中启动AI助手。
POST /calls/{call_control_id}/actions/ai_assistant_start
javascript
const response = await client.calls.actions.startAIAssistant('call_control_id');

console.log(response.data);

Stop AI Assistant

停止AI助手

Stop an AI assistant on the call.
POST /calls/{call_control_id}/actions/ai_assistant_stop
javascript
const response = await client.calls.actions.stopAIAssistant('call_control_id');

console.log(response.data);
在通话中停止AI助手。
POST /calls/{call_control_id}/actions/ai_assistant_stop
javascript
const response = await client.calls.actions.stopAIAssistant('call_control_id');

console.log(response.data);

Gather stop

停止收集

Stop current gather.
POST /calls/{call_control_id}/actions/gather_stop
javascript
const response = await client.calls.actions.stopGather('call_control_id');

console.log(response.data);
停止当前的收集操作。
POST /calls/{call_control_id}/actions/gather_stop
javascript
const response = await client.calls.actions.stopGather('call_control_id');

console.log(response.data);

Gather using AI

基于AI的收集

Gather parameters defined in the request payload using a voice assistant.
POST /calls/{call_control_id}/actions/gather_using_ai
— Required:
parameters
javascript
const response = await client.calls.actions.gatherUsingAI('call_control_id', {
  parameters: {
    properties: 'bar',
    required: 'bar',
    type: 'bar',
  },
});

console.log(response.data);
通过语音助手收集请求负载中定义的参数。
POST /calls/{call_control_id}/actions/gather_using_ai
— 必填:
parameters
javascript
const response = await client.calls.actions.gatherUsingAI('call_control_id', {
  parameters: {
    properties: 'bar',
    required: 'bar',
    type: 'bar',
  },
});

console.log(response.data);

Gather using audio

基于音频的收集

Play an audio file on the call until the required DTMF signals are gathered to build interactive menus.
POST /calls/{call_control_id}/actions/gather_using_audio
javascript
const response = await client.calls.actions.gatherUsingAudio('call_control_id');

console.log(response.data);
在通话中播放音频文件,直到收集到所需的DTMF信号,以此构建交互式菜单。
POST /calls/{call_control_id}/actions/gather_using_audio
javascript
const response = await client.calls.actions.gatherUsingAudio('call_control_id');

console.log(response.data);

Gather using speak

基于语音播报的收集

Convert text to speech and play it on the call until the required DTMF signals are gathered to build interactive menus.
POST /calls/{call_control_id}/actions/gather_using_speak
— Required:
voice
,
payload
javascript
const response = await client.calls.actions.gatherUsingSpeak('call_control_id', {
  payload: 'say this on call',
  voice: 'male',
});

console.log(response.data);
将文本转换为语音并在通话中播放,直到收集到所需的DTMF信号,以此构建交互式菜单。
POST /calls/{call_control_id}/actions/gather_using_speak
— 必填:
voice
,
payload
javascript
const response = await client.calls.actions.gatherUsingSpeak('call_control_id', {
  payload: 'say this on call',
  voice: 'male',
});

console.log(response.data);

Gather

收集

Gather DTMF signals to build interactive menus.
POST /calls/{call_control_id}/actions/gather
javascript
const response = await client.calls.actions.gather('call_control_id');

console.log(response.data);

收集DTMF信号以构建交互式菜单。
POST /calls/{call_control_id}/actions/gather
javascript
const response = await client.calls.actions.gather('call_control_id');

console.log(response.data);

Webhooks

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).
EventDescription
callGatherEnded
Call Gather Ended
CallAIGatherEnded
Call AI Gather Ended
CallAIGatherMessageHistoryUpdated
Call AI Gather Message History Updated
CallAIGatherPartialResults
Call AI Gather Partial Results
CallConversationEnded
Call Conversation Ended
callPlaybackStarted
Call Playback Started
callPlaybackEnded
Call Playback Ended
callDtmfReceived
Call Dtmf Received
以下Webhook事件将发送到您配置的Webhook URL。所有Webhook均包含
telnyx-timestamp
telnyx-signature-ed25519
头信息用于验证(兼容标准Webhooks)。
事件描述
callGatherEnded
通话收集结束
CallAIGatherEnded
通话AI收集结束
CallAIGatherMessageHistoryUpdated
通话AI收集消息历史更新
CallAIGatherPartialResults
通话AI收集部分结果
CallConversationEnded
通话对话结束
callPlaybackStarted
通话播放开始
callPlaybackEnded
通话播放结束
callDtmfReceived
收到通话DTMF信号