Page 1 of 1

How to split session.telephone.ani?

Posted: Thu Jul 07, 2011 8:11 am
by Polad
Dear support team,

I have one question. I assign variable session.telephone.ani and I see numbers which dial my application. They come with "70" and "77" prefixes. Now I need to assign some property, something like "if number start with 77 goto next hello.vxml else goto next change.vxml". Could you please help me with correct syntax?

Thanks beforehand.

Re: How to split session.telephone.ani?

Posted: Thu Jul 07, 2011 9:12 am
by support
Hi Polad,

The following example below will allow you to direct callers to specific scripts depending on the prefixes of their phone number:

splitnumbers.php:

Code: Select all

<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
?>
<vxml version="2.0">

<form id="splitnumber">

<var name="phonenum" expr="session.telephone.ani"/>
<var name="firsttwo" expr="phonenum.substring(0,2)"/>

<block>
  <if cond="firsttwo==77">
    <goto next="hello.vxml"/>
  <else/>
    <goto next="change.vxml"/>
  </if>
</block>

</form>
</vxml>
From this example, the variable, phonenum, is set to the value of session.telephone.ani (the caller's phone number). Next, the variable, firsttwo, is set to the substring of the first two numbers of the telephone number. From here, the application proceeds to the block and if the user's first two digits of their phone number are 77, they get directed to hello.vxml. If the user's first two digits are a number other than 77, they get directed to change.vxml.

Hope this helps.

Regards,
Plum Support

Re: How to split session.telephone.ani?

Posted: Thu Jul 07, 2011 9:42 am
by Polad
Dear support team,

Thank you very much. I just would like to ask one more question. If I need to assign property for first 3 digits (070), should I make changes in <var name="firsttwo" expr="phonenum.substring(0,2)"/> and change it to <var name="firstthree" expr="phonenum.substring(0,3)"/>. Am I correct?

Thank beforehand.

Re: How to split session.telephone.ani?

Posted: Thu Jul 07, 2011 10:16 am
by support
Hi Polad,

Yes, that is correct.

Regards,
Plum Support

Re: How to split session.telephone.ani?

Posted: Fri Jul 08, 2011 12:07 am
by Polad
Dear support team,

Everything is working correctly. Thank you very much.