Loading...
Loading...
Collect DTMF input and speech from callers using standard gather or AI-powered gather. Build interactive voice menus and AI voice assistants. This skill provides Go SDK examples.
npx skill4agent add team-telnyx/telnyx-ext-agent-skills telnyx-voice-gather-gogo get github.com/team-telnyx/telnyx-goimport (
"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")),
)clientPOST /calls/{call_control_id}/actions/ai_assistant_add_messagesclient_statecommand_idmessages response, err := client.Calls.Actions.AddAIAssistantMessages(
context.TODO(),
"call_control_id",
telnyx.CallActionAddAIAssistantMessagesParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)POST /calls/{call_control_id}/actions/ai_assistant_startassistantclient_statecommand_idgreetinginterruption_settingstranscriptionvoicevoice_settings response, err := client.Calls.Actions.StartAIAssistant(
context.TODO(),
"call_control_id",
telnyx.CallActionStartAIAssistantParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)POST /calls/{call_control_id}/actions/ai_assistant_stopclient_statecommand_id response, err := client.Calls.Actions.StopAIAssistant(
context.TODO(),
"call_control_id",
telnyx.CallActionStopAIAssistantParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)POST /calls/{call_control_id}/actions/gather_stopclient_statecommand_id response, err := client.Calls.Actions.StopGather(
context.TODO(),
"call_control_id",
telnyx.CallActionStopGatherParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)POST /calls/{call_control_id}/actions/gather_using_aiparametersassistantclient_statecommand_idgather_ended_speechgreetinginterruption_settingslanguagemessage_historysend_message_history_updatessend_partial_resultstranscriptionuser_response_timeout_msvoicevoice_settings response, err := client.Calls.Actions.GatherUsingAI(
context.TODO(),
"call_control_id",
telnyx.CallActionGatherUsingAIParams{
Parameters: map[string]any{
"properties": "bar",
"required": "bar",
"type": "bar",
},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)POST /calls/{call_control_id}/actions/gather_using_audioaudio_urlclient_statecommand_idinter_digit_timeout_millisinvalid_audio_urlinvalid_media_namemaximum_digitsmaximum_triesmedia_nameminimum_digitsterminating_digittimeout_millisvalid_digits response, err := client.Calls.Actions.GatherUsingAudio(
context.TODO(),
"call_control_id",
telnyx.CallActionGatherUsingAudioParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)POST /calls/{call_control_id}/actions/gather_using_speakvoicepayloadclient_statecommand_idinter_digit_timeout_millisinvalid_payloadlanguagemaximum_digitsmaximum_triesminimum_digitspayload_typeservice_levelterminating_digittimeout_millisvalid_digitsvoice_settings response, err := client.Calls.Actions.GatherUsingSpeak(
context.TODO(),
"call_control_id",
telnyx.CallActionGatherUsingSpeakParams{
Payload: "say this on call",
Voice: "male",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)POST /calls/{call_control_id}/actions/gatherclient_statecommand_idgather_idinitial_timeout_millisinter_digit_timeout_millismaximum_digitsminimum_digitsterminating_digittimeout_millisvalid_digits response, err := client.Calls.Actions.Gather(
context.TODO(),
"call_control_id",
telnyx.CallActionGatherParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)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 |
callGatherEnded| 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 | Number or SIP URI placing the call. |
| string | Destination number or SIP URI of the call. |
| string | The received DTMF digit or symbol. |
| enum | Reflects how command ended. |
CallAIGatherEnded| 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 | 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 | Number or SIP URI placing the call. |
| string | Destination number or SIP URI of the call. |
| array[object] | The history of the messages exchanged during the AI gather |
| object | The result of the AI gather, its type depends of the |
| enum | Reflects how command ended. |
CallAIGatherMessageHistoryUpdated| 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 | 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 | Number or SIP URI placing the call. |
| string | Destination number or SIP URI of the call. |
| array[object] | The history of the messages exchanged during the AI gather |
CallAIGatherPartialResults| 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 | 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 | Number or SIP URI placing the call. |
| string | Destination number or SIP URI of the call. |
| array[object] | The history of the messages exchanged during the AI gather |
| object | The partial result of the AI gather, its type depends of the |
CallConversationEnded| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| enum | The type of event being delivered. |
| uuid | Unique identifier for the event. |
| date-time | ISO 8601 datetime of when the event occurred. |
| date-time | Timestamp when the event was created in the system. |
| string | Unique identifier of the assistant involved in the call. |
| 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 leg. |
| string | ID that is unique to the call session (group of related call legs). |
| string | Base64-encoded state received from a command. |
| enum | The type of calling party connection. |
| string | ID unique to the conversation or insight group generated for the call. |
| integer | Duration of the conversation in seconds. |
| string | The caller's number or identifier. |
| string | The callee's number or SIP address. |
| string | The large language model used during the conversation. |
| string | The speech-to-text model used in the conversation. |
| string | The text-to-speech provider used in the call. |
| string | The model ID used for text-to-speech synthesis. |
| string | Voice ID used for TTS. |
callPlaybackStarted| 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 | 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. |
callPlaybackEnded| 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 | 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 | Reflects how command ended. |
| string | Provides details in case of failure. |
callDtmfReceived| 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 | Identifies the type of resource. |
| 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 | Number or SIP URI placing the call. |
| string | Destination number or SIP URI of the call. |
| string | The received DTMF digit or symbol. |