June 16, 2018

Oracle Intelligent Bots: Get the user Geo location from the map

For few use cases like delivering a Pizza, it would be a great user experience to take user's current location directly from a Map instead of asking the user to type his address.

In this post, we will see how to capture the user location from a map in a chatbot developed in Oracle ChatBots.

Oracle bots provide a component "System.CommonResponse" which helps us here to get the location. Below is the snippet to get the location.

----------------------------------------------------------------------------------------------------
 userLocation:
    component: "System.CommonResponse"
    properties:
      processUserMessage: true
      keepTurn: false
      variable: "loc"
      nlpResultVariable:
      maxPrompts:
      translate:
      metadata:
        responseItems: 
        - type: "text"
          text: "OK.. Please provide your address to deliver the Pizza?"
          iteratorVariable:
          separateBubbles: false
          rendered: 
        globalActions:
        - label: "Send Location"
          type: "location" 
    transitions:
      actions:
        locationReceived: "locMapReceived"
        textReceived: "locTextReceived"

----------------------------------------------------------------------------------------------------

The above code results as below image.
When the user clicks on the "Send Location" button, it will open the map application. The user can select current or any other location and submit. Once the user submits the location, the bot will receive a JSON into the variable assigned for it which is "loc" in the above example and invokes state assigned to the action "locationReceived". The JSON looks like as below. 

{"latitude":17.727758609852,"title":"Learning's Location","url":"<url of the map>","longitude":83.287353515625}

The JSON contains, latitude, longitude, title of the location on the map and the direct url to the selected location.

In the above example we have another action "textReceived" which helps to handle if user inputs text instead of selection on map.

Note: While implementing this, please check if your client application supports this feature and maps. I tested this with FB and Test console.

April 23, 2018

Oracle Intelligent Bots - Integration with Smooch

Smooch is the complete messaging platform for enterprise software makers. To know more about Smooch click here. Oracle Intelligent Bot made it very easy to integrate your bot with Smooch.

In this post, we will see how to integrate #chatbot developed in Oracle Intelligent Bot(#OracleMobile) with Smooch to open as a web page. Below is the procedure to do the same.

  • Create a channel in the bot for Smooch. To do so,
    • Goto settings of the bot
    • Select Channels tab
    • Click on "+Channel" to create a new channel

    • Enter Name and Description
    • Select Channel Type "Web". You can see a window like below

    • Click on Create
    • You can see a screen like below which contains an app id and app secret to connecting with the clients

  • Preparing a smooch client to connect with the bot
    • In this example, we use a web client to connect with the bot
    • Refer this smooch page and download/create the HTML page from https://github.com/smooch/smooch-web
    • Replace the app id with the id created above
    • Run the web page, you will see a chat widget on the page as below
    • Click on the chat icon and start your conversation with the bot

April 13, 2018

Connecting Oracle Mobile Application Framework (MAF) with Oracle Intelligent Bots

[Oracle Intelligent Bot 18.1.1]

In this post, we will see how to create a client in Oracle Mobile Application Framework (MAF) to connect with chatbot developed in Oracle Intelligent Bot. In this example, I am using bot version 18.1.1 and sample server in the bot instance.

To achieve this, we need to 
  • Create a webhook channel in Bot
  • Create a channel in web socket server
  • Create a client in MAF
Create a webhook channel in Bot

  • Go to settings in bot service
  • Select Channels tab
  • Click on “+ Channel” button, a window will be opened to create a channel
    • Fill name and description fields
    • Select Channel Type as “webhook”
    • Platform version as “1.1 (Conversation model)”
    • Fill Outgoing webhook URI as below (Below is a sample url if you are using sample server and channel id you can copy from webhook url. If you are using other server, please fill this accordingly)
      • https://bots-samples-nodejs:8889/ext/apps/chat/bots/<channel id>/messages
    • Enable the channel and Click on create












Create a channel in web socket server
  • Open admin console of the sample server : http://<host>:8888/ext/apps/chat/admin/
  • Select Channels tab
  • Click on “New Channel” button
    • Fill name and description
    • Copy server key and webhook URL from the bot created above and fill here
    • Click on Save






Create the client in MAF

Please follow below steps to integrate MAF with the web chat client widget.
  • Go to dev-resources of the bot instance and download the web client source code
  • Create a MAF application
  • Go to folder structure and navigate to public_html folder under ViewController folder of the app
  • Copy web client source code folder inside the public_html folder
  • Go to jdeveloper, open maf-feature.xml
  • Click on + icon and create a new feature
  • Under content, select type as “Local HTML”
  • In the copied chatclient folder, there is an index.html page. Select this page for URL under the feature content
  • Open settings.js file inside the chatclient folder
  • Update the Uri and channel id with your bot details
  • User id is hardcoded here to “Anand”, but you can pass username at runtime if required
  • Now, run the app, a chat window will appear in the app