Variables are properties of the current message or contact, and can be either numbers or text. By using variables, your SMS service can do something different depending on the incoming message. For example:
- Conditions allow your service to run different actions depending on certain variables.
- Actions that send SMS messages allow inserting variables into the content of the message.
- Actions that add or remove contacts from groups can use a variable for the group name.
- The Set variable rule allows you to create your own variables, and lets you perform basic numeric computations.
When editing actions, there will be an Insert variable... link in places where you can insert variables:
Click Insert variable... to see which variables are available:
The variables content and word1 are probably the most commonly used:
- content is the entire text message.
- word1 is the first word of the message (commonly used within if/then conditions to implement SMS keywords).
To insert a particular variable, simply click its name.
Some names in the list of variables contain parameters that you can change. For example, word2 is the second word of the message. To insert the variable word2, click in the box and change the 1 to 2, then press Enter (or click on word).
Many variables contain other related variables, also called properties, which can be seen by clicking the (+) next to the variable name, or by clicking a variable name followed by "...".
Each text variable contains the properties length, lower, and upper:
The variable contact contains information about the contact who sent the current message, including information about that contact's history of SMS messages:
After you insert a variable into a rule, the variable will appear surrounded by double square brackets. For example:
In the example above, if Telerivet received a SMS from a contact named "Bob", Telerivet would reply, "Hello Bob". (Telerivet shows "6 + ? chars" in the bottom right corner because the length of the SMS reply is 6 characters plus the length of the [[contact.name]] variable.)
Whenever Telerivet processes actions, it will replace all of the variables in double square brackets with the values for the current message or contact.
Once you learn the names of the variables, you can type them directly in square brackets, without needing to open the "Insert variable" dialog.
Suppose you want to create a service with multiple different groups that people can join.
For example, someone could text "JOIN subscribers" to join the subscribers group, or "JOIN customers" to join the customers group.
You could use the [[word1]] and [[word2]] variables like so:
Suppose you want to prevent a single contact from sending more than 10 messages per hour to your SMS service.
You can count the number of incoming messages from that contact in the past hour using the variable [[contact.messages.in.1h.count]], and stop processing rules if this variable is greater than 10: