Skip to main content
Skip table of contents

Intelli and Web Service OCP miniApps®

Intelli or Web Service?

Intelli and Web Service miniApps are quite similar. Both allow you to manipulate data. The key difference is that the Web Service miniApp can also pull the data you need from an endpoint of your choosing, whereas the Intelli only allows you to perform calculations on the data you already have.

For instance, in your Flow you might use a Web Service miniApp early on to get a JSON with particular data that you might or might not want to manipulate. But perhaps a few steps down the line you need to manipulate some data from the JSON you already have, without having to make a request to get it again. In that case, it would be appropriate to use an Intelli miniApp.


Configuring a Web Service miniApp

Wait Tab

In the Wait Prompt section, you can set up some waiting announcements,  that is things the customer will hear while the data is being pulled. In this particular example, 2.5 seconds after the query start, the customer will hear the prompt "please wait", and 5 seconds after the query start (meaning 2.5 more seconds after the original prompt), they will hear an additional prompt saying, "still trying to get some data."

The Replay prompt toggle button applies to the additional prompt and if toggled on, triggers the additional prompt to be repeated after each timeout threshold is reached, which is 5 seconds in the example below.

Wait tab example

In the Max Web Service Timeout section, you can set up the exact time after which the request will timeout and exit; you can also specify the prompt that will be played to the customer in that case. The customer will then be taken to the next step in the Flow you have set up, whether it means being redirected to an agent or proceeding with the next miniApp.

Keep in mind that the Max Web Service Timeout may not be less than the additional timeout (indicated above in this same tab) or the Request timeout set up in the next tab.

In order to Replay the additional prompt the Max Web Service Timeout must be longer than the sum of the initial and the additional prompts timeouts.

Web Services Tab

Web Service Environments

On the left, you can see three different tabs that can be configured: wsCall, wsCall_dev, and wsCall_uat.

They enable you to specify different API endpoints within one miniApp. For instance, you can configure the tab wsCall_dev when you are testing the application in the development phase, wsCall_uat when you are performing user acceptance testing, and wsCall when you want to use the actual production API. You can switch between them based on the envMode value you pass to your miniApp in the Flow. As such, the possible options are:

  • envMode="DEV"

  • envMode="UAT"

  • envMode="PROD"

Based on the envMode value, the application will run the correct endpoint.

You don’t have to configure all three tabs if you have no use for three different endpoints; you can just configure whichever one you are going to use.

However, keep in mind that by default your miniApp will run the wsCall tab configurations.

Web Services API Environment Configuration

In the wsCall environment tab of your choice you have to specify the HTTP method you want to use, the HTTP endpoint, and the Request timeout. You have the ability to add as many custom HTTP headers as you want and then provide the body in the JSON format or choose the Form Data option and provide key-value pairs.

The Body and Form Data options are hidden if HTTP GET method is selected, since they are not applicable.

JSON Body example

Form Data example

Caching Functionality

After the initial invocation of the web service, the response can be cached, thereby preventing the need for a subsequent call to the actual web service.

After enabling the Caching functionality from the corresponding toggle button, you can set the expiration time of the cached response with two methods that can be selected from the Expiration type dropdown list:

  • Static expiration - A fixed expiration time set in seconds.

  • OAUTH expiration - An expiration defined by the customer’s server dynamically by attribute $.expires_in.

If static expiration is selected it must be aligned with the expiration policy of the data the miniApp receives to avoid errors.

In case a WebService miniApp is used in Orchestrator and cached functionality is activated, to tackle response errors due to misaligned responses (for example if the cached response is a session token that is expired from the server side but cached from the miniApp), a Condition can send unsuccessful outputs to a Set Field with value ignoreCachedResponse = True to direct the Flow to a new response request and override the previously cached response.

Orchestrator Flow example setup

Failover JSON

You can manage the Failover JSON responses by using the Download/Upload Failover JSON buttons. Failover JSON is a hard-coded JSON response, stored in a file, that the web service miniApp will use in case the actual web service times out or there is an error status code response.

Failover JSON menu

Keep in mind that if you provide the correct endpoint but an incorrect HTTP method, the request will fail.

Encryption Profile

You can select an encryption profile from the dropdown list for each environment. For more info read Encryption Profiles.

Encryption Profiles dropdown list

Outputs Tab

In this tab, you can map which data you want to get from the JSON the web service request returned.

The declaration of outputs is only applicable if the wsCall type is Api.

Output Fields

In the Fields sub-tab, you add custom named outputs, and for each one, you can choose to use a JSON path, or a custom function.

Click the +Add output field button to add a new output field.

Add output field

The JSON path approach allows you to get the value directly from the JSON and return it as a specific output. Select type path for this case. In the example below the first output named store_name  will return the store’s name, and then you can reassign this output or use it later in your logic in the Flow.

Output fields path example

If you want to modify the data first, you need to select type function as the mapping method. Then you can write a function that manipulates the JSON data in the way you want in the User Functions tab and select its name here. For instance, below we have only one defined function, getDnis, the result of which (a string) will be assigned to the output named Dnis.

Output fields function example

Output Functions

In the Function sub-tab, you can write a JavaScript function to get some specific values of the response and set them as the output of the miniApp. This is a useful approach because it allows you to process all the data at once and then get exactly what you need (for instance, you might sort some values, calculate time difference, and so on).

Output Function example

You can have access to the web service response body and code by using  params.wsResponseBody and params.wsResponseCode respectively. For this type of JavaScript code, the script must return a JS object that will contain some outputs. See the example below:

JS
var toReturn;
if (params.wsResponseCode==200){
  toReturn = { hours_message: params.wsResponseBody.hourMessage };
} else {
  toReturn = { hours_message: "There was an error, please try again later" };
}
toReturn;

If you want the output function to be empty and not to assign a JS object to the outputs, the script must return an empty JSON object such as {}.

You can assign output values directly from here but keep in mind that this function overrides the field values. So if you have output1 and output2 already set up to take values from a JSON path, then having them assigned here will override those values. However, you can use any other output which is unassigned.

Output Decryption

In the Decryption sub-tab you can set to get the encrypted data from your endpoint and decrypt it when, for instance, announcing it to the user. To do that you need to add a decryption path. For more information please read Encryption Profiles, Add decryption path .

Decryptions menu

Decryption is available for WebService but not for Intelli miniApps.

User Functions Tab

In this tab, you can specify a JavaScript function for either manipulating the data from the endpoint or just executing some quick actions you want to use elsewhere in the miniApp. Unlike the function in the Outputs tab, which helps deal with bigger business logic, the purpose of the user functions here is to do small actions, such as string manipulation. For instance, you might want to get DNIS values without the +1 prefix. You can write the code here (see the screenshot below) and refer to this function in your API request by including it inside the double curly braces {{}}, like {{getDnis}}.

User Function example

Please make sure that your JavaScript code (whether you have it here or in the Outputs tab, or both) is correct and does not have any syntax or logical errors. You can test it using any JavaScript engines online (for example, https://jsfiddle.net/ ) or offline (nodejs14). At the moment, we are not providing code checking functionality, so if your code is incorrect the miniApp will not work.

Manage Languages Tab

To see the details on how to configure the Manage Languages tab, check out this article.


Configuring an Intelli miniApp

As was mentioned before, Intelli is a simplified version of Web Service, so it allows you to process data without hitting an endpoint. For that reason, this type of miniApp doesn’t have Wait or Web Service tabs, but the rest of the setup is exactly the same.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.