VoiceGuide IVR Software Main Page
Jump to content

How can VG retrieve info from a Web Service

Recommended Posts

I need to have Voiceguide get a zipcode from the caller and pass it to a webservice then text to speech all of the responses.

 

Karl

Share this post


Link to post

Pretty easy to do from within a 'Run VBScript' module.

 

Can we access the webservice?

 

Can you give us some examples of what the webservice would return?

Share this post


Link to post

Yes. Can you email me and I will give you the url where you can see the parms.

 

Karl

Share this post


Link to post

Can you please publish example codes to do web services using 'Run VBScript' module?

 

Thanks

Share this post


Link to post

Here is an example of how to retrieve information from a web service and return it to VoiceGuide.

 

The example queries a (free) web service provided by ejse.com and retrieves the weather information for a particular ZIP code. In this example 22207 (Arlington, VA) was used.

 

Returned data is then formatted as a Result Variable list and returned to VoiceGuide, when it may now be spoken to the caller or used for any further processing you may like.

 

The demo now calls MsgBox function to show the user what was retrieved as well.

 

You must have Microsoft's SOAP 3.0 Toolkit installed to use this.

See: http://msdn.microsoft.com/webservices/down...ds/default.aspx

 

The code below would go straight into a Run VBScript module:

Set soapClient = CreateObject("MSSOAP.SoapClient30")
soapClient.MSSoapInit "http://www.ejse.com/WeatherService/Service.asmx?WSDL"
Set node_list = soapClient.GetWeatherInfo(22207)
        
For Each node In node_list
  sText = sText & "[" & node.nodeName & "]{" & node.Text & "}"
Next

'show user the returned information.
'comment out this line later.
MsgBox sText  

set vg = CreateObject("VoiceGuide.CommandLink")
vg.Run_ResultReturn $RV_LINEID, sText
set vg = Nothing

set soapClient = Nothing
set node_list = Nothing

 

an example of the Result Variable list returned:

 

[Location]{Arlington, VA}[iconIndex]{26}[Temprature]{44°F}[FeelsLike]{41°F}[Forecast]{Cloudy}[Visibili

y]{9.0 miles}[Pressure]{29.93 inches and rising}[DewPoint]{41°F}[uVIndex]{0 Low}[Humidity]{89%}[Wind]{From the North Northwest at 6 mph}[ReportedAt]{}[LastUpdated]{}

 

So for example to say to the caller that wind is "From the North Northwest at 6 mph" you would just ask VoiceGuide to TTS the contents of $RV[Wind]

 

And of course you can replace 22207 with a Result Variable which stores the ZIP code entered by the caller in some previous 'Get Numbers' module, or retrieved from a database etc etc...

Share this post


Link to post

Thank you so very much. I will try this out and let you know how it goes!

 

Karl

Share this post


Link to post

I wanted to implement this by just parsing the XML. Feel free to use it anyone, it works well on my system.

 

' set xmlDoc=CreateObject("Microsoft.XMLDOM")
' Dim xDoc As MSXML.DOMDocument
' Dim Nodes As MSXML.IXMLDOMNodeList

set vg = CreateObject("VoiceGuide.CommandLink")

Dim MyTime
MyTime = Time  ' Return current system time.
vg.RvSet $RV_LINEID, "SysTime", MyTime

Set xDoc = CreateObject("MSXML2.DOMDocument")
xDoc.async = False
xDoc.validateOnParse = False

If xDoc.Load("http://www.ejse.com/WeatherService/Service.asmx/GetWeatherInfo?zipCode=34236") Then
 ' The document loaded successfully.

  resultStr = "The temperature is currently " & _
  left(xDoc.getElementsByTagName("Temprature").item(0).text,len(xDoc.getElementsByTagName("Temprature").item(0).text)-2) _
  & ".  Humidity is " & xDoc.getElementsByTagName("Humidity").item(0).text & _
  ".  The dew point is " & _
  left(xDoc.getElementsByTagName("DewPoint").item(0).text,len(xDoc.getElementsByTagName("DewPoint").item(0).text)-2) _
  & ".  It feels like " & _
  left(xDoc.getElementsByTagName("FeelsLike").item(0).text,len(xDoc.getElementsByTagName("FeelsLike").item(0).text)-2) _
  & ".  The wind is " & _
  left(xDoc.getElementsByTagName("Wind").item(0).text,len(xDoc.getElementsByTagName("Wind").item(0).text)-3) _
  & "miles per hour.  Today's forecast is " & xDoc.getElementsByTagName("Forecast").item(0).text & "."
  
  vg.RvSet $RV_LINEID, "WeatherStr", resultStr
  vg.Run_ResultReturn $RV_LINEID, True
Else
  ' The document failed to load.

  Set xPE = xDoc.parseError
  With xPE
     strErrText = "Your XML Document failed to load" & _
       "due the following error." & vbCrLf & _
       "Error #: " & .errorCode & ": " & xPE.reason & _
       "Line #: " & .Line & vbCrLf & _
       "Line Position: " & .linepos & vbCrLf & _
       "Position In File: " & .filepos & vbCrLf & _
       "Source Text: " & .srcText & vbCrLf & _
       "Document URL: " & .url
    End With
    
    vg.RvSet $RV_LINEID, "WeatherStr", strErrText
    vg.Run_ResultReturn $RV_LINEID, False
    
    Set xPE = Nothing
End If

Set vg = Nothing
Set xDoc = Nothing
Set Nodes = Nothing
Set MyTime = Nothing

 

Just add a speak module and put $RV[WeatherStr] in the text-to-speak box. Have it play a music file while the script runs as I've found sometimes there's a delay, possibly from the www.ejse.com site.

 

p.s. voiceguide rocks.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×