Skip to main content

Telnyx Calling: TeXML — Full Documentation

Complete page content for TeXML (Calling section) of the Telnyx developer docs (https://developers.telnyx.com). This file: https://developers.telnyx.com/development/llms/calling-texml-llms-full-txt.md · Root index: https://developers.telnyx.com/llms.txt

Guides

TeXML Fundamentals

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-fundamentals.md

Overview

TeXML is an XML-based markup language to define call control and processing instructions. When properly configured, Telnyx will fetch TeXML instructions from the user’s application and process the calls accordingly. See Verbs & Nouns.

TeXML Application

An instance of TeXML Application is a collection of configuration parameters that defines the interaction between Telnyx and the user’s application: A TeXML Application can be created through the Telnyx Mission Control Portal or via the Telnyx API.

Instruction Fetching

See Instruction Fetching.

Twilio Compatibility

See Twilio Compatibility.

Instruction Fetching

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-instruction-fetching.md
On inbound calls (PSTN or External SIP to Telnyx), Telnyx fetches TeXML instructions from the URL defined on the TeXML Application associated with the SIP subdomain or phone number. On outbound calls (Telnyx to PSTN or External SIP), there are two ways the user can trigger instructions fetching, the details of which are described below.

Instruction Fetching on Inbound Calls

An instance of TeXML application can have a specific SIP subdomain or phone number assigned to it. When Telnyx receives a call to that SIP subdomain or phone number, Telnyx will fetch the instructions from the URL defined on the TeXML Application.

Instruction Fetching on Outbound Calls

Using TeXML Application

Instructions fetching can be triggered by TeXML Calls API. In this case, a TeXML application is required. Example:

Using SIP Trunking Connections

The user can configure a SIP trunking connection of any type to “Park Outbound Calls”. When the user initiates an outbound call on that SIP connection, Telnyx will “park” that call leg, fetch the instructions from the URL defined on the connection, and then process the call based on the instructions. In this use case, a TeXML application is not required.

HTTP Request Details

When a call is being handled by a TeXML application, Telnyx makes HTTP requests to fetch instructions from the user’s application. These requests include specific parameters that provide context about the call, allowing the user’s application to generate appropriate TeXML responses.
  • Method: Configurable (GET or POST, default is GET)
  • URL: The URL configured for the user’s TeXML application
  • Failover URL: Used if the primary URL is unavailable (optional)

Request Parameters

When Telnyx makes a request to fetch TeXML instructions, the following parameters are always included:

Optional Parameters

Depending on the call context, additional parameters are added to the request. Full list of the parameters can be found on the documentation page for each of the TeXML verbs

Parameter Format

Depending on the HTTP method selected for the requests, the parameters are added in the following way:
  • GET requests - as URL query parameters
  • POST requests - in the request body as form-encoded data

Response Requirements

The user’s application should respond with valid TeXML. The response should:
  • Be valid XML with a root <Response> element
  • Not exceed size limits
  • Return HTTP status code 200 OK

Example

Request (GET method)

Response

Best Practices

Here are a few best practices to follow:
  • Always verify the CallSid parameter to ensure the request is legitimate
  • Include error handling in your application to handle unexpected parameters
  • Keep response times low to avoid call delays
  • Use the parameters to customize call flows based on caller information
  • Test your application with various parameter combinations
  • By properly handling these parameters, you can create dynamic, responsive TeXML applications that provide excellent caller experiences

TeXML Interpreter

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-interpreter.md

Basic Syntax

A proper TeXML response comprises the following elements:
  • <Response> element — tag defining the body of the TeXML document
  • verb — an XML tag denoting the desired action
  • noun — an XML tag denoting the object of the desired action
Here is a simple TeXML file containing an example of a verb and noun used together:

Dynamic parameters

When creating a TeXML set of instructions you can make use of Mustache Templates to generate instructions dynamically at runtime.

Inserting dynamic content

You can make use of Mustache Dynamic templating to insert content into your TeXML instructions through HTTP request parameters in the webhook URL we use to fetch your TeXML set of instructions. For example, you could create a TeXML set of instructions that calls a number that is set until the HTTP request is made to fetch your TeXML instructions. You first create your TeXML instructions using Mustache Templating and set the {{PhoneNumber}} as a variable like this
The phone number can now be replaced at runtime by setting your TeXML webhook URL to have PhoneNumber as a parameter.
The request parameters set by Telnyx, i.e. CallSid, From, and To are also available for the Mustache Template. The list of the parameters for each of the callbacks can be found on our developer documentation page.

Iterate through lists

You can set arrays as parameters in your TeXML webhook URL and let Mustache Template handle them. If for example, you want the dial command to have two numbers, you could add a Numbers list parameter to your callback Url.
Then you can handle the PhoneNumbers parameter in the TeXML instructions using the following syntax.
This will end up being parsed as

Render conditional content

Conditional content is supported by using if/else statements in the TeXML instructions. You could define a set of instructions to dial a specific number depending on From parameter present in the HTTP request.
Supported operators are ==, != and no operator for checking if the parameter value is not null.

TeXML TwiML Compatibility

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-twiml-compatibility.md
TeXML services was created to allow the easy migration from Twilio to Telnyx, allowing you to use the same verbs and nouns in both platforms. This page provides a comparison of verb support between TeXML and TwiML, helping you understand which features are available in each platform.

Verb Compatibility

For detailed information about particular TeXML verb click the link under the name of the verb in the table.

Noun Compatibility

More information about the nouns can be found on <Dial> documentation page

REST API Endpoint Compatibility

The following table outlines the compatibility between Twilio’s REST API endpoints and Telnyx’s TeXML API endpoints. For detailed information about TeXML REST API endpoints and their usage, please use the links to the documentation from the table.

Dynamic TeXML Bins

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-bin-dynamic.md
In this guide, we’ll cover how to create dynamic parameters in TeXML Bin using Mustache Templates. You can get started with TeXML Bin in the Mission Control Portal by following the first steps in our previous guide.

Dynamic parameters for TeXML

Mustache is a logic-less web template system used mainly for mobile and web applications. And a great way to generate instructions dynamically at runtime when creating a TeXML set of instructions. By using Mustache Dynamic templating you can insert content into your TeXML instructions through HTTP request parameters in the webhook URL that is used to fetch your TeXML set of instructions. For example, you could create a TeXML set of instructions that calls a phone number which is set until the HTTP request is made to fetch your TeXML instructions. To do this you’ll first need create your TeXML instructions using Mustache Templating, and set the {{PhoneNumber}} as a variable like this:
After pasting the above content, kindly check and remove any new lines added The phone number can now be replaced at runtime by setting your TeXML webhook url to have PhoneNumber as a parameter like so: Don’t forget to update YOUR_API_KEY here.
The request parameters set by Telnyx - for example, CallSid, From and To - are also available for the Mustache Template. The list of parameters for each of the callbacks can be found on our TeXML Instruction Fetching page.

Iterating through lists

TeXML Bin allows users to set arrays as parameters in the TeXML webhook url and let Mustache Template handle them. For example, if you want the dial command to have two numbers, you could add a Numbers list parameter to your callback Url.
Then you can handle the PhoneNumbers parameter in the TeXML instructions using the following syntax:
This will end up being parsed as:

How to render conditional content

Conditional content is supported by using if/else statements in the TeXML instructions. You could define a set of instructions to dial an specific number depending on From parameter present in the HTTP request.
Note that supported operators are ==, != and there is no operator for checking if the parameter value is not null.

Sending HTTP Requests

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-sending-http-requests.md
In the previous tutorial, we explained how to use dynamic parameters in the TeXML instructions. In this tutorial, we’ll cover how to integrate your systems using HTTP requests from a TeXML file without needing your own server-side application, as well as retrieve required information for call flows from external systems and send notifications to any REST API.

Sending HTTP request

The requests can be sent using <HTTPRequest> verb in the following way:
As part of the verb structure you can define the following aspects of the request:
  • Headers
  • The method for the request (GET or POST)
  • And the body

Synchronous requests

The requests are sent asynchronously by default. The TeXML process does not wait for the result of the request and immediately executes the next instruction from the TeXML file. It is possible to change that behavior by using the async attribute and setting it to true. In that case, the TeXML process will wait for the HTTP response and send a callback to the action URL immediately afterward.
You can define new variables that will be sent with the callbacks using the values from the HTTP response.

Using secrets

API keys or any other secrets can be stored in the secure storage. You can upload them using a dedicated REST endpoint.
Stored secrets can be used in the TeXML definitions. They will be redacted from all logs and won’t be sent in the callbacks as well.

Sending notifications about the call to your Slack workspace using information about the caller retrieved from Salesforce database

In this section we will present how to retrieve the information about the caller from the Salesforce database and send it as a message to the Slack channel.
  1. Upload an api_key to your Slack workspace under the name slack_api_key
  1. Upload a token to the Salesforce API under the name salesforce_token
  1. Create a TeXML file that will send a message to the Slack channel and make a call to your SIP account and name it slack_http_request
  1. Create a TeXML file that will retrieve the information about the caller and their name from Salesforce.
  1. Update your TeXML application webhook URL (If you need to create your application, please take a look at this tutorial)
TeXML application setup
  1. Make a call to the number associated with the TeXML application and observe the notification in your Slack workspace

TeXML Answering Machine

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-answering-machine.md
TeXML is an XML-based data structure you can use to control calls with Telnyx and is the quickest way to get started with Programmable Voice using a simple .xml file, allowing you to specify call instructions in your file using commands called verbs and nouns.

Initiating a TeXML outbound call using REST endpoint with AMD enabled

There are 2 possible options for using Answering Machine Detection for outbound calls:
  1. Synchronous mode: In this case, the TeXML instructions are not executed until the results of AMD process are provided in the status callback. The new instructions can be sent back as response to be processed by the TeXML engine.
  2. Asynchronous mode: Here, the TeXML instructions are processed in parallel to the AMD process. The results of the AMD analysis are being provided in the AsyncAmdStatusCallback callback.

Synchronous mode request

The outbound TeXML call with AMD support enable in the synchronous mode can be requested in the following way: Don’t forget to update YOUR_API_KEY here.
The results of the analysis will be sent as a value of the AnsweredBy parameter of the StatusCallback request.

AnsweredBy parameter values

The values returned depend on the MachineDetection mode used: When MachineDetection is Enable (detects as soon as the answering machine is identified): When MachineDetection is DetectMessageEnd (waits for the answering machine greeting to finish): The MachineDetection parameter accepts the following values: Enable, Disable (default), and DetectMessageEnd. The DetectionMode parameter accepts Regular (default) or Premium.

Asynchronous mode request

Similarly, the asynchronous AMD processing can be requested for outgoing TeXML calls:
The results of the AMD analysis will be sent as callback requests to the address provided as AsyncAmdStatusCallback parameter. Note that this can be used for basic and premium AMD.

AsyncAmdStatusCallback parameters

The callback to your AsyncAmdStatusCallback URL includes the following parameters:

Markup Language

Dial

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-verbs/dial.md
The <Dial> verb transfers an existing call to another destination. <Dial> will end this new call if: the called party does not answer, the number does not exist, or Telnyx receives a busy signal.

Attributes

ATTRIBUTE DESCRIPTION OPTIONS DEFAULT action Optional URL where TeXML will make a request when the <Dial> call ends to retrieve a new set of TeXML instructions to continue the call flow.
method HTTP method to use when requesting the action URL. GET, POST POST callerId Caller ID that must be a valid E.164 format number.
fromDisplayName The fromDisplayName string to be used as the caller id name (SIP From Display Name) presented to the destination. The string should have a maximum of 128 characters, containing only letters, numbers, spaces, and -_~!.+ special characters. If omitted, the display name will be the same as the number in the callerId field.
hangupOnStar The hangupOnStar attribute lets the initial caller hang up on the called party by pressing the ’*’ key on their phone. Does not apply for the Conference noun. false timeout The number of seconds to wait for the called party to answer the call. 5 - 120 30 timeLimit The maximum duration of the call in seconds. 60 - 14400 14400 record The record attribute lets you record both legs of a call within the associated <Dial> verb. It works with the <Number> and <Sip> nouns only. If you want to record the conference, please use the record attribute on <Conference> noun. Recordings are available in two options: single or dual. do-not-record, record-from-answer, record-from-ringing, record-from-answer-dual, record-from-ringing-dual do-not-record recordingChannels The number of channels in the final recording. Possible values are: single (for mono) and dual (for stereo). Defaults to single. single, dual single recordMaxLength Defines the maximum length for the recording in seconds (0 for infinite) 0 - 14400 0 recordingStatusCallback Optional URL that tells Telnyx where to make its GET or POST request when the recording is available.
recordingStatusCallbackMethod HTTP request type used for recordingStatusCallback. GET, POST POST recordingStatusCallbackEvent The recording events for which Telnyx should send a webhook. Multiple events are separated by a space. in-progress, completed, absent completed sendRecordingUrl Defines if the recording URL is sent in the callbacks. true ringTone The ringback tone played back to the caller. at, au, bg, br, be, ch, cl, cn, cz, de, dk, ee, es, fi, fr, gr, hu, il, in, it, lt, jp, mx, my, nl, no, nz, ph, pl, pt, ru, se, sg, th, tw, ve, za, us, us-old, uk us audioUrl A URL to an audio file that will be played as a custom ringback tone to the caller while waiting for the call to be answered. When set, overrides the ringTone attribute.
answerOnBridge If set to true, the inbound call will not be answered until the dialed call is answered. This preserves the ringing state on the caller’s side. Only takes effect when the inbound call has not yet been answered. false sequential When set to true with multiple <Number> or <Sip> nouns, Telnyx dials each destination one at a time in the order listed. The next destination is attempted only if the current attempt completes without being answered. If omitted or set to false, all destinations are dialed at the same time and the first answered call is connected. false passDiversionHeader When set to true, the Diversion SIP header from the inbound call is passed through to the outbound dial attempt. false machineDetectionSpeechThreshold Maximum duration of a greeting in milliseconds. If a greeting is longer than this value, the call is classified as a machine. Only used when machineDetection is enabled and detectionMode is Premium.
machineDetectionSpeechEndThreshold Silence duration in milliseconds after a greeting to wait before classifying the call as a machine. Only used when machineDetection is enabled and detectionMode is Premium.
machineDetectionSilenceTimeout Maximum duration of initial silence in milliseconds before the call is classified as a silence. Only used when machineDetection is enabled and detectionMode is Premium.

Child verbs/nouns

NOUN/VERB DESCRIPTION Number Specifies a phone number to dial. Sip The <Sip> noun specifies a SIP endpoint to dial. Queue The <Queue> noun allows you to add a call to a queue.

Number Attributes

ATTRIBUTE DESCRIPTION OPTIONS DEFAULT statusCallback A URL for Telnyx to send webhook requests to on each event specified in the statusCallbackEvent attribute for outbound calls only. Inbound Status Callback events can be configured for TeXML the connection settings in the Mission Control Portal.
statusCallbackEvent The call events for which Telnyx should send a webhook. Multiple events are separated by a space. initiated, ringing, answered, amd, dtmf, completed completed statusCallbackMethod HTTP request type Telnyx should use when requesting the statusCallback URL. GET, POST POST url Optional URL to another TeXML document that can contain <Gather> and <Hangup> verbs so that the called party can chose to take an action on the incoming call before the two parties are connected. The callee will continue to hear ringback while the url document is executed.
method HTTP request type used for url. GET, POST POST sendDigits Specifies DTMF tones to play when the call is answered. The value can include: digits 0-9, #, *, and w. ‘w’ indicates a 0.5 second pause.

machineDetection Enables Answering Machine Detection. Note: add amd event type to statusCallbackEvent list to receive the detection result webhook. Enable, DetectMessageEnd, Disable Disable detectionMode Sets the Answering Machine Detection mode. Use PremiumCallScreening for premium iOS call screening detection. See https://developers.telnyx.com/docs/voice/programmable-voice/answering-machine-detection Regular, Premium, PremiumCallScreening Regular machineDetectionTimeout Maximum timeout threshold for overall detection, in milliseconds. 500 - 60000 3500 machineDetectionPromptEndTimeout Silence duration threshold after a call screening prompt before ending prompt detection, in milliseconds. Only used when machineDetection is enabled and detectionMode is PremiumCallScreening. 1000 - 120000

sipRegion The geographic region of the SIP infrastructure Telnyx should use when dialing the destination. US, Europe, Canada, Australia, Middle East US

Sip Attributes

ATTRIBUTE DESCRIPTION OPTIONS DEFAULT username Username to use for SIP authentication.
password Password to use for SIP authentication.
statusCallback A URL for Telnyx to send webhook requests to on each event specified in the statusCallbackEvent attribute for outbound calls only. Inbound Status Callback events can be configured for TeXML the connection settings in the Mission Control Portal.
statusCallbackEvent The call events for which Telnyx should send a webhook. Multiple events are separated by a space. initiated, ringing, answered, amd, dtmf, completed completed statusCallbackMethod HTTP request type Telnyx should use when requesting the statusCallback URL. GET, POST POST url Optional URL to another TeXML document that can contain <Gather> and <Hangup> verbs so that the called party can chose to take an action on the incoming call before the two parties are connected. The callee will continue to hear ringback while the url document is executed.

method HTTP request type used for url. GET, POST POST machineDetection Enables Answering Machine Detection. Note: add amd event type to statusCallbackEvent list to receive the detection result webhook. Enable, DetectMessageEnd, Disable Disable detectionMode Sets the Answering Machine Detection mode. Use PremiumCallScreening for premium iOS call screening detection. See https://developers.telnyx.com/docs/voice/programmable-voice/answering-machine-detection Regular, Premium, PremiumCallScreening Regular machineDetectionTimeout Maximum timeout threshold for overall detection, in milliseconds. 500 - 60000 3500 machineDetectionPromptEndTimeout Silence duration threshold after a call screening prompt before ending prompt detection, in milliseconds. Only used when machineDetection is enabled and detectionMode is PremiumCallScreening. 1000 - 120000

sipRegion The geographic region of the SIP infrastructure Telnyx should use when dialing the destination. US, Europe, Canada, Australia, Middle East US

Queue Attributes

ATTRIBUTE DESCRIPTION OPTIONS DEFAULT url Optional URL to another TeXML document that can contain <Play>, <Say>, <Gather>, <Pause> and <Redirect> verbs. The document will be executed on the queued call before bridging the calls.
method HTTP request type used for url. GET, POST POST

Simultaneous dialing

You can use multiple <Number> and <Sip> nouns within a <Dial> verb to dial multiple phone numbers and SIP addresses at the same time. The first person to answer the call will be connected to the caller, while the rest of the call attempts are hung up:

Sequential dialing

Set sequential="true" to dial multiple <Number> and <Sip> nouns one at a time in the order listed. Telnyx attempts the next destination only if the current attempt completes without being answered. If a destination answers, it is connected to the caller and the remaining destinations are not dialed.

Examples

Expected callbacks

If action is set, a callback is sent when the dialed call ends. See Dial Action Callback for the full payload reference. The error_code and error_message fields are provided only in case of failed calls. The full list of errors can be found under the API Errors page. If statusCallbackEvent is set, the following webhooks are sent based on configured events: If machineDetection is enabled, an AMD callback is sent to amdStatusCallback. See AMD Callback for the full payload reference. If deepfakeDetection is set to Enable, a deepfake detection callback is sent to deepfakeDetectionCallbackUrl (or to statusCallback if "deepfake" is included in statusCallbackEvent). The callback payload includes DeepfakeResult (real, fake, or silence_timeout), DeepfakeScore (0.0–1.0), and DeepfakeConsistency (0–100). On detection failure, a DeepfakeError field is sent instead. If recordingStatusCallbackEvent is set, the following webhooks are sent:

Say

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-verbs/say.md
The <Say> verb speaks the text specified back to the caller, enabling text-to-speech for any application.

Attributes

ATTRIBUTE DESCRIPTION OPTIONS DEFAULT voice Optional text-to-speech voice type. For basic text-to-speech use man or woman (en-US only). For premium text-to-speech use alice or one of the following provider-prefixed formats: Polly.VoiceId / Polly.VoiceId-Neural for Amazon Polly, AWS.Polly.VoiceId for direct AWS Polly notation, Azure.VoiceId for Azure TTS (supports gender and effect attributes), ElevenLabs.ModelId.VoiceId for ElevenLabs (requires api_key_ref), Telnyx.ModelId.VoiceId for Telnyx native TTS, Resemble.ModelId.VoiceId for Resemble AI, Minimax.ModelId.VoiceId for Minimax, Rime.ModelId.VoiceId for Rime, Inworld.ModelId.VoiceId for Inworld, and FishAudio.ModelId.VoiceId for Fish Audio (ModelId is one of s2.1-pro, s2-pro, or s1). man, woman, alice, Polly.VoiceId, Polly.VoiceId-Neural, AWS.Polly.VoiceId, Azure.VoiceId, ElevenLabs.ModelId.VoiceId, Telnyx.ModelId.VoiceId, Resemble.ModelId.VoiceId, Minimax.ModelId.VoiceId, Rime.ModelId.VoiceId, Inworld.ModelId.VoiceId, FishAudio.ModelId.VoiceId man language ISO language type to be used if voice type alice is selected. If man or woman is selected, the language accent will always be en-US. This parameter is ignored when a specific Amazon Polly voice is used.
loop The number of times to repeat the text. 0 means infinite. 0 - 10 1

gender Specifies the gender of the voice. Only applicable when using Azure voices (Azure.*). Male, Female

effect Applies an audio effect to the spoken text. Only applicable when using Azure voices (Azure.*). eq_telecomhp8k, eq_car

voiceSpeed Speech rate for the voice. Must be a decimal between 0.1 and 2.0. Defaults to 1. 0.1 - 2.0 1 api_key_ref Reference to the API key for authentication with the TTS provider. The key must be stored via the integration secrets API. Used with ElevenLabs and Azure voices.
region Cloud region to use with the TTS provider. Required for Azure voices when using a custom API key.
pronunciationDictId UUID of a pronunciation dictionary to apply to the spoken text.
languageBoost Language hint for Telnyx Qwen3TTS voices. Accepted as full names (Auto, English, German, Chinese, French, Italian, Japanese, Korean, Portuguese, Russian, Spanish) or ISO 639-1 codes (en, de, zh, fr, it, ja, ko, pt, ru, es).

Examples


Play

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-verbs/play.md
The <Play> verb plays an MP3 or WAV audio file, which Telnyx fetches back to the caller from the URL you configure. Alternatively, specify mediaStorage="true" to fetch a file you previously uploaded to Telnyx using media storage APIs. When mediaStorage="true" is used the verb expects a media_name instead of a URL. You can also use the digits attribute to play DTMF tones instead of an audio file. The ringTone attribute generates a country-specific ringback tone instead of fetching an audio file; it cannot be combined with an audio body and is not supported inside <Conference>. By default, a playback failure (e.g. the audio URL returns 404) aborts the TeXML script. Set continueOnError="true" to log the failure and proceed with the next verb instead. Set failoverUrl to retry once with a backup audio source before the failure path is taken; continueOnError still applies if the failover also fails. <Play> can be used independently as a verb or nested within <Gather> as a noun to play an audio file while waiting for DTMF tones.

Attributes

ATTRIBUTE DESCRIPTION OPTIONS DEFAULT loop Times to repeat the audio. When used with ringTone, forwarded to FreeSWITCH as the tone_stream loops parameter; loop="0" plays the tone indefinitely until interrupted by a subsequent verb or hangup. 1 mediaStorage When true fetches the file from Telnyx media storage using the provided media name. true, false false digits DTMF tones to play. The value can include digits 0-9, *, #, and w (for a 0.5 second pause). When specified, the verb plays DTMF tones instead of an audio file.
failoverUrl Backup audio source played when the primary URL fails. The mediaStorage flag also applies to this URL. Only one retry attempt is made.
continueOnError When true, a playback failure does not abort the script. Telnyx still logs the error and continues with the next verb. true, false false

ringTone Plays a country-specific ringback tone instead of an audio file. Cannot be combined with an audio body. Not supported inside <Conference>. at, au, bg, br, be, ch, cl, cn, cz, de, dk, ee, es, fi, fr, gr, hu, il, in, it, lt, jp, mx, my, nl, no, nz, ph, pl, pt, ru, se, sg, th, tw, ve, za, us, us-old, uk

Examples


Gather

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-verbs/gather.md
The <Gather> verb collects DTMF tones during a call. <Say> can be nested within <Gather> to create an interactive IVR with text-to-speech.

Attributes

ATTRIBUTE DESCRIPTION OPTIONS DEFAULT action URL where TeXML will send the gathered result and message history. Same method (GET/POST) as set for the TexML application is used. Transfers control of the current call to the TeXML file returned.
timeout Time in seconds between digits before the <Gather> digits are sent to your action URL. Telnyx will wait until all nested verbs have been executed before beginning the timeout period. 1 - 120 5 input The input type for the gather action. dtmf, speech, dtmf speech dtmf speechTimeout Time in seconds to wait after speech ends before timing out.
partialResultCallback URL for sending partial gather results.
partialResultCallbackMethod HTTP request type used for partialResultCallback. GET, POST POST profanityFilter Whether to filter profanity from speech recognition results (camelCase format).
useEnhanced Enables enhanced transcription, this works for models phone_call and video (camelCase format).
hints Hints to improve transcription accuracy. On Deepgram, this maps to the Nova-2 keyword biasing feature and is supported only on model="deepgram/nova-2"; it is silently dropped on Nova-3 (use keyterms instead). Accepts a comma-separated string.
keyterms Deepgram Nova-3 keyterm prompting. Biases recognition toward domain-specific terms or brand names. Supported only on model="deepgram/nova-3"; silently dropped on Nova-2 (use hints instead). Accepts a comma-separated string.
smartFormat Disable Deepgram’s smart formatting so the transcript stays lowercase with no punctuation. Deepgram-only; silently dropped on other engines. true

transcriptionEngine Engine to use for speech recognition: Google, Telnyx, Azure, Deepgram, xAI, AssemblyAI, Soniox, Speechmatics, Parakeet, Humain, Reson8, Cohere Google, Telnyx, Azure, Deepgram, xAI, AssemblyAI, Soniox, Speechmatics, Parakeet, Humain, Reson8, Cohere

model Speech recognition model. Format is vendor/model-name — e.g. deepgram/nova-2, deepgram/nova-3, azure/fast, assemblyai/universal-streaming, soniox/stt-rt-v4, speechmatics/standard, nvidia/parakeet-v3, xai/grok-stt, humain/realtime, reson8/turns, cohere/ar-stt. The vendor must match transcriptionEngine. On Deepgram, defaults to deepgram/nova-3 when unset.
apiKeyRef Reference to the API key for authentication. See integration secrets documentation for details. The parameter is optional as defaults are available for some regions. Used with Azure transcriptionEngine.
region Region to use with the specified transcription engine. Required for Azure. See regions in transcription_engine_config.
finishOnKey The set of digits, (0-9, *, #), that indicates the end of the gather.

numDigits The number of digits to be gathered.
language The language used. See RESTful API documentation for supported values. By default en-US. en-US validDigits The set of valid digits for the gather action.
invalidDigitsAction URL where TeXML will send the invalid gathered digits. The same method (GET/POST) as set for the TeXML application is used. Transfers control of the current call to the TeXML file returned.
minDigits Minimum number of digits to be gathered. 1 - 128 1 maxDigits Maximum number of digits to be gathered. 1 - 128 128

Child verbs/nouns

NOUN/VERB DESCRIPTION Say Play

Examples

Expected callbacks

If action is set, a callback is sent when gather completes with the collected digits or speech. See Gather Callback for the full payload reference.

AIGather

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-verbs/aigather.md
The <AIGather> verb collects specific information from call participants leveraging AI. It requires the child node <Parameters> to be provided with a JSON Schema object that describes the parameters to be gathered.

Attributes

ATTRIBUTE DESCRIPTION OPTIONS DEFAULT action URL where TeXML will send the gathered speech input. The same method (GET/POST) as set for the TeXML application is used. Transfers control of the current call to the TeXML file returned.
method HTTP request type used to retrieve the next set of instructions. GET, POST POST

Child verbs/nouns

NOUN/VERB DESCRIPTION Greeting Reads supplied text back to the caller when the gathering starts, if none then nothing will be played when the gathering starts. Voice The voice to be used by the voice assistant. Parameters The parameters are described as a JSON Schema object that needs to be gathered by the voice assistant. It needs to be provided within CDATA tags (see the example below). MessageHistory The message history you want the voice assistant to be aware of, this can be useful to keep the context of the conversation, or to pass additional information to the voice assistant. They can be provided as a list of <Message> nodes. Each <Message> node must contain a role attribute that can be either user or assistant. The role attribute is used to determine if the message is from the user or the assistant. The text of the message is provided in the <Message> node (see the example below). Tools The list of <Tools> to be used by the AI assistant. The <Tool> should contain at tool definition in json format. All of the available tools are defined in the Voice API Gather using AI documentation.

Voice Attributes

ATTRIBUTE DESCRIPTION OPTIONS DEFAULT name The voice to be used by the voice assistant. Currently, we support ElevenLabs, Telnyx and AWS voices only, for ElevenLabs voices you can pass the voice as ElevenLabs.model_id.voice_id, for Telnyx voices you can pass the voice as Telnyx.model_id.voice_id, for AWS Polly voices you can pass the voice as AWS.Polly.voice_id, we also support this notation for AWS Polly voices: Polly.voice_id Telnyx.NaturalHD.Astra api_key_ref The reference to the ElevenLabs API key to be used for the voice assistant. The API key must be added to the account text-to-speech secrets /v2/text-to-speech/secret. Note: this is only used when using an ElevenLabs voice.
voice_speed The voice speed to be used for the voice. The voice speed must be between 0.1 and 2.0. Note: this is only used when using a Telnyx voice 0.1 - 2.0 1

Examples

Expected callbacks

If action is set, a callback is sent when the AI gather completes with the collected result and message history. See AI Gather Callback for the full payload reference.

AIAssistant

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-verbs/aiassistant.md
The <AIAssistant> verb allows you to start a voice assistant on the call.

Attributes

ATTRIBUTE DESCRIPTION OPTIONS DEFAULT id The identifier of the AI assistant. The AI assistant can be created using the AI Assistant API.
join The ID of an existing AI assistant conversation to join. When set, the call leg is added as a participant to the specified conversation instead of starting a new one. Use participantName and participantRole to configure the joining participant.
participantName The display name of the participant joining the conversation. Only used when join is set.
participantRole The role of the participant joining the conversation. Only used when join is set. user, assistant user

Examples

When the action attribute is set on <Connect>, TeXML makes a request to that URL when the assistant conversation ends and executes the TeXML instructions returned in the response. The request payload includes a Reason field describing why the conversation ended (for example service_error), so the action endpoint can branch on it — such as returning a <Dial> to a human agent on error:

Record

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-verbs/record.md
The <Record> verb creates an audio file with the call audio. If a recordingStatusCallback, Telnyx will deliver the URL for the recording to that address once the call has ended. Recording URLs are valid for 10 minutes after the call has ended. All recordings are also available via the Telnyx Mission Control Portal Note In addition to recording, the <Record> verb supports automatic transcription by setting transcription="true" and providing a transcriptionCallback URL. The transcription result will be sent via webhook.

Attributes

ATTRIBUTE DESCRIPTION OPTIONS DEFAULT action Optional URL where TeXML will make a request when the <Record> ends to retrieve a new set of TeXML instructions to continue the call flow sent with additional request parameters.
method HTTP request type used to retrieve the next set of instructions. GET, POST POST finishOnKey Set of digits specified together, any one of which will end the recording. Supported characters values: Any digit, #, *. 1234567890*# timeout The number of seconds that Telnyx will wait for the recording to be stopped if silence is detected. The timer only starts when the speech is detected. Please note that the transcription is used to detect silence and the related charge will be applied. 0 for infinite. 0 maxLength Defines the maximum length for the recording in seconds. 0 for infinite. 0 - 14400 3600 playBeep Whether or not a sound is played before the start of a recording. true

trim Will remove silence from the beginning and end of the recording when set to trim-silence. trim-silence

channels When using dual channels, the final audio file will be stereo recorded with the first leg on channel A, and the rest on channel B. single, dual dual recordingStatusCallback Optional URL that tells Telnyx where to make its GET or POST request when the recording is available.
recordingStatusCallbackMethod HTTP request type used for recordingStatusCallback. GET, POST POST transcription Enables automatic transcription of the recorded audio. When set to ‘true’, a transcription will be generated and delivered to the transcriptionCallback URL. true, false false transcriptionCallback The URL where Telnyx will send the transcription result once available.
transcriptionEngine Specifies the engine to use for transcription. A uses Google (default) and B uses Telnyx. Set to Deepgram to transcribe the recording with Deepgram, optionally pairing it with transcriptionModel to choose a specific Deepgram model. A, B, Deepgram, deepgram A transcriptionModel Optional model to use with the specified transcriptionEngine. Format is vendor/model-name — e.g. deepgram/nova-2 or deepgram/nova-3. The vendor must match transcriptionEngine. If not specified, the engine’s default model will be used. On Deepgram, defaults to deepgram/nova-3. See transcription models in transcription_engine_config.
transcriptionLanguage Language to use for transcription when transcription is enabled. Use a BCP-47 language tag such as en-US. The set of supported languages depends on the transcriptionEngine and transcriptionModel — see languages in transcription_engine_config. en-US format The format of the recording file. mp3, wav mp3 recordingStatusCallbackEvent The recording events for which Telnyx should send a webhook to the recordingStatusCallback URL. Multiple events are separated by a space. in-progress, completed completed

Examples

Example 1
Example 2
Example 3 Transcribe the recording with Deepgram and select a specific model:

Expected callbacks

If action or statusCallback is set, recording status callbacks are sent: If transcribe is enabled, a transcription callback is sent to transcribeCallback: See Transcription Callback for the full payload reference.

Conference

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-verbs/conference.md
The <Dial> verb’s <Conference> noun allows you to connect to a conference room. Much like how the <Number> noun allows you to connect to another phone number, the <Conference> noun allows you to connect to a named conference room and talk with the other callers who have also connected to that room. Conference is commonly used as a container for calls when implementing hold, transfer, and barge. If the specified conference name does not exist, a new conference will be created.

Attributes

ATTRIBUTE DESCRIPTION OPTIONS DEFAULT muted Specify whether a participant is muted or not. false startConferenceOnEnter Start the conference when a participant joins. If this is false and the participant joins a conference that has not started, they are muted and hear background music until a participant joins where startConferenceOnEnter is true. This is useful for implementing moderated conferences. true endConferenceOnExit If a participant has this attribute set to true, then when that participant leaves, the conference ends and all other participants drop out. This is useful for implementing moderated conferences that bridge two calls and allow either call leg to continue executing TexML if the other hangs up. false maxParticipants The maximum number of participants allowed in the conference. 2 - 250 250 beep Specify whether a notification beep is played to the conference when a participant joins or leaves the conference. The participant joining the conference will never hear a beep. Note: this attribute does not affect the recording start beep. To disable the beep played when recording starts, set the recordBeep attribute to false. true, false, onEnter, onExit true participantLabel A unique label for the participant which will be added into the conference as a result of executing the TeXML instruction. The label can be used to read or update participant attributes using the TeXML REST API.
record The record attribute lets you record entire conference. When set to record-from-start, recording begins immediately after the conference starts do-not-record, record-from-start do-not-record recordBeep If enabled, a beep sound will be played at the start of a recording. This is independent of the beep attribute, which only controls join/leave notification sounds. Set to false to disable the recording start beep. true recordingStatusCallback Optional URL that tells Telnyx where to make its GET or POST request when the recording is available.
recordingStatusCallbackEvent The recording events for which Telnyx should send a webhook. Multiple events are separated by a space. in-progress, completed, absent completed recordingStatusCallbackMethod HTTP request type used for recordingStatusCallback. GET, POST POST recordingTimeout The number of seconds that Telnyx will wait for the recording to be stopped if silence is detected. The timer only starts when the speech is detected. Please note that the transcription is used to detect silence and the related charge will be applied. 0 means no timeout. 0 - 14400 0 trim Whether to trim any leading and trailing silence from the recording. trim-silence, do-not-trim do-not-trim sendRecordingUrl Defines if the recording URL is sent in the callbacks. true statusCallback A URL for Telnyx to send webhook requests to on each event specified in the statusCallbackEvent attribute.
statusCallbackMethod HTTP method to use when requesting the status callback URL. GET, POST POST

statusCallbackEvent The conference events for which Telnyx should send a webhook on. Multiple events are separated by a space. start, end, join, leave, speaker

waitUrl A URL to an MP3 or WAV file that should be used for the conference’s hold music before the conference starts. The URL can also return an XML document with instructions that will be executed while the call is waiting for the conference to start.
waitMethod HTTP method to use when requesting the wait URL. GET, POST POST

Examples

Expected callbacks

If statusCallbackEvent is set, the following webhooks are sent based on configured events:

Enqueue

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-verbs/enqueue.md
The <Enqueue> verb enqueues the current call in a call queue.

Attributes

ATTRIBUTE DESCRIPTION OPTIONS DEFAULT action Defines an absolute or relative URL used to send a request when the call leaves the queue. It will be sent right away when the call is dequeued using <Leave> verb. When a call is dequeued using <Dial> verb, the request will be sent once the bridged calls disconnect.
method HTTP request type used for action. GET, POST POST waitUrl Specifies the URL to the TeXML document that will be executed when the call is waiting in the queue. Once all the commands from the flow are executed, the waitUrl is re-requested, and the TeXML document is run once again. Verbs that are supported in the waitUrl TeXML document: <Play>, <Say>, <Gather>, <Pause>, <Hangup>, <Redirect>, <Leave>.
waitUrlMethod HTTP request type used for waitUrl. GET, POST POST maxWaitTimeSecs Maximum time in seconds a call can stay in the queue. If the call is not dequeued within this time, it will be removed from the queue and the action URL will be called. Must be at least 1 second. 14400

Examples

Expected callbacks

If waitUrl is set, a callback is sent when the call enters the queue. See Queue Callback for the full payload reference.

Hangup

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-verbs/hangup.md
Ends the call

Examples

Expected callbacks

When the call ends, a callback is sent to the webhook URL defined on the connection level with CallStatus set to completed. See Call Completed Callback for the full payload reference.

Pause

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-verbs/pause.md
The <Pause> verb waits silently for a specified number of seconds or one second by default. No nouns can be nested within <Pause>, and a self-closing tag must be used.

Attributes

ATTRIBUTE DESCRIPTION OPTIONS DEFAULT length Seconds to pause 1 - 180 1

Examples


Pay

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-verbs/pay.md
The <Pay> verb collects payment information from a caller using DTMF and either charges or tokenizes the payment method through a configured Pay connector. Connectors may run in test or live mode. Test-mode connectors accept only the documented test card numbers.

Attributes

ATTRIBUTE DESCRIPTION OPTIONS DEFAULT action Optional URL where TeXML requests the next set of instructions after <Pay> completes. The request includes normalized PayResult, the raw Result, and available payment result fields.
method HTTP request type used for the action URL. GET, POST POST statusCallback Optional URL where Telnyx will send status callbacks for payment progress and completion events.
statusCallbackMethod HTTP request type used for statusCallback. GET, POST POST paymentConnector The name of the payment connector to use. The connector must be configured in the Telnyx API. Defaults to Default. Default chargeAmount The amount to charge (e.g. 10.50). Required when transactionType is charge. Ignored for tokenize transactions.
currency The currency for the charge. Pay currently supports USD. USD USD paymentToken An existing payment token to use for the transaction. If provided, the payment data collection steps are skipped.
paymentMethod The payment method to collect. credit-card collects card number, expiration date, postal code, and security code. ach-debit collects bank routing and account numbers. credit-card, ach-debit credit-card

transactionType The transaction type. charge processes a payment and returns a ChargeId. tokenize tokenizes the payment data and returns a TokenId. If omitted, Pay infers tokenize when chargeAmount is absent or zero and charge when it is positive. charge, tokenize

description An optional description for the payment transaction.
maxAttempts The maximum number of attempts for each payment collection step before failing. Valid values are 1 through 3. 1 - 3 1 timeout The timeout in seconds for each DTMF input step. Valid values are 1 through 600. 1 - 600 5 interDigitTimeout The timeout in seconds between consecutive DTMF digits during input. Valid values are 1 through 600. 1 - 600 5 voice The voice used for payment prompts (e.g. female, male). female language The language used for payment prompts (e.g. en-US, es-ES). en-US serviceLevel The service level for payment processing. premium premium parameters A JSON string of additional parameters to pass to the payment connector.
prompts A JSON string of custom prompts for payment collection steps. Can also be specified using nested <Prompt> elements.
metadata A JSON string of metadata to attach to the payment transaction.

Child verbs/nouns

NOUN/VERB DESCRIPTION Parameter Optional key-value parameter merged into the Pay parameters map. Use the name and value attributes to specify the key and value. Prompt Custom text-to-speech prompt for a specific payment collection step. Use the for attribute to specify the step and include the prompt text in a nested <Say> element.

Connector modes and test cards

Pay connectors can operate in test or live mode. Before contacting the configured processor, a test-mode connector rejects every card number except those below. A test-mode payment using any other card number fails with ErrorType=invalid-card-number. Live-mode connectors pass the captured payment details to the configured payment processor.

Charge a credit card

Collect credit-card details and charge a specific amount. The paymentConnector must name a Pay connector configured for the account:

Tokenize a credit card

Collect credit-card details and tokenize them without charging:
If transactionType is omitted, Pay infers tokenize when chargeAmount is absent or zero and charge when chargeAmount is positive.

Collect ACH bank-account details

Collect a 9-digit bank routing number and a 4–17 digit bank account number:

Custom prompts

Override a payment step’s text-to-speech prompt with a nested <Prompt> and <Say>:
The supported for values are payment-card-number, expiration-date, postal-code, security-code, bank-routing-number, and bank-account-number. Prompts may be qualified by attempt, errorType, and cardType. Qualifiers are optional and may be combined. attempt accepts a space-separated list of 1-based attempt numbers. Card-type values are lowercase and case-sensitive.
The prompts JSON attribute is an alternative to nested <Prompt> elements. Each step may contain a string or a list of prompt objects:

Additional connector parameters

Pass extra string parameters with nested <Parameter> elements. Child parameters override keys with the same name in the parameters JSON attribute.

Status callbacks

When statusCallback is set, TeXML sends callbacks as payment collection progresses and another callback when the Pay session completes. Parameters are form encoded for POST callbacks and query encoded for GET callbacks. The following call and payment context fields are included when available:

Progress callback

A progress callback always contains Status=processing and Result=pending. It can also contain: Progress callbacks accumulate the masked payment data collected so far. For example, the expiration-date callback can include the card number and card type collected by an earlier step.

Completed callback

The final status callback contains Status=completed and a normalized Result of success or failed. It can also contain:

Masked payment-data fields

Progress and completed callbacks include these fields when the corresponding values have been collected:

Action request

After Pay completes, TeXML requests the action URL using method. If action is omitted, TeXML requests the current document URL instead. The response must contain the next TeXML instructions. The action request has its own payload shape; it is not identical to the completed statusCallback payload. The action request also includes any available masked payment-data fields listed above.

Redirect

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-verbs/redirect.md
The <Redirect> verb transfers control of a call to the TeXML document to another TeXML application. This is useful to create a tree structure of TeXML files for different applications. No nouns can be nested within <Redirect>

Attributes

ATTRIBUTE DESCRIPTION OPTIONS DEFAULT method The type of requested used <Redirect> URL. GET, POST POST

Examples


Reject

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-verbs/reject.md
The <Reject> verb rejects a call to your Telnyx number. It is effectively an exit statement from the current document, as there is no way to return to any instructions listed after the <Reject> verb. If placed as the very first verb in an incoming call, <Reject> will prevent the call from being answered and will incur no cost. If placed elsewhere in the call, the call will hang up but will be charged up to that point.You can’t nest any verbs within <Reject> and you can’t nest <Reject> in any other verbs.

Attributes

ATTRIBUTE DESCRIPTION OPTIONS DEFAULT reason The tone to play to indicate the reason the call was rejected. rejected, busy rejected

Examples


Stream

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-verbs/stream.md
The <Stream> instruction starts streaming the media from a call to a specific WebSocket address in near-real-time. Audio will be delivered as base64-encoded RTP payloads (no headers), wrapped in JSON payloads.

Attributes

ATTRIBUTE DESCRIPTION OPTIONS DEFAULT url The destination WebSocket address where the stream is going to be delivered.
track Specifies which track should be streamed. inbound_track, outbound_track, both_tracks inbound_track name Specifies custom name for the stream instance
codec Specifies the codec to be used for the streamed audio. When set to ‘default’ or when transcoding is not possible, the codec from the call will be used. Currently, transcoding is only supported between PCMU and PCMA codecs. PCMU, PCMA, G722, OPUS, AMR-WB, default default bidirectionalMode Bidirectional streaming mode mp3, rtp mp3 bidirectionalCodec Bidirectional streaming codec, used only with bidirectionalMode=rtp PCMU, PCMA, G722, OPUS, AMR-WB PCMU bidirectionalSamplingRate Bidirectional streaming sampling rate in Hz 8000, 16000, 24000 8000 statusCallback A URL for Telnyx to send webhook requests to on stream status events (e.g. stream started, stopped, or failed).
statusCallbackMethod HTTP request type used for statusCallback. GET, POST POST enableReconnect Whether the platform should automatically attempt to reconnect the WebSocket stream if disconnected. Defaults to true. true

Child verbs/nouns

NOUN/VERB DESCRIPTION Parameter Custom key-value parameter to pass to the WebSocket server. Parameters are included in the start message sent over the WebSocket connection.

Parameter Attributes

ATTRIBUTE DESCRIPTION OPTIONS DEFAULT name The name of the custom parameter.
value The value of the custom parameter.

Examples

Disabling automatic reconnection

By default, enableReconnect is "true", and the platform will automatically attempt to reconnect the WebSocket stream if it is disconnected. Set enableReconnect="false" to disable this behavior, for example when a disconnection should immediately end the stream.

Expected callbacks

If statusCallback is set, stream status callbacks are sent for the following events:
  • stream-started — Stream has started
  • stream-stopped — Stream has stopped
  • stream-failed — Stream failed to start or was interrupted
See Stream Callback for the full payload reference.

ConversationRelay

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-verbs/conversationrelay.md
The <ConversationRelay> verb routes a call to a ConversationRelay service that provides voice interactions over a WebSocket connection. It provides speech-to-text transcription and allows requesting text-to-speech synthesis for the call over WebSocket.

Attributes

ATTRIBUTE DESCRIPTION OPTIONS DEFAULT url The WebSocket URL of the conversation relay server.
welcomeGreeting A greeting message to be spoken when the conversation relay session starts.
voice The TTS voice to use (e.g., Telnyx.Natural.abbie, Telnyx.NaturalHD.astra).
language The language for TTS and transcription (e.g., en, fr, es).
transcriptionProvider The speech-to-text provider (e.g., deepgram).
interruptible Whether TTS playback can be interrupted by the caller. true is an alias for any, false is an alias for none. none, any, speech, dtmf, true, false any welcomeGreetingInterruptible Whether the welcome greeting can be interrupted by the caller. true is an alias for any, false is an alias for none. none, any, speech, dtmf, true, false any dtmfDetection Whether to enable DTMF detection during the conversation relay session. false

backgroundAudioType The type of background audio to mix into the call during the conversation relay session. Must be set together with backgroundAudioValue; both must be present for background audio to apply. media_url

backgroundAudioValue The background audio source. For media_url, a URL pointing to an audio file (e.g., https://example.com/hold-music.mp3). Must be set together with backgroundAudioType; both must be present for background audio to apply.

Child verbs/nouns

NOUN/VERB DESCRIPTION Language Configures a supported language with optional per-language voice and provider settings. Multiple <Language> elements can be specified to enable multilingual conversations. Parameter Custom key-value parameter passed to the WebSocket server as assistant dynamic variables.

Language Attributes

ATTRIBUTE DESCRIPTION OPTIONS DEFAULT code The language code (e.g., en, fr, es).
ttsProvider The text-to-speech provider to use for this language (e.g., telnyx, google).
voice The voice to use for this language.
transcriptionProvider The speech-to-text provider to use for this language (e.g., google, telnyx, deepgram).
speechModel The speech recognition model to use for this language (e.g., nova-2).

backgroundAudioType The type of background audio to mix into the call for this language. Must be set together with backgroundAudioValue; both must be present for background audio to apply. media_url

backgroundAudioValue The background audio source for this language. For media_url, a URL pointing to an audio file (e.g., https://example.com/hold-music.mp3). Must be set together with backgroundAudioType; both must be present for background audio to apply.

Parameter Attributes

ATTRIBUTE DESCRIPTION OPTIONS DEFAULT name The name of the custom parameter.
value The value of the custom parameter.

Examples

Basic usage with greeting and voice

Multilingual with DTMF language selection

Custom parameters

Custom parameters are passed to the WebSocket server as assistant dynamic variables.

Non-interruptible greeting

Use welcomeGreetingInterruptible="none" to ensure the greeting plays fully before accepting input.

Background audio

Mix a background audio track into the call by setting backgroundAudioType and backgroundAudioValue together. Both attributes must be present; media_url plays audio from a URL.
Per-language background audio is also supported on <Language> elements:

Connect

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-verbs/connect.md
The <Connect> verb starts the service defined in the nested noun in synchronous mode. The following instructions will be executed when the service is stopped.

Attributes

ATTRIBUTE DESCRIPTION OPTIONS DEFAULT action Optional URL where TeXML will make a request when the <Connect> service ends to retrieve a new set of TeXML instructions to continue the call flow. Supported for the <ConversationRelay> and <AIAssistant> nouns.
method HTTP method to use when requesting the action URL. GET, POST POST

Child verbs/nouns

NOUN/VERB DESCRIPTION Stream Start media stream over websocket. See the Stream documentation for more information. ConversationRelay Route a call to a ConversationRelay service that provides voice interactions over a WebSocket connection. See the ConversationRelay documentation for more information. AIAssistant Start a voice assistant on the call. See the AIAssistant documentation for more information.

Expected callbacks

If action is set, TeXML makes a request to the action URL when the connected service ends and executes the TeXML instructions returned in the response, replacing the remaining call flow. This is supported for the <ConversationRelay> and <AIAssistant> nouns. The request payload includes a Reason field describing why the service ended. For <AIAssistant>, common reasons include normal (a transfer is in progress — the call flow continues and the action is not requested), service_error, stt_error, handoff, and hangup. The action endpoint can branch on Reason to decide how to continue the call — for example, returning a <Dial> to a human agent when the conversation ended with a server-error reason.

HttpRequest

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-verbs/httprequest.md
The <HttpRequest> verb sends a request to the external servers. It consists of 2 child nodes <Request> and <Response>

Attributes

ATTRIBUTE DESCRIPTION OPTIONS DEFAULT async Defines if TeXML process should wait for the request response. When it is set to false, the callback will be sent to the action URL, when the request is processed false action Defines the action url that will be used to send the callback when the request is processed (only if async is set to false)

Child verbs/nouns

NOUN/VERB DESCRIPTION Request The <Request> node defines all the attributes of the request. It can have 2 child nodes <Headers> and <Body> Response The <Response> node defines all the attributes of the response. It can have 2 child nodes <Headers> and <Body>

Examples

Expected callbacks

When the HTTP request completes, a callback is sent to the action URL. See HTTP Request Callback for the full payload reference.

Leave

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-verbs/leave.md
The <Leave> verb removes a call from the queue and continues with the next verb after the original <Enqueue>. The <Leave> verb doesn’t support any attributes.

Examples


Refer

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-verbs/refer.md
The <Refer> verb in Telnyx allows you to transfer a phone call to another SIP infrastructure during a TeXML call. You can initiate it at any point during the call. When you use the <Refer> verb, Telnyx will replace the original call with a new call to the external system you specify, effectively transferring the call to that system.

Attributes

ATTRIBUTE DESCRIPTION OPTIONS DEFAULT action Optional URL where TeXML will make a request when the Refer verb ends, to retrieve a new set of TeXML instructions to continue the call flow.
method HTTP request type used to retrieve the next set of instructions. GET, POST POST

Examples

Expected callbacks

If action is set, a callback is sent when the <Refer> verb finishes. See Refer Status Callback for the full payload reference.

Siprec

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-verbs/siprec.md
The <Siprec> instruction starts the SIPREC session on the given call.

Attributes

ATTRIBUTE DESCRIPTION OPTIONS DEFAULT connectorName Specifies which pre-configured external connector shall be used for this request.
statusCallback A URL for Telnyx to send webhook requests to on each event related to siprec session.
statusCallbackMethod HTTP request type used for statusCallback. GET, POST POST track Specifies which track should be forwarded to SRS. inbound_track, outbound_track, both_tracks both_tracks name Name of the SIPREC session. It can be used to stop the session.
includeMetadataCustomHeaders Controls whether custom parameters are added as metadata, if false, they are added to sip headers. false secure Controls whether to encrypt media sent to your SRS using SRTP and TLS. When set you need to configure SRS port in your connector to 5061. false sessionTimeoutSecs Sets Session-Expires header to the INVITE. A reinvite is sent every half the value set. Useful for session keep alive. Minimum value is 90, set to 0 to disable. 90 - 14440 1800

Examples

Expected callbacks

If statusCallback is set, SIPREC status callbacks are sent for the following events:
  • siprec-started — SIPREC session has started
  • siprec-stopped — SIPREC session has stopped
  • siprec-failed — SIPREC session failed to start
See SIPREC Callback for the full payload reference.

Start

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-verbs/start.md
The <Start> verb starts the service defined in the nested noun. As soon as the service is started, the next TeXML instructions will be executed from the provided instructions.

Child verbs/nouns

NOUN/VERB DESCRIPTION Suppression Start noise suppression. See the Suppression documentation for more information. Transcription Start transcription. See the Transcription documentation for more information. Stream Start media stream over websocket. See the Stream documentation for more information. Recording Start recording the call. See the Recording documentation for more information.

Stop

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-verbs/stop.md
The <Stop> verb stops the instruction specified by noun on a call.

Child verbs/nouns

NOUN/VERB DESCRIPTION Suppression Stops current suppression, no attributes need to be provided. Transcription Stops current transcription, no attributes need to be provided. Stream Stops current media stream, no attributes need to be provided.

Examples


Suppression

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-verbs/suppression.md
The <Suppression> noun is used inside <Start> and <Stop> verbs to control noise suppression on the call to improve audio quality.

Attributes

ATTRIBUTE DESCRIPTION OPTIONS DEFAULT direction Specifies which side of the audio shall be denoised. inbound, outbound, both inbound

noiseSuppressionEngine The noise suppression engine to use. Defaults to Denoiser. Denoiser, DeepFilterNet, Krisp, AiCoustics

model The Krisp model to use. Only applicable when noiseSuppressionEngine is Krisp. Available models: krisp-viva-tel-v2.kef, krisp-viva-tel-lite-v1.kef, krisp-viva-pro-v1.kef, krisp-viva-ss-v1.kef.
suppressionLevel Suppression intensity (0.0–100.0). Only applicable when noiseSuppressionEngine is Krisp.
family The AiCoustics model family. Only applicable when noiseSuppressionEngine is AiCoustics. Valid values: sparrow (default), quail.
size The AiCoustics model size. Only applicable when noiseSuppressionEngine is AiCoustics. Valid values: s (default), l, vf (vf requires family to be quail). CCA-supported size aliases are also accepted and normalized.
enhancementLevel Enhancement intensity (0.0–1.0). Only applicable when noiseSuppressionEngine is AiCoustics. Defaults to 0.8.

Examples

Start suppression with default settings

Start suppression with Krisp engine

Stop suppression


Transcription

Source: https://developers.telnyx.com/docs/voice/programmable-voice/texml-verbs/transcription.md
The <Transcription> verb enables real-time speech-to-text transcription for the call.

Attributes

ATTRIBUTE DESCRIPTION OPTIONS DEFAULT language Language to use for speech recognition. See languages in transcription_engine_config. en interimResults Whether to send also interim results. If set to false, only final results will be sent. Applies to transcriptionEngine A only. false transcriptionEngine Engine to use for speech recognition. Available engines: Google (default), Telnyx, Deepgram, Azure, xAI, AssemblyAI, Soniox, Speechmatics, Parakeet, Humain, Reson8, Cohere. Each engine supports different models and languages - see model attribute and examples below. Legacy values “A” (maps to Google) and “B” (maps to Telnyx) are supported for backward compatibility. Google, Telnyx, Deepgram, Azure, xAI, AssemblyAI, Soniox, Speechmatics, Parakeet, Humain, Reson8, Cohere, A, B Google transcriptionTracks Indicates which leg of the call will be transcribed. Use inbound for the leg that requested the transcription, outbound for the other leg, and both for both legs of the call. inbound, outbound, both inbound transcriptionCallback URL that tells Telnyx where to make its GET or POST requests with transcription data.
transcriptionCallbackMethod HTTP request type used for transcriptionCallback. GET, POST POST model Optional model to use with the specified transcription engine. Format is vendor/model-name — e.g. deepgram/nova-2, deepgram/nova-3, azure/fast, assemblyai/universal-streaming, soniox/stt-rt-v4, speechmatics/standard, nvidia/parakeet-v3, xai/grok-stt, humain/realtime, reson8/turns, cohere/ar-stt. The vendor must match transcriptionEngine. If not specified, the engine’s default model will be used. On Deepgram, defaults to deepgram/nova-3. See transcription models in transcription_engine_config.
hints Hints to improve transcription accuracy. On Deepgram, this maps to the Nova-2 keyword biasing feature and is supported only on model="deepgram/nova-2"; it is silently dropped on Nova-3 (use keyterms instead). Accepts a comma-separated string.
keyterms Deepgram Nova-3 keyterm prompting. Biases recognition toward domain-specific terms or brand names. Supported only on model="deepgram/nova-3"; silently dropped on Nova-2 (use hints instead). Accepts a comma-separated string.
smartFormat Disable Deepgram’s smart formatting so the transcript stays lowercase with no punctuation. Deepgram-only; silently dropped on other engines. true apiKeyRef Reference to the API key for authentication. See integration secrets documentation for details. The parameter is optional as defaults are available for some regions.
region Region to use with the specified transcription engine. Required for Azure. See regions in transcription_engine_config.

Examples

Example 1: Basic transcription using Google (default)
Example 2: Google with phone call optimized model
Example 3: Telnyx engine with Whisper model
Example 4: Deepgram with Nova-3 model
Example 5: Azure with Fast model and credentials
Example 6: Azure with Realtime model

Expected callbacks

If transcriptionCallback is set, transcription results are sent as they become available. See Transcription Callback for the full payload reference.

API Reference

Applications

Source: https://developers.telnyx.com/docs/voice/texml/rest-api/applications.md
A TeXML application defines how inbound and outbound calls are handled using TeXML instructions. Each TeXML application instance encapsulates a set of configuration parameters that control call behavior, instruction retrieval, and webhook interactions. These parameters determine where Telnyx fetches TeXML from, how call events are handled, and how call flows are executed. More details: Applications

Calls

Source: https://developers.telnyx.com/docs/voice/texml/rest-api/calls.md
A call object represents a single call leg. It contains all state, metadata, and lifecycle information of that call leg.

Creating calls

A call object is instantiated in the following situations: 1. When an outbound call is initiated through the REST API. Telnyx immediately creates a call resource to represent this outbound call. 2. When an inbound call reaches a phone number assigned to a TeXML application.
  • Before processing any TeXML, a call resource is created to represent the inbound call itself.
  • At that point, the call is answered and the instruction fetch request is sent. The lifecycle of this inbound call is driven by the instructions defined in the TeXML response.
3. When a <Dial> verb is executed inside a TeXML script. Each execution of <Dial> creates a new call resource. This call is logically associated with the parent call that initiated the TeXML request, and Telnyx manages both calls as part of a multi-leg call flow if needed.

Fetching call details

The details of the call can be retrieved using the calls endpoint up to 30 days after the call has ended.

Conferences

Source: https://developers.telnyx.com/docs/voice/texml/rest-api/conferences.md
A conference object represents a multi-participant audio session.

Creating conference

A conference is instantiated in the following way: 1. When a <Dial> to a non-existent <Conference> is executed Documentation: <Conference> 2. When Telnyx processes a TeXML response that includes a <Dial> verb with a <Conference> noun, it attempts to place the current call into a named conference. Documentation: <Dial>

Managing Existing Conferences

Once instantiated, conferences can be managed via REST API endpoints, including:

Conference participants

Source: https://developers.telnyx.com/docs/voice/texml/rest-api/conference-participants.md
A conference participant object represents an individual call leg that has been added to a conference.

Creating a conference participant

A conference participant is instantiated in the following situations: 1. When a new participant is dialed and added to a conference via the REST API API reference: dial-a-new-conference-participant. When your application requests to dial a new party into an existing conference using the REST API, a conference participant resource for the new call leg is created. 2. When a call leg is added to a conference via <Dial> with <Conference> in TeXML Documentation: <Conference> When a TeXML <Dial> verb that contains a <Conference> element is executed, the call leg joins the specified conference. At that point, Telnyx creates a conference participant object associated with that call leg.

When Participant API Responses Return No Results

Certain situations cause the participant API to return no participant records, even if the call or conference previously existed. Telnyx will return no participant objects under the following conditions: 1. The conference has been completed Once a conference ends (e.g., all participants disconnect or the session is terminated), Telnyx no longer returns participant objects associated with that completed conference. 2. A participant’s call leg is no longer active (i.e., has been hung up) If a participant disconnects - whether intentionally, due to call failure, or because of application logic - their call leg is considered complete, and the participant object is no longer returned by the API. 3. The participant has been explicitly removed via the REST API API reference: delete-a-conference-participant 4. The participant’s call leg has been given new TeXML instructions via the REST API API reference: update-call If a call leg that was previously in a conference is updated with new TeXML instructions via the REST API, it effectively leaves the conference context. As a result, it is no longer included in participant API responses.

Recordings

Source: https://developers.telnyx.com/docs/voice/texml/rest-api/recordings.md
A recording object represents an audio recording generated during a call or conference using TeXML application. Recording objects track metadata such as format, duration, start and end times, and storage locations.

Creating recording

A recording can be created in the following situations: 1. When an outbound call is initiated with record enabled via the REST API API reference: Initiate an outbound call If your application initiates an outbound call and specifies the record attribute, Telnyx automatically begins recording the call when it is answered. 2. When a <Record> verb is executed in a TeXML script Documentation: <Record> Whenever a <Record> verb is encountered in a TeXML response, Telnyx initiates audio capture for the call leg that executed the verb. Each execution produces a distinct recording object that captures the audio during the <Record> period 3. When a <Dial> verb is executed with record attributes enabled Documentation: <Dial> If a <Dial> verb includes recording parameters (e.g., to record the outbound leg created by the dial), Telnyx begins recording as soon as that outbound call leg is created. 4. When a <Dial> to <Conference> is executed with record attributes Documentation: <Conference> When a <Dial> connects a call into a <Conference> and recording attributes are provided, Telnyx initiates conference recording. 5. When recording is started manually via the REST API API reference: Request recording for a call The recording may be triggered dynamically on any existing call by making a request to the start recording endpoint. When the request is executed, Telnyx creates a new recording object associated with that ongoing call. 6. When a conference participant is dialed and joined via the REST API with recording enabled API reference: Dial a new conference participant If a new participant is added to a conference using the REST API and recording is enabled for that action, Telnyx begins capturing audio for the participant or the entire conference session.

Fetching Recordings

Recording objects can be retrieved through several query paths depending on how the recording was initiated: 1. By Recording ID - API reference 2. By Conference ID - API reference 3. By Call ID - API reference

Controlling Ongoing Recordings

Once recording is active, your application can manage or modify the recording session using the REST API: 1. Update or stop an ongoing recording on a call - API reference

Transcripts

Source: https://developers.telnyx.com/docs/voice/texml/rest-api/transcripts.md

Transcription Creation

A transcription can be enabled from TeXML in 2 scenarios: 1. When a <Transcription> verb is executed in TeXML Documentation: <Transcription> When Telnyx processes a TeXML document containing the <Transcription> verb, it initiates an audio capture operation based on the parameters defined in that verb. Once the audio is captured and processed, a transcription is provided in statuscallbacks in real-time. 2. When a <Record> verb is executed with transcription attributes Documentation: <Record> If a TeXML <Record> verb includes transcription-related attributes, Telnyx performs transcription on the recorded audio once the recording is complete.

Retrieving recording transcription

Upon completion of the transcription process, a transcription object representing the text output associated with that recording segment is created and can be retrieved using the following endpoint: Fetch a recording transcription resource

SIPREC

Source: https://developers.telnyx.com/docs/voice/texml/rest-api/siprec.md
A SIPREC session represents an active SIP Client Recording (SIPREC) media session associated with a call. SIPREC sessions enable the delivery of call media to an external SIP recording server for compliance recording, monitoring, or archival purposes. Each SIPREC session object encapsulates the configuration, state, and lifecycle of a single recording session tied to a call. In order to use SIPREC, the SIPREC client connectors must be configured in your Telnyx account. See SIPREC client tutorial for more information.

Creating SIPREC session

A SIPREC session can be started in the following ways: 1. Starting a SIPREC session via the REST API API reference: Request a SIPREC session for a call Using the REST API, an application can explicitly request the initiation of a SIPREC session for an active call. When this endpoint is invoked, Telnyx creates a SIPREC session object and begins streaming the call media to the configured SIP recording endpoint according to the supplied parameters. This approach allows SIPREC to be started dynamically at any point during the call lifecycle. 2. Starting a SIPREC session via the TeXML <Siprec> verb Documentation: <Siprec> The SIPREC session is initiated synchronously (nested to <Start> verb) as part of the sequential TeXML execution flow. Subsequent TeXML instructions are processed only after the SIPREC session has been stopped.

Managing and Stopping a SIPREC Session

Once a SIPREC session has been started—either via the REST API or via TeXML - it can be managed throughout its lifecycle using the REST API. API reference: Update a SIPREC session for a call This endpoint allows an application to update the state of an active SIPREC session or explicitly stop the recording.

Streams

Source: https://developers.telnyx.com/docs/voice/texml/rest-api/streams.md
A stream object represents an active media streaming session originating from a call. Streams allow real-time audio from a call to be delivered to an external destination using WebSockets. Each stream object encapsulates the configuration, state, and lifecycle of a single streaming session associated with a call.

Creating stream

A stream object can be started in the following ways: 1. Starting a stream via the REST API API reference: Start streaming media from a call Using the REST API, an application can explicitly start streaming media from an active call. When this endpoint is invoked, a stream object is created and audio begins streaming from the specified call according to the provided configuration. This method allows streaming to be initiated dynamically at any point during the call lifecycle. 2. Starting a stream via the TeXML <Stream> verb Streams can also be initiated as part of TeXML execution using the <Stream> verb, which supports two operational modes:
  • Asynchronous streaming via <Start>
When the <Stream> verb is nested inside a <Start> verb, the stream is started asynchronously. In this mode, streaming begins in parallel with the ongoing call flow, allowing audio to be streamed without interrupting or blocking other TeXML instructions.
  • Synchronous streaming via <Connect>
When the <Stream> verb is nested inside a <Connect> verb, streaming is initiated synchronously. In this mode, the call flow waits for the streaming operation to stop before proceeding to the next TeXML instruction. In both cases, execution of the <Stream> verb results in the creation of a stream object associated with the active call.

Managing and Stopping a Stream

Once a stream has been started—whether via the REST API or TeXML—it can be managed throughout its lifecycle using the REST API. 1.Updating or stopping a stream via the REST API. API reference: Update streaming on a call When streaming is stopped, the associated stream object transitions to a completed state, and websockets are closed.

Queues

Source: https://developers.telnyx.com/docs/voice/texml/rest-api/queues.md
A queue object represents a holding area for calls. Calls in a queue are ordered by the time they were enqueued (First-In-First-Out).

Creating queues

There are two ways to instantiate a new queue: 1. Using the REST API A queue can be explicitly created by sending a request to the Create New Queue endpoint. 2. Using the <Enqueue> Verb A queue can also be created dynamically during call flow execution. When an <Enqueue> verb is executed inside a TeXML script with a specific queue name, Telnyx checks if a queue with that name already exists. If the queue exists, the call is added to it. If it does not exist, a new queue is automatically created with default settings, and the call is then added.

Managing queues

Once a queue is instantiated, it can be managed using the TeXML REST API. Get detailed information about a specific queue by its Queue SID or name. This returns the current state, including the number of calls currently waiting (current size), the average wait time, and the maximum size configuration. Modify the properties of an existing queue. For example, you can change the maximum number of allowed calls (max size) to prevent overloading the system. Remove a queue from your account.

TeXML application secrets

Source: https://developers.telnyx.com/docs/voice/texml/rest-api/secrets.md
The TeXML Secrets API provides a secure mechanism for storing, managing, and retrieving sensitive information required by your TeXML applications. This includes credentials, API keys, tokens, and other confidential values that should not be hardcoded into TeXML documents or exposed in application source code. See the tutorial for more information.

Creating a Secret

The secret can be created using the following endpoint: Create a TeXML secret

API Reference (TeXML)

TeXML Applications

TeXML REST Commands

Callbacks