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 telnyxbash
npm install telnyxSetup
设置
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 is already initialized as shown above.
clientjavascript
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // 这是默认设置,可省略
});以下所有示例均假设已按照上述方式完成初始化。
clientAdd 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_messagesjavascript
const response = await client.calls.actions.addAIAssistantMessages('call_control_id');
console.log(response.data);向通话中由AI助手发起的对话添加消息。
POST /calls/{call_control_id}/actions/ai_assistant_add_messagesjavascript
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_startjavascript
const response = await client.calls.actions.startAIAssistant('call_control_id');
console.log(response.data);在通话中启动AI助手。
POST /calls/{call_control_id}/actions/ai_assistant_startjavascript
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_stopjavascript
const response = await client.calls.actions.stopAIAssistant('call_control_id');
console.log(response.data);在通话中停止AI助手。
POST /calls/{call_control_id}/actions/ai_assistant_stopjavascript
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_stopjavascript
const response = await client.calls.actions.stopGather('call_control_id');
console.log(response.data);停止当前的收集操作。
POST /calls/{call_control_id}/actions/gather_stopjavascript
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_aiparametersjavascript
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_aiparametersjavascript
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_audiojavascript
const response = await client.calls.actions.gatherUsingAudio('call_control_id');
console.log(response.data);在通话中播放音频文件,直到收集到所需的DTMF信号,以此构建交互式菜单。
POST /calls/{call_control_id}/actions/gather_using_audiojavascript
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_speakvoicepayloadjavascript
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_speakvoicepayloadjavascript
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/gatherjavascript
const response = await client.calls.actions.gather('call_control_id');
console.log(response.data);收集DTMF信号以构建交互式菜单。
POST /calls/{call_control_id}/actions/gatherjavascript
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 and headers for verification (Standard Webhooks compatible).
telnyx-timestamptelnyx-signature-ed25519| Event | Description |
|---|---|
| Call Gather Ended |
| Call AI Gather Ended |
| Call AI Gather Message History Updated |
| Call AI Gather Partial Results |
| Call Conversation Ended |
| Call Playback Started |
| Call Playback Ended |
| Call Dtmf Received |
以下Webhook事件将发送到您配置的Webhook URL。所有Webhook均包含和头信息用于验证(兼容标准Webhooks)。
telnyx-timestamptelnyx-signature-ed25519| 事件 | 描述 |
|---|---|
| 通话收集结束 |
| 通话AI收集结束 |
| 通话AI收集消息历史更新 |
| 通话AI收集部分结果 |
| 通话对话结束 |
| 通话播放开始 |
| 通话播放结束 |
| 收到通话DTMF信号 |