Weather Bot Data Adapter

Weather Bot Data Adapter

Weather Bot Data Adapter

Asset Version: 1.0
  • Version 1.0
Last Published: Apr 20, 2017 By: Kony Team
137 0 2 14
This API.ai connector will allow you to leverage a simple weather chatbot for retrieving weather information. You can ask the bot for weather updates for your location, and even get forecasts. Watch out for a rainy day!

Requirements

  • Kony Fabric
 

Features

  • Easy to create applications to provide weather information
  • Builds connection with api.ai Weather Agent
  • Predefined APIs to fetch weather details
  • Easy to make API calls and view responses

Prerequisites

  • Kony Fabric v8

Damion Isaac BA

Hi, I am getting error code 20001 when following the documentation steps. Is it possible to help on this issue please?

Rajesh Kumar

Hi Damion, We tested the flow it is working fine. Make sure that you are using visualizer enterprise version 7.3 as well as cloud version 7.3

Weather Bot is a data adapter that helps you quickly integrate intelligent conversational user interface into your mobile apps to provide accurate weather information. The data adapter makes use of API.AI Webhook to connect with the Yahoo Weather web service and fetch the weather information. For more information, see API.AI Weather.

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

Use Case

Consider a case that you want to develop a mobile app that provides weather information to bikers. Using the mobile app, the bikers should be able to get the accurate weather information and look for the weather information hourly and location basis.

You can develop a mobile app and make use of the Weather Bot data adapter to get the weather details. Weather Bot is a ready to use data adapter and can be easily integrated with the mobile apps. You can avoid writing lengthy code to obtain weather information from various web services, which consumes lot of time and effort. With the usage of Weather Bot, you just need to do the following:

  1. Design and develop the user interface and functionality of the mobile app using Kony Visualizer.
  2. Import the Weather Bot data adapter into MobileFabric and create integration service with it.
  3. Create operations with required APIs to fetch the weather details.
  4. Integrate the mobile app with the integration service and invoke the operations to execute when required.

The following sections help you use the Weather Bot data adapter:

Prerequisites

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

  1. Client access token and developer access token
  2. A Kony account
  3. Kony MobileFabric 7.3

Importing the Weather Bot Data Adapter

You can import Weather Bot 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 Weather Bot data adapter, and click IMPORT. The Weather Bot data adapter is listed on the Custom Data Adapters page.
    weatherbot_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 Weather Bot data adapter is listed on the Custom Data Adapters page.

Creating an Integration Service with Weather Bot

After you import Weather Bot into MobileFabric, you must create an integration service with service type as Weather Bot to connect with your API.AI Webhook.

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

    The Weather Bot is listed only after you import the Weather Bot data adapter into MobileFabric.

  7. Click Save.

If the details provided are valid, the MobileFabric service connects to the API.AI Webhook 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.

In the Weather Bot data adapter, there are only two APIs, get_query and post_query. This section provides steps to create an operation for the get_query API. You can use the get_query API to obtain the today's weather.

Steps to create an operation for the get_query 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 Weather Bot. 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 Weather Bot is displayed.
  7. Click the plus icon to expand the Weather Bot list.
  8. Click the plus icon to expand the Services list, and select get/query.
    weatherbot_get.png
  9. Click ADD OPERATION. The get_query operation is listed in the Configured Operations section.
    weatherbot_get_oprtn.png
Note:

You can follow the same steps to create operations for the post_query API.

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.

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

Steps to execute the get_query 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 Weather Bot. The Service Definition tab of the selected integration service opens by default.
  5. Click the Operations List tab.
  6. In the Configured Operations section, click the get_query operation. The get_query tab opens with the Request Input sub-tab and Body section opened by default.
    weatherbot_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 following parameters, specify the values in the respective boxes under the Test Value column.
    • v: Specify the version in the YYYYMMDD format. For example, 20150910. Specify the value from June 1, 2015. For more information, refer API.AI Versioning.
    • query: Specify a query as string. For example, Today's weather in Austin.
    • lang: Specify the language tag. For example, "en" is the tag for English language.
    • sessionId: Specify a string token to mange the session parameters.
  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 the response.
    weatherbot_get_output.png

You can follow the above steps to execute the post_query operation, but the request parameters of the post API are different. The following is the list of parameters that you must specify for the post_query operation.

  • v: Specify the version in the YYYYMMDD format. For example, 20150910. Specify the value from June 1, 2015.
  • query: Specify array of queries. For example, ["Today's weather in Austin", "Today's weather in Texas"].
  • lang: Specify the language tag. For example, "en" is the tag for English language.
  • sessionId: Specify a string token to mange the session parameters.
  • contexts: Specify the array of context objects.
  • timezone: Optional parameter. Specify the time zone from the IANA time zone database.