telnyx-voice-media-go
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 Media - Go
Telnyx 语音媒体 - Go
Installation
安装
bash
go get github.com/team-telnyx/telnyx-gobash
go get github.com/team-telnyx/telnyx-goSetup
配置
go
import (
"context"
"fmt"
"os"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
client := telnyx.NewClient(
option.WithAPIKey(os.Getenv("TELNYX_API_KEY")),
)All examples below assume is already initialized as shown above.
clientgo
import (
"context"
"fmt"
"os"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
client := telnyx.NewClient(
option.WithAPIKey(os.Getenv("TELNYX_API_KEY")),
)以下所有示例均假设已按照上述方式完成初始化。
clientError Handling
错误处理
All API calls can fail with network errors, rate limits (429), validation errors (422),
or authentication errors (401). Always handle errors in production code:
go
import "errors"
result, err := client.Messages.Send(ctx, params)
if err != nil {
var apiErr *telnyx.Error
if errors.As(err, &apiErr) {
switch apiErr.StatusCode {
case 422:
fmt.Println("Validation error — check required fields and formats")
case 429:
// Rate limited — wait and retry with exponential backoff
fmt.Println("Rate limited, retrying...")
default:
fmt.Printf("API error %d: %s\n", apiErr.StatusCode, apiErr.Error())
}
} else {
fmt.Println("Network error — check connectivity and retry")
}
}Common error codes: invalid API key, insufficient permissions,
resource not found, validation error (check field formats),
rate limited (retry with exponential backoff).
401403404422429所有API调用都可能失败,原因包括网络错误、速率限制(429)、校验错误(422)或身份验证错误(401)。在生产代码中请务必处理错误:
go
import "errors"
result, err := client.Messages.Send(ctx, params)
if err != nil {
var apiErr *telnyx.Error
if errors.As(err, &apiErr) {
switch apiErr.StatusCode {
case 422:
fmt.Println("校验错误 — 请检查必填字段和格式")
case 429:
// 触发速率限制 — 等待后使用指数退避策略重试
fmt.Println("触发速率限制,正在重试...")
default:
fmt.Printf("API错误 %d: %s\n", apiErr.StatusCode, apiErr.Error())
}
} else {
fmt.Println("网络错误 — 请检查连接后重试")
}
}常见错误码: API密钥无效, 权限不足, 资源未找到, 校验错误(检查字段格式), 触发速率限制(使用指数退避策略重试)。
401403404422429Play audio URL
播放音频URL
Play an audio file on the call. If multiple play audio commands are issued consecutively,
the audio files will be placed in a queue awaiting playback. Notes:
- When is enabled,
overlayis limited totarget_legs.self
POST /calls/{call_control_id}/actions/playback_startOptional: (enum: mp3, wav), (string), (boolean), (string), (string), (string), (string), (boolean), (string), (string), (string)
audio_typeaudio_urlcache_audioclient_statecommand_idloopmedia_nameoverlayplayback_contentstoptarget_legsgo
response, err := client.Calls.Actions.StartPlayback(
context.Background(),
"call_control_id",
telnyx.CallActionStartPlaybackParams{
AudioURL: "https://example.com/audio.mp3",
},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)Returns: (string)
result在通话中播放音频文件。如果连续发出多个播放音频的命令,音频文件会进入队列等待播放。注意:
- 启用时,
overlay仅支持target_legs取值。self
POST /calls/{call_control_id}/actions/playback_start可选参数: (枚举值: mp3, wav), (字符串), (布尔值), (字符串), (字符串), (字符串), (字符串), (布尔值), (字符串), (字符串), (字符串)
audio_typeaudio_urlcache_audioclient_statecommand_idloopmedia_nameoverlayplayback_contentstoptarget_legsgo
response, err := client.Calls.Actions.StartPlayback(
context.Background(),
"call_control_id",
telnyx.CallActionStartPlaybackParams{
AudioURL: "https://example.com/audio.mp3",
},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)返回值: (字符串)
resultStop audio playback
停止音频播放
Stop audio being played on the call. Expected Webhooks:
- or
call.playback.endedcall.speak.ended
POST /calls/{call_control_id}/actions/playback_stopOptional: (string), (string), (boolean), (string)
client_statecommand_idoverlaystopgo
response, err := client.Calls.Actions.StopPlayback(
context.Background(),
"call_control_id",
telnyx.CallActionStopPlaybackParams{},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)Returns: (string)
result停止通话中正在播放的音频。预期Webhook:
- 或
call.playback.endedcall.speak.ended
POST /calls/{call_control_id}/actions/playback_stop可选参数: (字符串), (字符串), (布尔值), (字符串)
client_statecommand_idoverlaystopgo
response, err := client.Calls.Actions.StopPlayback(
context.Background(),
"call_control_id",
telnyx.CallActionStopPlaybackParams{},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)返回值: (字符串)
resultRecord pause
暂停录制
Pause recording the call. Recording can be resumed via Resume recording command. Expected Webhooks:
There are no webhooks associated with this command.
POST /calls/{call_control_id}/actions/record_pauseOptional: (string), (string), (uuid)
client_statecommand_idrecording_idgo
response, err := client.Calls.Actions.PauseRecording(
context.Background(),
"call_control_id",
telnyx.CallActionPauseRecordingParams{},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)Returns: (string)
result暂停通话录制。可以通过恢复录制命令恢复录制。预期Webhook:
该命令没有关联的Webhook。
POST /calls/{call_control_id}/actions/record_pause可选参数: (字符串), (字符串), (uuid)
client_statecommand_idrecording_idgo
response, err := client.Calls.Actions.PauseRecording(
context.Background(),
"call_control_id",
telnyx.CallActionPauseRecordingParams{},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)返回值: (字符串)
resultRecord resume
恢复录制
Resume recording the call. Expected Webhooks:
There are no webhooks associated with this command.
POST /calls/{call_control_id}/actions/record_resumeOptional: (string), (string), (uuid)
client_statecommand_idrecording_idgo
response, err := client.Calls.Actions.ResumeRecording(
context.Background(),
"call_control_id",
telnyx.CallActionResumeRecordingParams{},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)Returns: (string)
result恢复通话录制。预期Webhook:
该命令没有关联的Webhook。
POST /calls/{call_control_id}/actions/record_resume可选参数: (字符串), (字符串), (uuid)
client_statecommand_idrecording_idgo
response, err := client.Calls.Actions.ResumeRecording(
context.Background(),
"call_control_id",
telnyx.CallActionResumeRecordingParams{},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)返回值: (字符串)
resultRecording start
开始录制
Start recording the call. Recording will stop on call hang-up, or can be initiated via the Stop Recording command. Expected Webhooks:
call.recording.savedcall.recording.transcription.savedcall.recording.error
POST /calls/{call_control_id}/actions/record_startformatchannelsOptional: (string), (string), (string), (int32), (boolean), (enum: both, inbound, outbound), (int32), (boolean), (enum: A, B, deepgram/nova-3), (enum: af, af-ZA, am, am-ET, ar, ar-AE, ar-BH, ar-DZ, ar-EG, ar-IL, ar-IQ, ar-JO, ar-KW, ar-LB, ar-MA, ar-MR, ar-OM, ar-PS, ar-QA, ar-SA, ar-TN, ar-YE, as, auto_detect, az, az-AZ, ba, be, bg, bg-BG, bn, bn-BD, bn-IN, bo, br, bs, bs-BA, ca, ca-ES, cs, cs-CZ, cy, da, da-DK, de, de-AT, de-CH, de-DE, el, el-GR, en, en-AU, en-CA, en-GB, en-GH, en-HK, en-IE, en-IN, en-KE, en-NG, en-NZ, en-PH, en-PK, en-SG, en-TZ, en-US, en-ZA, es, es-419, es-AR, es-BO, es-CL, es-CO, es-CR, es-DO, es-EC, es-ES, es-GT, es-HN, es-MX, es-NI, es-PA, es-PE, es-PR, es-PY, es-SV, es-US, es-UY, es-VE, et, et-EE, eu, eu-ES, fa, fa-IR, fi, fi-FI, fil-PH, fo, fr, fr-BE, fr-CA, fr-CH, fr-FR, gl, gl-ES, gu, gu-IN, ha, haw, he, hi, hi-IN, hr, hr-HR, ht, hu, hu-HU, hy, hy-AM, id, id-ID, is, is-IS, it, it-CH, it-IT, iw-IL, ja, ja-JP, jv-ID, jw, ka, ka-GE, kk, kk-KZ, km, km-KH, kn, kn-IN, ko, ko-KR, la, lb, ln, lo, lo-LA, lt, lt-LT, lv, lv-LV, mg, mi, mk, mk-MK, ml, ml-IN, mn, mn-MN, mr, mr-IN, ms, ms-MY, mt, my, my-MM, ne, ne-NP, nl, nl-BE, nl-NL, nn, no, no-NO, oc, pa, pa-Guru-IN, pl, pl-PL, ps, pt, pt-BR, pt-PT, ro, ro-RO, ru, ru-RU, rw-RW, sa, sd, si, si-LK, sk, sk-SK, sl, sl-SI, sn, so, sq, sq-AL, sr, sr-RS, ss-latn-za, st-ZA, su, su-ID, sv, sv-SE, sw, sw-KE, sw-TZ, ta, ta-IN, ta-LK, ta-MY, ta-SG, te, te-IN, tg, th, th-TH, tk, tl, tn-latn-za, tr, tr-TR, ts-ZA, tt, uk, uk-UA, ur, ur-IN, ur-PK, uz, uz-UZ, ve-ZA, vi, vi-VN, xh-ZA, yi, yo, yue-Hant-HK, zh, zh-TW, zu-ZA), (int32), (int32), (boolean), (boolean), (enum: trim-silence)
client_statecommand_idcustom_file_namemax_lengthplay_beeprecording_tracktimeout_secstranscriptiontranscription_enginetranscription_languagetranscription_max_speaker_counttranscription_min_speaker_counttranscription_profanity_filtertranscription_speaker_diarizationtrimgo
response, err := client.Calls.Actions.StartRecording(
context.Background(),
"call_control_id",
telnyx.CallActionStartRecordingParams{
Channels: telnyx.CallActionStartRecordingParamsChannelsSingle,
Format: telnyx.CallActionStartRecordingParamsFormatWav,
},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)Returns: (string)
result开始通话录制。录制会在通话挂断时停止,也可以通过停止录制命令主动终止。预期Webhook:
call.recording.savedcall.recording.transcription.savedcall.recording.error
POST /calls/{call_control_id}/actions/record_startformatchannels可选参数: (字符串), (字符串), (字符串), (int32), (布尔值), (枚举值: both, inbound, outbound), (int32), (布尔值), (枚举值: A, B, deepgram/nova-3), (枚举值: af, af-ZA, am, am-ET, ar, ar-AE, ar-BH, ar-DZ, ar-EG, ar-IL, ar-IQ, ar-JO, ar-KW, ar-LB, ar-MA, ar-MR, ar-OM, ar-PS, ar-QA, ar-SA, ar-TN, ar-YE, as, auto_detect, az, az-AZ, ba, be, bg, bg-BG, bn, bn-BD, bn-IN, bo, br, bs, bs-BA, ca, ca-ES, cs, cs-CZ, cy, da, da-DK, de, de-AT, de-CH, de-DE, el, el-GR, en, en-AU, en-CA, en-GB, en-GH, en-HK, en-IE, en-IN, en-KE, en-NG, en-NZ, en-PH, en-PK, en-SG, en-TZ, en-US, en-ZA, es, es-419, es-AR, es-BO, es-CL, es-CO, es-CR, es-DO, es-EC, es-ES, es-GT, es-HN, es-MX, es-NI, es-PA, es-PE, es-PR, es-PY, es-SV, es-US, es-UY, es-VE, et, et-EE, eu, eu-ES, fa, fa-IR, fi, fi-FI, fil-PH, fo, fr, fr-BE, fr-CA, fr-CH, fr-FR, gl, gl-ES, gu, gu-IN, ha, haw, he, hi, hi-IN, hr, hr-HR, ht, hu, hu-HU, hy, hy-AM, id, id-ID, is, is-IS, it, it-CH, it-IT, iw-IL, ja, ja-JP, jv-ID, jw, ka, ka-GE, kk, kk-KZ, km, km-KH, kn, kn-IN, ko, ko-KR, la, lb, ln, lo, lo-LA, lt, lt-LT, lv, lv-LV, mg, mi, mk, mk-MK, ml, ml-IN, mn, mn-MN, mr, mr-IN, ms, ms-MY, mt, my, my-MM, ne, ne-NP, nl, nl-BE, nl-NL, nn, no, no-NO, oc, pa, pa-Guru-IN, pl, pl-PL, ps, pt, pt-BR, pt-PT, ro, ro-RO, ru, ru-RU, rw-RW, sa, sd, si, si-LK, sk, sk-SK, sl, sl-SI, sn, so, sq, sq-AL, sr, sr-RS, ss-latn-za, st-ZA, su, su-ID, sv, sv-SE, sw, sw-KE, sw-TZ, ta, ta-IN, ta-LK, ta-MY, ta-SG, te, te-IN, tg, th, th-TH, tk, tl, tn-latn-za, tr, tr-TR, ts-ZA, tt, uk, uk-UA, ur, ur-IN, ur-PK, uz, uz-UZ, ve-ZA, vi, vi-VN, xh-ZA, yi, yo, yue-Hant-HK, zh, zh-TW, zu-ZA), (int32), (int32), (布尔值), (布尔值), (枚举值: trim-silence)
client_statecommand_idcustom_file_namemax_lengthplay_beeprecording_tracktimeout_secstranscriptiontranscription_enginetranscription_languagetranscription_max_speaker_counttranscription_min_speaker_counttranscription_profanity_filtertranscription_speaker_diarizationtrimgo
response, err := client.Calls.Actions.StartRecording(
context.Background(),
"call_control_id",
telnyx.CallActionStartRecordingParams{
Channels: telnyx.CallActionStartRecordingParamsChannelsSingle,
Format: telnyx.CallActionStartRecordingParamsFormatWav,
},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)返回值: (字符串)
resultRecording stop
停止录制
Stop recording the call. Expected Webhooks:
call.recording.saved
POST /calls/{call_control_id}/actions/record_stopOptional: (string), (string), (uuid)
client_statecommand_idrecording_idgo
response, err := client.Calls.Actions.StopRecording(
context.Background(),
"call_control_id",
telnyx.CallActionStopRecordingParams{
StopRecordingRequest: telnyx.StopRecordingRequestParam{},
},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)Returns: (string)
result停止通话录制。预期Webhook:
call.recording.saved
POST /calls/{call_control_id}/actions/record_stop可选参数: (字符串), (字符串), (uuid)
client_statecommand_idrecording_idgo
response, err := client.Calls.Actions.StopRecording(
context.Background(),
"call_control_id",
telnyx.CallActionStopRecordingParams{
StopRecordingRequest: telnyx.StopRecordingRequestParam{},
},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)返回值: (字符串)
resultSpeak text
文本语音播报
Convert text to speech and play it back on the call. If multiple speak text commands are issued consecutively, the audio files will be placed in a queue awaiting playback. Expected Webhooks:
call.speak.startedcall.speak.ended
POST /calls/{call_control_id}/actions/speakpayloadvoiceOptional: (string), (string), (enum: arb, cmn-CN, cy-GB, da-DK, de-DE, en-AU, en-GB, en-GB-WLS, en-IN, en-US, es-ES, es-MX, es-US, fr-CA, fr-FR, hi-IN, is-IS, it-IT, ja-JP, ko-KR, nb-NO, nl-NL, pl-PL, pt-BR, pt-PT, ro-RO, ru-RU, sv-SE, tr-TR), (string), (enum: text, ssml), (enum: basic, premium), (string), (enum: self, opposite, both), (object)
client_statecommand_idlanguagelooppayload_typeservice_levelstoptarget_legsvoice_settingsgo
response, err := client.Calls.Actions.Speak(
context.Background(),
"call_control_id",
telnyx.CallActionSpeakParams{
Payload: "Say this on the call",
Voice: "female",
},
)
if err != nil {
log.Fatal(err)
Language: "en-US",
}
fmt.Printf("%+v\n", response.Data)Returns: (string)
result将文本转换为语音并在通话中播放。如果连续发出多个文本播报命令,生成的音频会进入队列等待播放。预期Webhook:
call.speak.startedcall.speak.ended
POST /calls/{call_control_id}/actions/speakpayloadvoice可选参数: (字符串), (字符串), (枚举值: arb, cmn-CN, cy-GB, da-DK, de-DE, en-AU, en-GB, en-GB-WLS, en-IN, en-US, es-ES, es-MX, es-US, fr-CA, fr-FR, hi-IN, is-IS, it-IT, ja-JP, ko-KR, nb-NO, nl-NL, pl-PL, pt-BR, pt-PT, ro-RO, ru-RU, sv-SE, tr-TR), (字符串), (枚举值: text, ssml), (枚举值: basic, premium), (字符串), (枚举值: self, opposite, both), (对象)
client_statecommand_idlanguagelooppayload_typeservice_levelstoptarget_legsvoice_settingsgo
response, err := client.Calls.Actions.Speak(
context.Background(),
"call_control_id",
telnyx.CallActionSpeakParams{
Payload: "Say this on the call",
Voice: "female",
},
)
if err != nil {
log.Fatal(err)
Language: "en-US",
}
fmt.Printf("%+v\n", response.Data)返回值: (字符串)
resultWebhooks
Webhooks
Webhook Verification
Webhook 验证
Telnyx signs webhooks with Ed25519. Each request includes
and headers. Always verify signatures in production:
telnyx-signature-ed25519telnyx-timestampgo
// In your webhook handler:
func handleWebhook(w http.ResponseWriter, r *http.Request) {
body, _ := io.ReadAll(r.Body)
event, err := client.Webhooks.Unwrap(body, r.Header)
if err != nil {
http.Error(w, "Invalid signature", http.StatusBadRequest)
return
}
// Signature valid — event is the parsed webhook payload
fmt.Println("Received event:", event.Data.EventType)
w.WriteHeader(http.StatusOK)
}The following webhook events are sent to your configured webhook URL.
All webhooks include and headers for Ed25519 signature verification. Use to verify.
telnyx-timestamptelnyx-signature-ed25519client.webhooks.unwrap()| Event | Description |
|---|---|
| Call Playback Ended |
| Call Playback Started |
| Call Recording Error |
| Call Recording Saved |
| Call Recording Transcription Saved |
| Call Speak Ended |
| Call Speak Started |
Telnyx使用Ed25519对Webhook进行签名。每个请求都包含和头。生产环境中请务必验证签名:
telnyx-signature-ed25519telnyx-timestampgo
// 在你的Webhook处理函数中:
func handleWebhook(w http.ResponseWriter, r *http.Request) {
body, _ := io.ReadAll(r.Body)
event, err := client.Webhooks.Unwrap(body, r.Header)
if err != nil {
http.Error(w, "Invalid signature", http.StatusBadRequest)
return
}
// 签名有效 — event为解析后的Webhook payload
fmt.Println("Received event:", event.Data.EventType)
w.WriteHeader(http.StatusOK)
}以下Webhook事件会发送到你配置的Webhook URL。所有Webhook都包含和头,用于Ed25519签名验证。可使用完成验证。
telnyx-timestamptelnyx-signature-ed25519client.webhooks.unwrap()| 事件 | 描述 |
|---|---|
| 通话播放结束 |
| 通话播放开始 |
| 通话录制错误 |
| 通话录制已保存 |
| 通话录制转写已保存 |
| 通话语音播报结束 |
| 通话语音播报开始 |
Webhook payload fields
Webhook payload 字段
callPlaybackEnded| Field | Type | Description |
|---|---|---|
| enum: event | Identifies the type of the resource. |
| enum: call.playback.ended | 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 | The audio URL being played back, if audio_url has been used to start. |
| string | The name of the audio media file being played back, if media_name has been used to start. |
| boolean | Whether the stopped audio was in overlay mode or not. |
| enum: file_not_found, call_hangup, unknown, cancelled, cancelled_amd, completed, failed | Reflects how command ended. |
| string | Provides details in case of failure. |
callPlaybackStarted| Field | Type | Description |
|---|---|---|
| enum: event | Identifies the type of the resource. |
| enum: call.playback.started | 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 | The audio URL being played back, if audio_url has been used to start. |
| string | The name of the audio media file being played back, if media_name has been used to start. |
| boolean | Whether the audio is going to be played in overlay mode or not. |
callRecordingError| Field | Type | Description |
|---|---|---|
| enum: event | Identifies the type of the resource. |
| enum: call.recording.error | 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. |
| enum: Failed to authorize with storage using custom credentials, Invalid credentials json, Unsupported backend, Internal server error | Indication that there was a problem recording the call. |
callRecordingSaved| Field | Type | Description |
|---|---|---|
| enum: event | Identifies the type of the resource. |
| enum: call.recording.saved | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| 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. |
| date-time | ISO 8601 datetime of when recording started. |
| date-time | ISO 8601 datetime of when recording ended. |
| enum: single, dual | Whether recording was recorded in |
callRecordingTranscriptionSaved| Field | Type | Description |
|---|---|---|
| enum: event | Identifies the type of the resource. |
| enum: call.recording.transcription.saved | 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. |
| enum: pstn, sip | The type of calling party connection. |
| string | ID that is unique to the recording session and can be used to correlate webhook events. |
| string | ID that is unique to the transcription process and can be used to correlate webhook events. |
| enum: completed | The transcription status. |
| string | The transcribed text |
callSpeakEnded| Field | Type | Description |
|---|---|---|
| enum: event | Identifies the type of the resource. |
| enum: call.speak.ended | 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. |
| enum: completed, call_hangup, cancelled_amd | Reflects how the command ended. |
callSpeakStarted| Field | Type | Description |
|---|---|---|
| enum: event | Identifies the type of the resource. |
| enum: call.speak.started | 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. |
callPlaybackEnded| 字段 | 类型 | 描述 |
|---|---|---|
| 枚举值: event | 标识资源类型 |
| 枚举值: call.playback.ended | 推送的事件类型 |
| uuid | 标识资源类型 |
| date-time | 事件发生的ISO 8601格式时间 |
| 字符串 | 用于通过Call Control API下发命令的通话ID |
| 字符串 | 通话中使用的Call Control App ID(原Telnyx connection ID) |
| 字符串 | 通话唯一ID,可用于关联Webhook事件 |
| 字符串 | 通话会话唯一ID,可用于关联Webhook事件 |
| 字符串 | 从命令中接收的状态 |
| 字符串 | 正在播放的音频URL(若使用audio_url启动播放) |
| 字符串 | 正在播放的音频媒体文件名(若使用media_name启动播放) |
| 布尔值 | 已停止的音频是否处于叠加模式 |
| 枚举值: file_not_found, call_hangup, unknown, cancelled, cancelled_amd, completed, failed | 反映命令结束的原因 |
| 字符串 | 失败情况下的详细说明 |
callPlaybackStarted| 字段 | 类型 | 描述 |
|---|---|---|
| 枚举值: event | 标识资源类型 |
| 枚举值: call.playback.started | 推送的事件类型 |
| uuid | 标识资源类型 |
| date-time | 事件发生的ISO 8601格式时间 |
| 字符串 | 用于通过Call Control API下发命令的通话ID |
| 字符串 | 通话中使用的Call Control App ID(原Telnyx connection ID) |
| 字符串 | 通话唯一ID,可用于关联Webhook事件 |
| 字符串 | 通话会话唯一ID,可用于关联Webhook事件 |
| 字符串 | 从命令中接收的状态 |
| 字符串 | 正在播放的音频URL(若使用audio_url启动播放) |
| 字符串 | 正在播放的音频媒体文件名(若使用media_name启动播放) |
| 布尔值 | 音频是否将以叠加模式播放 |
callRecordingError| 字段 | 类型 | 描述 |
|---|---|---|
| 枚举值: event | 标识资源类型 |
| 枚举值: call.recording.error | 推送的事件类型 |
| uuid | 标识资源类型 |
| date-time | 事件发生的ISO 8601格式时间 |
| 字符串 | 用于通过Call Control API下发命令的通话ID |
| 字符串 | 通话中使用的Call Control App ID(原Telnyx connection ID) |
| 字符串 | 通话唯一ID,可用于关联Webhook事件 |
| 字符串 | 通话会话唯一ID,可用于关联Webhook事件 |
| 字符串 | 从命令中接收的状态 |
| 枚举值: Failed to authorize with storage using custom credentials, Invalid credentials json, Unsupported backend, Internal server error | 表示通话录制出现问题的原因 |
callRecordingSaved| 字段 | 类型 | 描述 |
|---|---|---|
| 枚举值: event | 标识资源类型 |
| 枚举值: call.recording.saved | 推送的事件类型 |
| uuid | 标识资源类型 |
| date-time | 事件发生的ISO 8601格式时间 |
| 字符串 | 通话唯一ID,可用于关联Webhook事件 |
| 字符串 | 通话会话唯一ID,可用于关联Webhook事件 |
| 字符串 | 通话中使用的Call Control App ID(原Telnyx connection ID) |
| 字符串 | 从命令中接收的状态 |
| date-time | 录制开始的ISO 8601格式时间 |
| date-time | 录制结束的ISO 8601格式时间 |
| 枚举值: single, dual | 录制使用的是单声道还是双声道 |
callRecordingTranscriptionSaved| 字段 | 类型 | 描述 |
|---|---|---|
| 枚举值: event | 标识资源类型 |
| 枚举值: call.recording.transcription.saved | 推送的事件类型 |
| uuid | 标识资源类型 |
| date-time | 事件发生的ISO 8601格式时间 |
| 字符串 | 用于通过Call Control API下发命令的通话ID |
| 字符串 | 通话中使用的Call Control App ID(原Telnyx connection ID) |
| 字符串 | 通话唯一ID,可用于关联Webhook事件 |
| 字符串 | 通话会话唯一ID,可用于关联Webhook事件 |
| 字符串 | 从命令中接收的状态 |
| 枚举值: pstn, sip | 主叫方连接类型 |
| 字符串 | 录制会话唯一ID,可用于关联Webhook事件 |
| 字符串 | 转写流程唯一ID,可用于关联Webhook事件 |
| 枚举值: completed | 转写状态 |
| 字符串 | 转写生成的文本 |
callSpeakEnded| 字段 | 类型 | 描述 |
|---|---|---|
| 枚举值: event | 标识资源类型 |
| 枚举值: call.speak.ended | 推送的事件类型 |
| uuid | 标识资源类型 |
| date-time | 事件发生的ISO 8601格式时间 |
| 字符串 | 用于通过Call Control API下发命令的通话ID |
| 字符串 | 通话中使用的Call Control App ID(原Telnyx connection ID) |
| 字符串 | 通话唯一ID,可用于关联Webhook事件 |
| 字符串 | 通话会话唯一ID,可用于关联Webhook事件 |
| 字符串 | 从命令中接收的状态 |
| 枚举值: completed, call_hangup, cancelled_amd | 反映命令结束的原因 |
callSpeakStarted| 字段 | 类型 | 描述 |
|---|---|---|
| 枚举值: event | 标识资源类型 |
| 枚举值: call.speak.started | 推送的事件类型 |
| uuid | 标识资源类型 |
| date-time | 事件发生的ISO 8601格式时间 |
| 字符串 | 用于通过Call Control API下发命令的通话ID |
| 字符串 | 通话中使用的Call Control App ID(原Telnyx connection ID) |
| 字符串 | 通话唯一ID,可用于关联Webhook事件 |
| 字符串 | 通话会话唯一ID,可用于关联Webhook事件 |
| 字符串 | 从命令中接收的状态 |