API.ai Data Adapter

API.ai Data Adapter

API.ai Data Adapter

Asset Version: 1.0
  • Version 1.0
Last Published: Apr 20, 2017 By: Kony Team
283 1 0 44
API.AI is a natural language understanding and machine learning platform that makes it easy for developers (and non-developers) to design and integrate intelligent and sophisticated conversational user interfaces into mobile apps, web applications, devices, and bots that continuously improve over time automatically. This Data Adapter lets you integrate the capabilities of API.AI into your Mobile application. Use this adapter to create delightful user interactions.

Requirements

  • Kony Fabric
 

Features

  • Quickly integrate your apps with conversational bots developed in api.ai
  • Facility to connect to external web services through api.ai
  • Easy to make API calls provided by api.ai and view responses
  • Incorporate natural conversation and machine learning experiences into your applications

Prerequisites

  • Kony Fabric v8

The Dialogflow (formerly API.AI) data adapter helps you integrate the conversational interface built using the Dialogflow into your mobile apps. The data adapter is also capable of connecting to external web services through Dialogflow using the Webhook implementation.

Dialogflow is a platform to develop the intelligent conversational interfaces for mobile apps, web applications, and devices. For more information, refer Dialogflow.

Here is a use case that describes the use of the Dialogflow data adapter.

Use Case

Consider a case of a customer who runs an online training institute. The customer needs a mobile app that is capable of answering queries of students on various subjects via chat. It would be a huge investment for customer to set up infrastructure and hire support team to assist many students simultaneously on various subjects. Alternatively, you can do the following:

  1. Design and develop the user interface and functionality of the mobile app using Kony Visualizer.
  2. Build the required conversational bot using the Dialogflow. You can also connect to external web services using the Webhook implementation. You can refer to Dialogflow Documentation for more information on building the conversational bot and Webhook.
  3. Import the Dialogflow data adapter into Kony Fabric and create an integration service to connect to the conversational bot built using the Dialogflow.
  4. Create operations with required APIs to fetch required details.
  5. Integrate the mobile app with the integration service and invoke the operations to execute as required.

The following sections help you use the Dialogflow data adapter:

Prerequisites

Before you start using the Dialogflow data adapter, ensure you have the following:

  1. A Dialogflow account
  2. An app created in your Dialogflow account
  3. Client access token and developer access token issued by Dialogflow when you created an app
  4. A Kony account
  5. Kony Fabric V8

Importing the Dialogflow Data Adapter

You can import Dialogflow into Kony Fabric directly from Kony Marketplace or by importing the data adapter zip file.

To import the data adapter from Marketplace, do the following:

  1. Log on to your Kony account. The Dashboard page appears by default.
  2. In the left pane, click the API Management menu. The APIs tab opens by default.
    amadeus_api_page.png
  3. Click the Customer Data Adapters tab. The Custom Data Adapter page appears.
    amadeus_cda_import.png
  4. Click Import. The Import Data Adapter dialog appears.
    amadeus_import_da.png
  5. Click IMPORT FROM KONY MARKETPLACE. The Import Data Adapter from Kony Marketplace dialog appears with a list of available data adapters.
  6. Find and select the Dialogflow data adapter, and click IMPORT. The Dialogflow data adapter is listed on the Custom Data Adapters page.

To import the data adapter zip file, do the following:

  1. Perform steps 1 to 4 in the above procedure.
  2. Drag the data adapter zip file into the Drag a Data Adapter box.

    Alternatively, click browse. The Open dialog appears.

    Navigate to the location where you downloaded the data adapter (zip file) on your computer, select the data adapter, and click Open. The Import Data Adapter dialog shows the selected data adapter.

    Note:

    If the selected data adapter zip file is not the one that you want to import, click Remove.

  3. Click Import. The Dialogflow data adapter is listed on the Custom Data Adapters page.

Creating an Integration Service with Dialogflow

After you import Dialogflow into Kony Fabric, you must create an integration service with service type as Dialogflow to connect with your conversational bot created using Dialogflow.

To create an integration service with Dialogflow, do the following:

  1. Log on to your Kony account. The Dashboard page appears by default.
  2. In the left pane, click the API Management menu. The APIs tab opens by default.
  3. Click the Integration tab. The Integration tab opens with a list of existing integration services.
  4. Click CONFIGURE NEW. The Service Definition tab opens.
  5. In the Name box, type a unique name for your service.
  6. From the Service Type list, select Dialogflow.
    Note:

    The Dialogflow Bot is listed only after you import the Dialogflow data adapter into Kony Fabric.

  7. Click Save.

If the details provided are valid, the Kony Fabric service connects to the Dialogflow and allows you to make the API calls.

Refer to Integration Services for more information on creating and using integration services.

Creating an Operation

To make any API call in the Kony Fabric console, you must create an operation for the respective API and then execute the operation. Executing an operation involves making the API call and displaying the response. For more information, see Executing an Operation.

This section provides steps to create an operation for the get context API.

Steps to create an operation for the get context API:

  1. Log on to your Kony account. The Dashboard page appears by default.
  2. In the left pane, click the API Management menu. The APIs tab opens by default.
  3. Click the Integration tab. The Integration page appears with a list of existing integration services.
  4. From the list of integration services, select the integration service that you have created with service type as Dialogflow. The Service Definition tab of the selected integration service opens by default.
  5. Click the Operations List tab. The Operations List tab opens.
  6. Click the context menu arrow to expand the Please Select list. The Dialogflow is displayed.
  7. Click the plus icon to expand the Dialogflow list.
  8. Click the plus icon to expand the Services list. A list of APIs available in Dialogflow are listed.
    purebackend_getcontext.png
  9. Select get/context and click ADD OPERATION. The get_context operation is listed in the Configured Operations section.
    purebackend_get_oprtn.png
Note:

You can follow the same steps to create operations for other APIs.

You can create the operations with required APIs and save them in the Configured Operations section. You can then execute the operations when ever required.

Executing an Operation

Executing an operation involves making the API call by setting the necessary parameters and displaying the response. The procedure to execute any operation is same, but the request parameters of the APIs vary. For more information on request parameters of each API, refer Dialogflow Documentation.

This section provides steps to execute the get_context operation (explained in Creating an Operation).

Steps to execute the get_context operation:

  1. Log on to your Kony account. The Dashboard page appears by default.
  2. In the left pane, click the API Management menu. The APIs tab opens by default.
  3. Click the Integration tab. The Integration tab opens with a list of existing integration services.
  4. From the list of integration services, select the integration service that you have created with service type as Dialogflow. The Service Definition tab of the selected integration service opens by default.
  5. Click the Operations List tab.
  6. Under the Configured Operations section, click the get_context operation. The get_context tab opens with the Request Input sub-tab and Body section opened by default.
    purebackend_get_exeoprtn.png
  7. In the Name box, the name of the operation is displayed by default. If you want, you can change the name.
  8. On the Request Input tab, in the Body section, for the sessionId parameter, specify the values in the respective box under the Test Value column.
  9. Click Header. The Header section opens.
  10. Click Add Parameter. A new row adds to provide parameter values.
  11. In the box under the NAME column, type Authorization.
  12. In the boxes under the TEST VALUE and DEFAULT VALUE columns, type "Bearer", a space (" "), and then developer access token, which is generated when you created an app in Dialogflow. For example, Bearer 123456.
  13. Click SAVE OPERATION.
  14. Click the Test tab, and then click SAVE AND FETCH RESPONSE. The Output Result dialog appears with a response.
    purebackend_getcontext_output.png

 

Publishing the App in Kony Fabric

After adding the Dialogflow data adapter to your app and configuring the necessary configurations, you must publish the app to Kony Fabric. For more information, refer to Publish a Project to Kony Fabric.