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
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
Re: Using a Web Service with a Scrath Pad Application
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:webservice.php:
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
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>
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>
Hope this helps!
Regards,
Plum Support
Plum Support
http://www.plumvoice.com
http://www.plumvoice.com