TeXML is an XML based data structure used by Telnyx to build quick Call Control applications to be associated with your Telnyx phone numbers. TeXML is the quickest way to get started with Call Control using a simple
.xml file. TeXML allows you to specify call instructions in your file using commands called verbs and nouns. TeXML Translator starts at the top of your TeXML file and executes your TeXML commands sequentially in the order they are arranged in the file.
In this guide, you'll learn how to write a simple text to speech TeXML application using Telnyx Call Control in just five lines of code.
First, follow our Quickstart guide to create a Telnyx account, phone number, and TeXML Application.
If you already have an XML call instruction file from another provider, skip to Step 3. TeXML Translator will seamlessly interpret your existing verbs and nouns.
Create an empty standard
.xml file using your preferred editor.
TeXML files contain the following items:
<Response>element -- tag defining the body of the TeXML document
- verb -- an XML tag denoting the action that you want Telnyx to take
- noun -- the item for the action specified in the associated verb
Our TeXML Translator API documentationAPI contains full details of currently supported commands.
In this example, we want to our application to answer incoming calls, play some speech to the caller and hangup so we only need
<?xml version="1.0" encoding="UTF-8"?> <!-- XML file setup above--> <!-- The Response element wraps the body and is required --> <Response> <!-- You don't need to issue an answer command, start with Say for text to speech --> <Say>This is TeXML text to speech setup in seconds! The call will now hangup.</Say> <!-- For this example, you want to hangup the call otherwise there will be silence --> <Hangup /> </Response>
In order to execute your TeXML file, it has to be available via the internet for Telnyx Call Control to execute. Upload the XML file to your own publicly accessible server or use a temporary file storage service such as https://uguu.se/ for this example.
In your Telnyx Mission Control Portal account created in Step 1:
- Select "Call Control"PORTAL on the left-hand side navigation menu and navigate to the TeXML Applications tab
- Edit the TeXML Application you created in Step 1 by clicking on the row
- Change the
Implementationfrom Webhook to XML
- For this example, change the XML Request Method to
- Enter the URL for the XML file you made available via the internet in Step 3
- Save All Changes
Using your favorite telephony client or your own device, dial the number you purchased in Step 1 which is connected to the Call Control Application we just configured. The call will answer automatically and you should hear your text to speech playing. It's that simple!