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

Using a Web Service with a Scrath Pad Application

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
Nampaw
Posts: 1
Joined: Thu Jun 16, 2011 10:44 am

Using a Web Service with a Scrath Pad Application

Post by Nampaw »

Hello I have created an IVR using the scratchpad feature but I can't add a data source/webservice to it. I can only add web services to the pre built applications. I would appreciate some help with this.

Thanks

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

Re: Using a Web Service with a Scrath Pad Application

Post by support »

Hi Nampaw,

The scratchpad itself cannot handle web service requests. It was designed to only handle VXML. To correctly handle this situation you should use a subdialog tag to make your web service request. Here's an example using the Plum Survey's test web service.

Scratchpad:

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0">
  <form>
    <var name="question" expr="'Say yes or no.'"/>
    <var name="answer"/>

    <field name="statement">
      <grammar type="application/srgs+xml" root="ROOT" mode="voice">
	<rule id="ROOT">
	  <one-of>
	    <item>
	      yes
	    </item>
	    <item>
	      no
	    </item>
	  </one-of>
	</rule>
      </grammar>

      <prompt>
	<value expr="question"/>
      </prompt>

      <filled>
	<assign name="answer" expr="statement"/>
      </filled>
    </field>

    <subdialog name="webservice" src="http://www.plumvoice.com/example/webservice.php" namelist="question answer">
      <filled>
	<prompt>
	  The web service returned: <value expr="webservice.Value"/>
	</prompt>
      </filled>
    </subdialog>
  </form>
</vxml>
webservice.php:

Code: Select all

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

$question = array($_GET['question']);
$answer = array($_GET['answer']);

ob_start();
$soap_client = new SoapClient("http://survey.plumvoice.com/ws/sample-webservice.php?wsdl", array('trace' => 1, 'exceptions' => 0));
ob_end_clean();

$result = $soap_client->plumEval($question, $answer);
?>

<vxml version="2.0">
<form id="main">
  <block>
    <var name="Value" expr="'<?= $result ?>'"/>
    <return namelist="Value"/>
  </block>
</form>
</vxml>
This example submits both the question and answer to the web service. This test web service looks at the answers that were submitted and looks for the keyword "yes". If "yes" was sent the web service should return "accepted" while any other value returns "rejected" (in this case, "no").

Hope this helps!

Regards,
Plum Support

Post Reply