Telestax Blog

Introducing RVD’s Control element

A shiny new element has been recently added to RVD. It’s named ‘Control’ and aims to make RVD a little bit smarter.


If you have worked with RVD you probably know that it is pretty easy to do simple things like Say announcements, Collect digits etc. However, when putting the slightest logic to the mix, like divert the application flow to another module, change the value of variables arbitrarily or parse a value returned from an External Service, things suddenly change.

External Services as a necessary evil

Traditionally, all logic would be delegated to an external service,  i.e. a script that would handle processing and communicate results back to RVD over http in JSON format. The downside is increased complexity, maintenance and hosting considerations for the script, difficulty in packaging and performance issues. The good part is that it allows adding value to an RVD application to the extend that a script exists to do the ‘smart’ work.

Meet Control

A new element has been added to RVD toolbox to address exactly these. It’s called ‘Control’ and aims to help RVD deal with simple tasks like making decisions, changing the flow of the application, alter variables etc. It works in terms of conditions and actions. If the conditions are met, the actions are evaluated. That’s it!


Conditions are a basic form of expressions that evaluate to true/false. They are either comparisons like equals, greater, less etc. or regex matching expressions. Many conditions can be defined. Each one is evaluated individually and all outcomes are combined together (ANDer or ORed) resulting in the status of the whole Control construct. If this is true the Actions are executed.


Actions are a set of tasks that are executed in case the conditions evaluate to true. Three types of actions are available. Assign, Continue-To and Capture.

  • ‘Assign’ introduces new variables and initializes them using an RVD value.
  • ‘Continue-To’ diverts the flow of the application to an arbitrary module.
  • ‘Capture’ parses an RVD value using a regex pattern and extracts a portion of it inside a variable.


Use cases

Here are some use cases where Control can be handy.

1. Regex-based IVR tree

Suppose you need to implement an IVR tree based on sets of caller ids matched using regular expressions. For example all numbers starting with ‘+1209xxxxx should be directed to module ‘California Support’. Numbers starting with ‘+1301xxx’ should be directed o module ‘NY Support’ etc. You will need a Control elements for each of the modules. Here is the element that handles calls for California:


2. Customize application behavior based on time

Your office closes at 17.00. Between 17.00 and 20.00 you want to forward the calls to your mobile number. A Time online service has been used to provide the current time in JSON format. The date/time value has been extracted from the JSON block but still it needs some parsing to be converted in a usable  ‘hour’ value. The time service returns:

{“status”:”OK”,”message”:””,”formatted”:”2017-02-16 13:11:56″}

You have already extracted the time value in $time variable using an External Service element assignment:

$time = 2017-02-16 13:11:56

Here is how to isolate the hour part to use it in conditions. A control element with ‘Capture’ action has been used:


Note the pair of parenthesis in the regex pattern: .*([0-9]+).*. It designates the portion of the text on the right that will be assigned to the hour variable. In the screenshot above a literal date/time value has been used. In realily that would be a variable like $time initialized from an ES element right before.

Then, you need to check if the $hour is between 17.00 and 20.00 and make the forward if that’s the case. You can use arithmetic operations greater or equal and less to set the conditions. If both of these stand, a ‘Continue-to’ action will divert the flow to the module that will make the call to the mobile:


Note, both condition comparisons are numeric. That’s what the ‘123…’ option on the right side of the text-boxes means.

Of course other conditions may also be applied putting day-of-week to the mix, customizing further the behavior.


Overall, the new element is a valuable addition to RVD. Its functionality is still limited but it can already solve common tasks easily without using External Services. Further operations and actions are likely to be added in the future.

For more information feel free to browse the Control elements documentation page.

Stay tuned!

No Comments

Post A Comment