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
181 1 0 38
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 API.AI data adapter helps you integrate the conversational interface built using the API.AI into your mobile apps. The data adapter is also capable of connecting to external web services through API.AI using the Webhook implementation.

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

Here is a use case that describes the use of the API.AI 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 API.AI. You can also connect to external web services using the Webhook implementation. You can refer to API.AI Documentation for more information on building the conversational bot and Webhook.
  3. Import the API.AI data adapter into MobileFabric and create an integration service to connect to the conversational bot built using the API.AI.
  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 API.AI data adapter:

Prerequisites

Before you start using the API.AI data adapter, ensure you have the following:

  1. An API.AI account
  2. An app created in your API.AI account
  3. Client access token and developer access token issued by API.AI when you created an app
  4. A Kony account
  5. Kony MobileFabric 7.3.

Importing the API.AI Data Adapter

You can import API.AI into MobileFabric 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 API.ai data adapter, and click IMPORT. The API.ai data adapter is listed on the Custom Data Adapters page.
    purebackendbot_cda.png

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 component, and click Open. The Import Data Adapter dialog shows the selected component.

    Note:

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

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

Creating an Integration Service with API.AI

After you import API.AI into MobileFabric, you must create an integration service with service type as API.ai to connect with your conversational bot created using API.AI.

To create an integration service with API.ai, 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 API.ai.
    Note:

    The API.ai Bot is listed only after you import the API.AI data adapter into MobileFabric.

  7. Click Save.

If the details provided are valid, the MobileFabric service connects to the API.AI 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 MobileFabric 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 API.ai. 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 API.ai is displayed.
  7. Click the plus icon to expand the API.ai list.
  8. Click the plus icon to expand the Services list. A list of APIs available in API.AI 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 API.AI 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 API.ai. 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 API.AI. 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