From the MiCC Business Tip Desk
by Patrick McDowell, MiCC Business Customer Advocate
As part of the on-going IVR theme, this month's tips are simple, quick, but powerful.
You can leverage .NET operators on IVR variables. What does this mean? It means things like this:
Let's say you have a variable called <<ANI>> which contains the phone number of the person calling you and you want to determine what area code the caller is calling from, what the phone number prefix is, and what the last 4 digits of the phone number are, and you want to store the results in variables for later use in your workflow. In our example, the caller's number is 6135551212.
- To determine the area code, we need the first 3 characters of the <<ANI>>, you will use an IVR Set Variable widget, set a variable <<AreaCode>> with the value "<<ANI>>".Substring(0,3).
The caller's <<AreaCode>> = 613
- To determine the telephone number prefix, the 3, 4, and 6 characters value in <<ANI>> you will set a variable <<PhonePrefix>> with the value "<<ANI>>".Substring(3,3). Skip 3 characters of <<ANI>> then return the next 3 characters.
The callers's <<PhonePrefix>> = 555
- To determine the last 4 characters of <<ANI>>, you will set a variable <<LastPhour>> with a value of
- Using the length method will always work regardless of how long <<ANI>> is - we want the last 4 characters, so we calculate who long the <<ANI>> is, skip all but the last 4 characters, then return the next 4. If you know that <<ANI>> will always be 10 characters long, you can get the last 4 also by using the value "<<ANI>>".Substring(7).
- The caller's <<LastPhour>> = 1212
Other .NET operators that you can use are ones to manipulate date/time variables. You can use the AddDays(), AddHours(), or AddMinutes() operators.
- To determine what time it was two hours ago, set a variables with value <<Now>>.Addhours(-2)
- To determine what time it will be in 24 hours from now, set a variable value <<Now>>.AddDays(1)
The use of these and other operators follows the standard syntax of .NET and there are a lot of online resources to show you how to use them and you can then leverage in your IVR logic. I encourage you experiment and build cool things!
Pro tip - use a chat workflow to test your variables - you can set a variable and then SAY the result to quickly see if you are getting the results you desire instead of having to look at the logs or make a lot of test calls!