Gather using audio
Play an audio file on the call until the required DTMF signals are gathered to build interactive menus.
You can pass a list of valid digits along with an ‘invalid_audio_url’, which will be played back at the beginning of each prompt. Playback will be interrupted when a DTMF signal is received. The Answer command must be issued before the gather_using_audio` command.
Expected Webhooks:
call.playback.startedcall.playback.endedcall.dtmf.received(you may receive many of these webhooks)call.gather.ended
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const response = await client.calls.actions.gatherUsingAudio('call_control_id');
console.log(response.data);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
response = client.calls.actions.gather_using_audio(
call_control_id="call_control_id",
)
print(response.data)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
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)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.calls.actions.ActionGatherUsingAudioParams;
import com.telnyx.sdk.models.calls.actions.ActionGatherUsingAudioResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
ActionGatherUsingAudioResponse response = client.calls().actions().gatherUsingAudio("call_control_id");
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.calls.actions.gather_using_audio("call_control_id")
puts(response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$response = $client->calls->actions->gatherUsingAudio(
'call_control_id',
audioURL: 'http://example.com/message.wav',
clientState: 'aGF2ZSBhIG5pY2UgZGF5ID1d',
commandID: '891510ac-f3e4-11e8-af5b-de00688a4901',
interDigitTimeoutMillis: 10000,
invalidAudioURL: 'http://example.com/message.wav',
invalidMediaName: 'my_media_uploaded_to_media_storage_api',
maximumDigits: 10,
maximumTries: 3,
mediaName: 'my_media_uploaded_to_media_storage_api',
minimumDigits: 1,
terminatingDigit: '#',
timeoutMillis: 10000,
validDigits: '123',
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx calls:actions gather-using-audio \
--api-key 'My API Key' \
--call-control-id call_control_idcurl --request POST \
--url https://api.telnyx.com/v2/calls/{call_control_id}/actions/gather_using_audio \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"audio_url": "http://example.com/message.wav",
"invalid_audio_url": "http://example.com/message.wav",
"minimum_digits": 1,
"maximum_digits": 10,
"timeout_millis": 10000,
"terminating_digit": "#",
"valid_digits": "123",
"inter_digit_timeout_millis": 10000,
"client_state": "aGF2ZSBhIG5pY2UgZGF5ID1d",
"command_id": "891510ac-f3e4-11e8-af5b-de00688a4901"
}
'{
"data": {
"result": "ok"
}
}Authorizations
Body
Gather using audio request
The URL of a file to play when digits don't match the valid_digits parameter or the number of digits is not between min and max. The URL can point to either a WAV or MP3 file. invalid_media_name and invalid_audio_url cannot be used together in one request.
"http://example.com/invalid.wav"
The media_name of a file to be played back when digits don't match the valid_digits parameter or the number of digits is not between min and max. The media_name must point to a file previously uploaded to api.telnyx.com/v2/media by the same user/organization. The file must either be a WAV or MP3 file.
"my_media_uploaded_to_media_storage_api"
Was this page helpful?
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const response = await client.calls.actions.gatherUsingAudio('call_control_id');
console.log(response.data);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
response = client.calls.actions.gather_using_audio(
call_control_id="call_control_id",
)
print(response.data)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
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)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.calls.actions.ActionGatherUsingAudioParams;
import com.telnyx.sdk.models.calls.actions.ActionGatherUsingAudioResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
ActionGatherUsingAudioResponse response = client.calls().actions().gatherUsingAudio("call_control_id");
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.calls.actions.gather_using_audio("call_control_id")
puts(response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$response = $client->calls->actions->gatherUsingAudio(
'call_control_id',
audioURL: 'http://example.com/message.wav',
clientState: 'aGF2ZSBhIG5pY2UgZGF5ID1d',
commandID: '891510ac-f3e4-11e8-af5b-de00688a4901',
interDigitTimeoutMillis: 10000,
invalidAudioURL: 'http://example.com/message.wav',
invalidMediaName: 'my_media_uploaded_to_media_storage_api',
maximumDigits: 10,
maximumTries: 3,
mediaName: 'my_media_uploaded_to_media_storage_api',
minimumDigits: 1,
terminatingDigit: '#',
timeoutMillis: 10000,
validDigits: '123',
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx calls:actions gather-using-audio \
--api-key 'My API Key' \
--call-control-id call_control_idcurl --request POST \
--url https://api.telnyx.com/v2/calls/{call_control_id}/actions/gather_using_audio \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"audio_url": "http://example.com/message.wav",
"invalid_audio_url": "http://example.com/message.wav",
"minimum_digits": 1,
"maximum_digits": 10,
"timeout_millis": 10000,
"terminating_digit": "#",
"valid_digits": "123",
"inter_digit_timeout_millis": 10000,
"client_state": "aGF2ZSBhIG5pY2UgZGF5ID1d",
"command_id": "891510ac-f3e4-11e8-af5b-de00688a4901"
}
'{
"data": {
"result": "ok"
}
}