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.Documentation Index
Fetch the complete documentation index at: https://developers.telnyx.com/llms.txt
Use this file to discover all available pages before exploring further.
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
PhoneNumber as a parameter like so:
Don’t forget to update
YOUR_API_KEY here.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 aNumbers list parameter to your callback Url.
PhoneNumbers parameter in the TeXML instructions using the following syntax:
How to render conditional content
Conditional content is supported by usingif/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.
==, != and there is no operator for checking if the parameter value is not null.