We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics

Implementation of GSM service activation via ASPX in VXML

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
Polad
Posts: 21
Joined: Wed Dec 15, 2010 3:50 am

Implementation of GSM service activation via ASPX in VXML

Post by Polad »

Dear all,
I need your advice. I implement static IVR via VoiceXML in our company. Now I need to create dynamic IVR. At the moment I have a direct URL to activate or deactivate the service. The URL is: http://192.168.0.150:9874/default.aspx? ... sact_id=60. This is a service activation code.

My question is how can I insert this line into VoiceXML code? I mean the correct synopsis. At the moment the test code showen as below:
<?xml version="1.0" ?>
<vxml version="2.1" xmlns="http://www.w3.org/2001/vxml" xml:lang="en-US" >

<menu>
<property name = "inputmodes" value="dtmf"/>

<prompt bargein = "true">
<audio src = "cent_govori.wav"/>


</prompt>


<choice dtmf="1" next="http://192.168.0.150:9874/default.aspx? ... sact_id=60 "/>


</menu>

</vxml>

I need pressing button "1" activate that service. I.e. when pressing 1 the VoiceXML send code to asp and activate service.
But it doesn`t work. Could you please help me with correct way of inserting this code into VXML?

Thanks in advanced.

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

Re: Implementation of GSM service activation via ASPX in VXM

Post by support »

Hi Polad,

You are correct in your use of the <choice> tag with the "next" attribute, however, we did notice 2 issues with your code. First, you will need to replace all ampersands (&) in your URL with '&'. Also, please keep in mind that the URL you are going to within the "next" attribute must return valid VoiceXML. We've provided a simplistic example below:

choice.php

Code: Select all

<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");
?>
<vxml version="2.0">
  
<form>
    <block>
      <prompt>
         Welcome to Plum Voice.
      </prompt>
      <goto next="#mainmenu"/>
    </block>
  </form>

  <menu id="mainmenu">
    <prompt>
      For sales, press 1 or say sales.
      For tech support, press 2 or say support.
      For company directory, press 3 or say directory.
    </prompt>
    <choice dtmf="1" next="choicenext.php?id=4&dept=1">
       Sales</choice>
    <choice dtmf="2" next="choicenext.php?id=5&dept=2">
       Tech Support</choice>
    <choice dtmf="3" next="choicenext.php?id=6&dept=3">
       Company Directory</choice>
  </menu>

</vxml>


choicenext.php

Code: Select all

<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");
$id = $_GET['id'];
$dept = $_GET['dept'];
?>
<vxml version="2.0">
  
<form>
    <block>
      <prompt>
         <?php echo 'Your I D is: ' . $id . ', and your department is: ' . $dept . '.'; ?>
      </prompt>
    </block>
  </form>

</vxml>


Regards,
Plum Support

Polad
Posts: 21
Joined: Wed Dec 15, 2010 3:50 am

Re: Implementation of GSM service activation via ASPX in VXM

Post by Polad »

Dear support team,

First, thanks a lot for your advice. I made changes by replacing & to & and test it. It works fine now.
And if you don`t mind I`d like to ask another advice. As you in my URL http://192.168.0.150:9874/default.aspx? ... sact_id=60 the line v_msisdn=992935149998 already contains GSM number. Now I need to determine CallerID in VXML and replace it to v_msisdn=. I know that it should contain variable. But I just don`t know how to use the correct variable.

Could you please advice me how can I determine caller ID and perform this operation. Thanks in advanced.

P.S. Sorry for disturbing you with such requests. This is my first experience with dynamic IVR via VoiceXML :)

Polad
Posts: 21
Joined: Wed Dec 15, 2010 3:50 am

Re: Implementation of GSM service activation via ASPX in VXM

Post by Polad »

In additional to my last post, I have created variable session.telephone.ani. But it doesn`t work. Could you please check, whats wrong with application?

Thanks in advanced.

<?xml version="1.0" ?>
<vxml version="2.1" xmlns="http://www.w3.org/2001/vxml" xml:lang="en-US" >

<menu>
<property name = "inputmodes" value="dtmf"/>

<prompt bargein = "true">
<audio src = "cent_govori.wav"/>
<audio src = "cent_govori2.wav"/>

</prompt>

<var name='callerID' expr='session.telephone.ani' />

<choice dtmf="1" next="http://192.168.0.150:9874/default.aspx? ... sact_id=60 "/>

</menu>

<nomatch cond="true" count="1">
<prompt bargein="false">
<audio src="wrong.wav"/>
</prompt>

</nomatch>

<noinput count="1">
<prompt bargein="false">
<audio src="nosel.wav"/>
</prompt>

</noinput>

</vxml>

Polad
Posts: 21
Joined: Wed Dec 15, 2010 3:50 am

Re: Implementation of GSM service activation via ASPX in VXM

Post by Polad »

The default.aspx code is shown below:

<%
Dim p_Login As String
Dim p_Pwd As String
Dim V_MSISDN As String
Dim V_SACT_ID As String
Dim V_SERV_ID As String
p_Login = Request.QueryString("P_LOGIN")
p_Pwd = Request.QueryString("P_PASSWD")
V_MSISDN = Request.QueryString("V_MSISDN")
V_SACT_ID = Request.QueryString("V_SACT_ID")
V_SERV_ID = Request.QueryString("V_SERV_ID")
Dim cn As System.Data.OleDb.OleDbConnection
Dim cmd As System.Data.OleDb.OleDbCommand
cn = New System.Data.OleDb.OleDbConnection("Provider=MSDAORA.1;User ID=" + p_Login + ";Data Source=invnew;Password=" + p_Pwd + ";Max Pool Size=20;Min Pool Size=10")
Try
cn.Open()
cmd = New System.Data.OleDb.OleDbCommand("SMASTER.T_SVCOM_SERV", cn)
cmd.CommandType = Data.CommandType.StoredProcedure
Dim myParameterPhone As System.Data.OleDb.OleDbParameter = cmd.Parameters.Add("PHONE", Data.OleDb.OleDbType.VarChar, 12)
myParameterPhone.Direction = Data.ParameterDirection.Input
myParameterPhone.Value = V_MSISDN
Dim myParameterService As System.Data.OleDb.OleDbParameter = cmd.Parameters.Add("SERVID", Data.OleDb.OleDbType.VarChar, 20)
myParameterService.Direction = Data.ParameterDirection.Input
myParameterService.Value = V_SERV_ID
Dim myParameterSact As System.Data.OleDb.OleDbParameter = cmd.Parameters.Add("ACT", Data.OleDb.OleDbType.Numeric, 12)
myParameterSact.Direction = Data.ParameterDirection.Input
myParameterSact.Value = V_SACT_ID
Dim myParameterErrCode As Data.OleDb.OleDbParameter = cmd.Parameters.Add("RESULT", Data.OleDb.OleDbType.Numeric)
myParameterErrCode.Direction = Data.ParameterDirection.Output
cmd.ExecuteNonQuery()
Response.Write("Code=" & myParameterErrCode.Value)
cn.Close()
Catch ex As Exception
Response.Write("Code=-999&Coment=Error:" + ex.ToString)
End Try
%>

Could you please check and advice how can I implement my request? Thanks in advanced.

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

Re: Implementation of GSM service activation via ASPX in VXM

Post by support »

Hi Polad,

To help clarify our previous post, the choice tag's next attribute cannot send dynamically generated GET variables. It is only able to send static strings. To send dynamic data, we recommend using the submit tag's namelist attribute. The submit tag's next attribute is also capable of sending static strings within it. We would also recommend using the field tag over the menu tag.

Here's some sample IVR code to accomplish this:

Code: Select all

<?php
header("Content-type: text/xml");
echo "<?xml version=\"1.0\"?>"
?>

<vxml version="2.0">
  <var name="v_msisdn" expr="session.telephone.ani"/>
  <form id="menu">
    <field name="input">
      <grammar type="application/srgs+xml" root="ROOT" mode="dtmf">
	<rule id="ROOT">
	  <one-of>
	    <item> 1 </item>
	  </one-of>
	</rule>
      </grammar>

      <prompt>
	<audio src = "cent_govori.wav"/>
	<audio src = "cent_govori2.wav"/>
      </prompt>

      <filled>
	<submit next="http://192.168.0.150:9874/default.aspx?p_login=testuser&p_passwd=123456&v_serv_id=1&v_sact_id=60" namelist="v_msisdn"/>
      </filled>

      <nomatch cond="true" count="1">
	<prompt bargein="false">
	  <audio src="wrong.wav"/>
	</prompt>
      </nomatch>

      <noinput count="1">
	<prompt bargein="false">
	  <audio src="nosel.wav"/>
	</prompt>
      </noinput>
    </field>
  </form>
</vxml>
Note that we still utilize the submit's next attribute to send the static data to default.aspx but this also allows us to send the dynamic v_msisdn (session.telephone.ani) variable. The default transport method for submit is also GET so this shouldn't impact your default.aspx code.

Regards,
Plum Support

Polad
Posts: 21
Joined: Wed Dec 15, 2010 3:50 am

Re: Implementation of GSM service activation via ASPX in VXM

Post by Polad »

Dear support team,

Thank you very much for your quick response. I tried the code you sent, but... Something is wrong. I here error prompt from phone. Could you please review the code? I just need one working tutorial and according to it I will deploy another services. Also I`d like to ask about default.aspx file. Should I make changes in that file? If yes, then please advice which changes?

Sorry again for disturbing you. As I said on previous post this is my first experience with dynamic IVR via VXML.

My only hope at the moment is you. Thanks in advanced.

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

Re: Implementation of GSM service activation via ASPX in VXM

Post by support »

Hi Polad,

We have verified that the VXML code supplied above does correctly work. There was one change that was required.

This line was missing the semicolon at the end of the line.

Code: Select all

echo "<?xml version=\"1.0\"?>";
There were no other errors with the code. We tested against this script:

Code: Select all

<?php
header("Content-type: text/xml");
echo "<?xml version=\"1.0\"?>";

$p_login = $_GET['p_login'];
$p_passwd = $_GET['p_passwd'];
$v_serv_id = $_GET['v_serv_id'];
$v_sact_id = $_GET['v_sact_id'];
$v_msisdn = $_GET['v_msisdn'];
?>

<vxml version="2.0">
  <form>
    <block>
      <prompt>
	LOGIN: <?= $p_login ?>
	PASSWORD: <?= $p_passwd ?>
	SERV ID: <?= $v_serv_id ?>
	SACT ID: <?= $v_sact_id ?>
	CALLER ID: <?= $v_msisdn ?>
      </prompt>
    </block>
  </form>
</vxml>
We received the expected results:
LOGIN: testuser
PASSWORD: 123456
SERV ID: 1
SACT ID: 60
CALLER ID: 8005557586

When is the error occurring during the call?

Regards,
Plum Support

Polad
Posts: 21
Joined: Wed Dec 15, 2010 3:50 am

Re: Implementation of GSM service activation via ASPX in VXM

Post by Polad »

Dear support team,

I found the problem. The "session.telephone.ani" determine my number without country code (992). I.e. GSM number is 992 93 515 79 08. But I receive caller ID with 93 515 79 08.

Now as I know I need to create variable 992 and assign something like "992 + session.telephone.ani. Could you please help with correct path to perform it.

Thanks on advanced.

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

Re: Implementation of GSM service activation via ASPX in VXM

Post by support »

Hi,

There is no variable available that will give you the country.

However, if you're certain that the country code will be 992 for all your calls, you can assign your variable in the following way:

anisample.php:

Code: Select all

<?php
header("Content-type: text/xml");
echo "<?xml version=\"1.0\"?>";
?>
<vxml version="2.0">
  <var name="ani" expr="'992' + session.telephone.ani"/>

<form id="abc">
<block>
  <prompt>
    Your telephone number is <say-as type="telephone"><value expr="ani"/></say-as>.
  </prompt>
</block>
</form>
</vxml>
Hope this helps.

Regards,
Plum Support

Polad
Posts: 21
Joined: Wed Dec 15, 2010 3:50 am

Re: Implementation of GSM service activation via ASPX in VXM

Post by Polad »

Dear support team,

First, thank you very much for the wonderful support. Everything works fine now.

I just have one last request.

Could you please advise what changes I should make in a default.aspx file for return valid VXML code? I`d like to set the announcement which would say, that at "You operation is successful", or "Unsuccessful". The return codes from aspx code=0 is success, code=1 is unsuccess. How can I assign it. For example in vxml something like that: if code=0 audio src=sucess.wav or if code=1 audio src = unsuccess.wav. I just don't know how to point in vxml that return code from aspx is 0 or 1.

Could you please advice me the changes in vxml file and aspx file. Thanks again for help and support.

P.S. I insert both codes below:

Start.vxml

<?xml version="1.0" ?>
<vxml version="2.1" xmlns="http://www.w3.org/2001/vxml" xml:lang="en-US" >

<var name="v_msisdn" expr="'992' + session.telephone.ani"/>
<form id="menu">
<field name="input">
<grammar type="application/srgs+xml" root="ROOT" mode="dtmf">
<rule id="ROOT">
<one-of>
<item> 1 </item>
</one-of>
</rule>
</grammar>

<prompt>
<audio src = "cent_govori.wav"/>
<audio src = "cent_govori2.wav"/>
</prompt>

<filled>
<submit next="http://192.168.0.150:9874/default.aspx? ... sact_id=60" namelist="v_msisdn"/>
</filled>


<nomatch cond="true" count="1">
<prompt bargein="false">
<audio src="wrong.wav"/>
</prompt>
</nomatch>

<noinput count="1">
<prompt bargein="false">
<audio src="nosel.wav"/>
</prompt>
</noinput>
</field>
</form>
</vxml>


Default.aspx

<%
Dim p_Login As String
Dim p_Pwd As String
Dim V_MSISDN As String
Dim V_SACT_ID As String
Dim V_SERV_ID As String
p_Login = Request.QueryString("P_LOGIN")
p_Pwd = Request.QueryString("P_PASSWD")
V_MSISDN = Request.QueryString("V_MSISDN")
V_SACT_ID = Request.QueryString("V_SACT_ID")
V_SERV_ID = Request.QueryString("V_SERV_ID")
Dim cn As System.Data.OleDb.OleDbConnection
Dim cmd As System.Data.OleDb.OleDbCommand
cn = New System.Data.OleDb.OleDbConnection("Provider=MSDAORA.1;User ID=" + p_Login + ";Data Source=invnew;Password=" + p_Pwd + ";Max Pool Size=20;Min Pool Size=10")
Try
cn.Open()
cmd = New System.Data.OleDb.OleDbCommand("SMASTER.T_SVCOM_SERV", cn)
cmd.CommandType = Data.CommandType.StoredProcedure
Dim myParameterPhone As System.Data.OleDb.OleDbParameter = cmd.Parameters.Add("PHONE", Data.OleDb.OleDbType.VarChar, 12)
myParameterPhone.Direction = Data.ParameterDirection.Input
myParameterPhone.Value = V_MSISDN
Dim myParameterService As System.Data.OleDb.OleDbParameter = cmd.Parameters.Add("SERVID", Data.OleDb.OleDbType.VarChar, 20)
myParameterService.Direction = Data.ParameterDirection.Input
myParameterService.Value = V_SERV_ID
Dim myParameterSact As System.Data.OleDb.OleDbParameter = cmd.Parameters.Add("ACT", Data.OleDb.OleDbType.Numeric, 12)
myParameterSact.Direction = Data.ParameterDirection.Input
myParameterSact.Value = V_SACT_ID
Dim myParameterErrCode As Data.OleDb.OleDbParameter = cmd.Parameters.Add("RESULT", Data.OleDb.OleDbType.Numeric)
myParameterErrCode.Direction = Data.ParameterDirection.Output
cmd.ExecuteNonQuery()
Response.Write("Code=" & myParameterErrCode.Value)
cn.Close()
Catch ex As Exception
Response.Write("Code=-999&Coment=Error:" + ex.ToString)
End Try
%>

Thanks in advanced.

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

Re: Implementation of GSM service activation via ASPX in VXM

Post by support »

Hi,

If you're looking to pass back a value (such as 0 for 'success' or 1 for 'failure') to your initial VoiceXML script, you will want to use a <subdialog>, rather than a <submit>. Since we are primarily a PHP shop here, we have provided you with a working PHP example below, which you can use to help you understand how to write your application using ASP.

first-script.php

Code: Select all

<?php
header("Content-type: text/xml");
echo "<?xml version=\"1.0\"?>";
?>

<vxml version="2.0">
  <var name="v_msisdn" expr="session.telephone.ani"/>
  <form id="menu">
    <field name="input">
      <grammar type="application/srgs+xml" root="ROOT" mode="dtmf">
   <rule id="ROOT">
     <one-of>
       <item> 1 </item>
     </one-of>
   </rule>
      </grammar>

      <prompt>

   <audio src = "cent_govori.wav"/>
   <audio src = "cent_govori2.wav"/>

      </prompt>

      <filled>
	<goto next="#sub"/>
      </filled>

      <nomatch cond="true" count="1">
   <prompt bargein="false">
     <audio src="wrong.wav"/>
   </prompt>
      </nomatch>

      <noinput count="1">
   <prompt bargein="false">
     <audio src="nosel.wav"/>
   </prompt>
      </noinput>
    </field>
  </form>

  <form id="sub">
   <subdialog name ="sub" src="subdialog.php?p_login=testuser&p_passwd=123456&v_serv_id=1&v_sact_id=60" namelist="v_msisdn">
    <filled>
      <if cond="sub.ret == 0">
	<prompt>The transaction was successful!</prompt>
      <else />
	<prompt>The transaction failed!</prompt>
      </if>
    </filled>
   </subdialog>
  </form>
</vxml>
Notice the <if> conditional that branches based on the value that was returned from your subdialog call:

Code: Select all

<if cond="sub.ret == 0">
	<prompt>The transaction was successful!</prompt>
      <else />
	<prompt>The transaction failed!</prompt>
      </if>
subdialog.php

Code: Select all

<?php
header("Content-type: text/xml");
echo "<?xml version=\"1.0\"?>";

$p_login = $_GET['p_login'];
$p_passwd = $_GET['p_passwd'];
$v_serv_id = $_GET['v_serv_id'];
$v_sact_id = $_GET['v_sact_id'];
$v_msisdn = $_GET['v_msisdn'];

if( $p_passwd == 123456 )
{
  $error = 0;
} else {
  $error = 1;
}

?>

<vxml version="2.0">
  <form>
    <block>
	<prompt>
	  LOGIN: <?= $p_login ?>.
	  PASSWORD: <?= $p_passwd ?>.
	  SERV ID: <?= $v_serv_id ?>.
	  SACT ID: <?= $v_sact_id ?>.
	  CALLER ID: <?= $v_msisdn ?>.
	</prompt>
      <var name="ret" expr="'<?php echo($error)?>'"/>
     <return namelist="ret"/>
    </block>
  </form>
</vxml>
Regards,
Plum Support

Polad
Posts: 21
Joined: Wed Dec 15, 2010 3:50 am

Re: Implementation of GSM service activation via ASPX in VXM

Post by Polad »

Dear support team,

We changed aspx to php and implemented everything on php using your samples. All services is working fine now.

Thank you very much for great help and support.

Post Reply