Using a Data Source value in a Web Service Interface request

When using a Data Connector applet with a web service interface, the applet is sometimes referred to as a Web Service Data Connector or WSDC.

When you configure a Data Connector applet to get data from or send data to an external web service, you can send static values to that web service in the request object. You can also send values that other applets in the interaction plan have collected and stored in Data Sources—Data Sources are specific to each interaction so you cannot know their values when you configure the Data Connector applet. For example, you can pass the contents of a Data Source that contains the caller's order ID, and use this order ID to get information about the caller's order from the configured web service.

You can use Data Source values in the following ways:

  • If you are defining the web service interaction using XML, to insert a Data Source value into a request, use a placeholder in the Url element, Key or Value element of a header, or in the CDATA section of the Body element.
  • If you are using a template to define the web service interaction, to insert a Data Source value into a request, use a placeholder in any required request parameter fields.

Placeholders must be in the format $(DataSourceName). Replace DataSourceName with the name of the Data Source that contains the value you want to use in the request.

 Example

An interaction plan has an IVR Collect Digit String applet and a Data Connector applet. The IVR Collect Digit String applet collects a caller's order ID (1234567) and stores the value in an IVR Slot called OrderID. This IVRSlot is made available to the Data Source, IVRSlot|OrderID.

The Data Connector applet is configured to use a Web Service interface. The Interaction Definition can use the Data Source in the following ways:

  • <Url>http://example.com/order/$(IVRSlot|OrderID)/</Url>.
  • <Header><Key>OrderId</Key><Value>$(IVRSlot|OrderID)</Value><Header>
  • <Body><![CDATA[$(IVRSlot|OrderID)]]></Body>

When the call reaches this applet, $(IVRSlot|OrderID) is replaced with 1234567 and the web service processes the value accordingly.

If the Data Source does not exist or has not been set, the call will route to the applet chosen in the Interface Failure list.

If the Data Source is null, the placeholder is removed.

Remove leading '+' characters

If a data source contains a phone number in E.164 format, with a leading '+' character, you can use the data source with the RemoveLeadingPlus formatter. RemoveLeadingPlus removes '+' characters at the beginning of the data source value.

For example, if data source CustomerClid contains the value '+1234567890' and the value is required without the '+' character, add the RemoveLeadingPlus as a suffix at the end of the data source name: $(CustomerClid:RemoveLeadingPlus). The data source value is returned as '1234567890'.

Support and documentation feedback

For general assistance, please contact Customer Support.

For help using this documentation, please send an email to docs_feedback@vonage.com. We're happy to hear from you. Your contribution helps everyone at Vonage! Please include the name of the page in your email.