Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The NewVoiceMedia Vonage Contact Center Javascript Engine is a special type of web service that accepts some JavaScript, run the script and returns the results. You can then write these results to Data Sources for use later in the call plan.

Info

To use the NewVoiceMedia Vonage Contact Center Javascript Engine in web service interactions that you define using a template, the template must contain $(JavascriptEngineUrl) in the Url element.

Using the NewVoiceMedia Vonage Contact Center Javascript Engine, you can manipulate existing data for your purposes.

For example, a customer currently uses a Data Announcer to announce a caller's postcode, which is stored in a Data Source, but wants to only announce the first three characters of the postcode. The customer can use the NewVoiceMedia Vonage Contact Center Javascript Engine to run a JavaScript method that extracts the first three characters of the provided postcode.

To use the NewVoiceMedia Vonage Contact Center Javascript Engine, you must create a Data Connector that uses a Web Service interface. For more information about using a Web Service interface, see Retrieving data from a Web Service. Provide the following values in Interaction Definition:

  • In the Url element, type $(JavascriptEngineUrl). $(JavascriptEngineUrl) is a special configuration value that holds the address of the NewVoiceMedia Vonage Contact Center Javascript Engine.
  • Create a Content-Type header to enable the Javascript Engine to execute correctly.
    • Inside the <Request> element, create the following <Headers> element:
      <Headers><Header><Key>Content-Type</Key><Value>application/json</Value></Header></Headers>
  • In the Body element, type the JavaScript method that manipulates the values as required.
    • In the following example, the JavaScript extracts the first three characters of the value stored in the Postcode Data Source:
      <Body><![CDATA[{"script": "var str = \"$(Postcode)\"; result = str.substring(0, 3);"}]]></Body>
    • In the following example, the JavaScript adds three zeros to the front of the value stored in the Order Number Data Source:
      <Body><![CDATA[{"script": "result = \"000\" + \"$(Order Number)\";"}]]></Body>

...

One of the following messages appears. The JavaScript you provide in the Body element must now be approved by NewVoiceMediaVonage Contact Center.

JavaScript Engine approval (super user)

JavaScript Engine approval

Note
titleDouble quotes in Data Source value

The EscapeDoubleQuotes formatter reformats data source values. When using the NewVoiceMedia Vonage Contact Center Javascript Engine, you can use the EscapeDoubleQuotes formatter to escape any double-quotes within data sources in your JavaScript methods. 

If the value of a data source contains a double quote ...

for example, a JSON object returned by an earlier call to a web service:
{ "type" : "postcode", "name" : "AB12 3CD" }

... you can add the EscapeDoubleQuotes suffix to the end of the data source name:

{ "script" : "x = $(AddressDetail:EscapeDoubleQuotes);" }

Adding the suffix escapes any double-quotes in the data source value. The reformatted value contains escaped double-quotes:

{ "script" : "x = { \\\"type\\\" : \\\"postcode\\\", \\\"name\\\" : \\\"AB12 3CD\\\" };" }

...