Simplifying Virtual Assistant Orchestration Layer with IBM App Connect

Wilson Wong
5 min readJul 22, 2020

--

Figure 1: Current State of Virtual Assistant Architecture

The current state of building virtual assistants requires the user to interact with a client user interface. The client user interface communicates with the virtual assistant and returns the virtual assistant response to the user, see figure 1. When the virtual assistant needs to call a service, such as fetching user information, the virtual assistants need to call a web service that is connected to a backend system. Because of this, the web service become the ‘orchestration layer’, a connection between your virtual assistant and other services. To help simplify building the orchestration layer, using an application integration technology, such as IBM App Connect, as an orchestration layer, will help significantly reduce the level of effort and code that is required to build a virtual assistant. In this article, I’ll be showing you how to display the order status from Salesforce.

Prerequisites

Getting Started — Display Order Status from Salesforce

IBM App Connect Setup

  1. On the App Connect dashboard click New and select Flows for an API
  2. Define the model name, for this example; we will define the model name to be assistant
  3. Define properties for your model using the table below. Here we are defining what values we want the endpoint to use and return. In this case, we want to pass the order number and return the order status from Salesforce.

4. Click on the Operations tab, click the dropdown and click on Create, then click on Implement flow

5. For the first node, select If from the toolbox tab, see below

Figure 3: Adding If Block

6. In the If block, let’s define a logic where type is equal to getOrderStatus, see below. Note, map the type value from the request body parameters to getOrderStatus

Figure 4: Setting type is equal to getOrderStatus

7. Now in the scenario where type is equal getOrderStatus, add a new node, and select Salesforce, see below. Choose Order and select Retrieve Orders. Note, Salesforce node should have already been configured, if not look at the prerequisites section.

Figure 5: Overview of If block

8. In the Salesforce node, Click on Add condition + and have Order Number equal to orderNumber. Set Maximum number of items to retrieve to be 1. Note map from the request body parameters orderId, see below

Figure 6: SOQL Setup for Salesforce Order Record

9. Now go and click the If block again. Select the Output Schema and define a property, OrderStatus. Then in the if condition where type equal to getOrderStatus, click on Output data and map OrderStatus to the status from the Salesforce node, see below.

Figure 7: Defining Output Schema and setting OrderStatus values from Salesforce Order Object

10. Go and click on the response node. In the response body, define type as the request body type. Define orderStatus from the IfOutput Schema — OrderStatus, see below.

Figure 8: Mapping Output Schema Value to Response

11. Click Done on the top right of the page, and click on the 3 dots on the right-hand side and select Start API

Testing Endpoint

  1. Click on the Manage tab, and under the API Info section, Route URL is your endpoint for your App Connect instance, please save this URL. Then scroll down and click on Create API key and documentation link under the Sharing outside of Cloud Foundry organization section.
  2. Give a descriptive name, for now; you can name it assistant, and click Create. Take a note of the API Key.
  3. To test this endpoint, open Postman and set the endpoint to be the Route URL and set the action as POST.
  4. Set the header using the table below

5. Set your body as this

//Request Body
{
"type": "getOrderStatus",
"orderNumber": "aRealOrderNumberFromYourSalesforceOrg"
}

6. Send the request and you should be getting the order status back from Salesforce

Connecting App-Connect to Watson Assistant

  1. Open your Watson Assistant instance and select a skill that you want
  2. Select the Options section on the left-hand side and webhooks. Paste your URL from App Connect and fill out the header with your values. Now you ready to call App Connect in your dialog nodes! Go to the Resources section below to learn about how to use webhooks.

Expanding your App Connect Functionally

To increase the functionally of App Connect to perform more actions, add properties to App Connect model on what input or output you want. Then go to your flow and expand If block by adding another else if and defining the type name, see figure 9 below. The type name serves as an action router, and based on the name of the type; your flow will route to a specific sub-flow.

Figure 9: Overview of App Connect subflows

Resources

Watson Assistant Webhook: https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-webhooks

Connecting IBM App to Salesforce: https://developer.ibm.com/integration/docs/app-connect/how-to-guides-for-apps/use-ibm-app-connect-salesforce/

--

--

No responses yet