October 15, 2018

Android Error: Failed to resolve: com.google.firebase

[Android Studio]


I updated gradle to 4.4 in my Android app and added below firebase libraries to my app level build.gradle file

implementation 'com.google.firebase:firebase-core:16.0.0'

but while building the project, got the below error

Failed to resolve: com.google.firebase:firebase-core:16.0.0

This is a maven issue. This issue is resolved after adding google() to repositories of allporjects in project level build.gradle file. Now the json looks like below.

allprojects {
    repositories {

August 26, 2018

How to run background service in Oracle MAF

In mobile apps, we often need some services to run in the background to do tasks like fetching or updating data from a server, sync local data with a server, invoking APIs etc.
In this post, we will see how to run a task in the background of a mobile app developed using Oracle MAF.

There is a default utility available in Oracle MAF to run java code in background threads which is MafExecutorService. It has a method execute() to run java runnable on a background thread in the context of the calling thread's MAF feature context. The syntax of the method is like

MafExecutorService.execute(new Runnable()
public void run()
         //Invoke your methods here     

If you update any data change events in the background, invoke below method to make it effective.


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.

    component: "System.CommonResponse"
      processUserMessage: true
      keepTurn: false
      variable: "loc"
        - type: "text"
          text: "OK.. Please provide your address to deliver the Pizza?"
          separateBubbles: false
        - label: "Send Location"
          type: "location" 
        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

March 16, 2018

Oracle MAF: How to get the current row object of an binding iterator programmatically

[Oracle MAF 2.3.1]

Below is a code snippet helps to get the current object of a binding iterator from Java program in Oracle Mobile Application Framework (MAF).

AmxIteratorBinding ib = (AmxIteratorBinding)
oracle.adfmf.dc.bean.ConcreteJavaBeanObject obj=
IncidentVORow row=(IncidentVORow) obj.getInstance();

-- Where

  • #{bindings.listIncidetnsIterator} is binding iterator expression for a list of Incident objects
  • IncidentVORow is a bean class of incident object
  • "row" contains the current row of the iterator binding

March 1, 2018

Oracle Intelligent Bots: Chatbot integration with Facebook Messenger

Below is the procedure to integrate chat bot developed using Oracle Intellegent Bot Cloud Service (IBCS) with the Facebook channel.

  • Create a Facebook page
  • Make sure you see  "Send Message" button on the page like below

  • If you dont see this button, the follow the below steps, other wise continue to the integration
    • Click on the button or select Edit button option
    • Select "Send Messages" option under "Contact you"
    • Click Next
    • Select "Facebook Messenger" in the step2

    • Now you can see as below

    • Click on Finish. Now your facebook page is ready.
  • Now goto Facebook developer page: http://developer.facebook.com
  • Click on "My Apps"

  • Select "Add new app"
  • Give "Display name", email id and click on "Create App ID"
  • Products page will be opened
  • Mouse over to "Messenger" and click on "Set up"
  • Repeat the same for "Webhooks"
  • You can see both of them added under "PRODUCTS" on the left menu of the app
  • Selecte Settings under Messenger from the left menu
  • Scroll to "Token Generation" section
  • In the drop down under "Page", select the facebook page we created above
  • It will generate a "Page Access Token"
  • Click on the generated token. It will be copied to clip board
  • Open the bot for which you are creating this channel
  • Goto Settings and click on Channels
  • Click on "+ Channel"
  • Enter a name to the channel
  • Enter Description which is optional
  • Select Channel Type as "Facebook Messenger"
  • Paste the copied token into "Page Access Token" field
  • Copy "App Secret" from the facebook app's settings to "App Secret" field in bot
  • Enable channel and click on Create
  • You can observe channel created in bot for facebook with two extra fields Verify Token and Webhook URL. And the screen looks like as below
  • Go back to facebook messenger app page
  • Click on "Messenger", scroll to "Webhooks" section and click on "Setup webhooks"

  • Copy "Webhook URL" of bot to "Callback URL"
  • Copy "Verify token" from bot to this facebook app
  • Under "Subscription Fields", select messages and messaging_postbacks
  • Now the window will look like as below
  • Click on "Verify and Save" button which will create a webhook call back to your bot from facebook
  • Now you can see a new field in "Webhooks" section in the facebook app page
  • Select your facebook page from the drop down which is to subscribe your webhook to the page events
  • Once you select the page, a button "Subscribe" will be visible next to the drop down. Click on it
  • Now your facebook channel is ready to talk to the bot
  • Either make your facebook page public or add users as testers to the page to interact with the bot
  • Open facebook messenger and search for the name given to the facebook page and start sending messages to the bot. You will see the bot responses.

February 21, 2018

Oracle Intelligent Bots: Getting Started with Chat bots - My First Chat Bot- Part 2

Continuation of Oracle Intelligent Bots: Getting Started with Chat bots - Part 1

Now you have the basic knowledge about the Oracle chat bot environment. Let's see how to use this environment and create our first chatbot.

  • Click on New Chatbot

  • Enter Name of the bot which is a mandatory field, and description is optional
  • Your bot window will be opened
  • Before, doing further steps, the bot has a default flow to greet the user. So, let's test the bot first. 
  • Click on "Run" icon which is on top right corner
  • Test window will be opened
  • Type anything to start the bot flow. Let's say, "Hi". Now you can see the bot response as below
  • Let's see the dialog flow for this default bot
  • If you observe the dialog flow, we can see different sections but below are very important out of those
    • Variables: variables created to use in entire bot in any state.
    • States: To define the flow in various states. 
    • System.Intent: Is a component name which will map the user input with the corresponding intent and its state defined in the flow
  • Now, let's change this bot
  • Goto Intents
  • Click on the "+ Intent" button to create new Intent
  • Give a name to the Intent. Ex: MyBot
  • Give some statements to identify the intent under "Examples" section, which we call as utterances
  • Select "Flow" from left menu and write the YAML code as below
  • You can observe a button called "+ Components" on top left corner in "Flow" which provides a menu to choose system components
  • In the flow, the first state is "startBot" which is to identify the intent and the corresponding state 
  • If you enter any statement which does not match with any of the utterances, then it will go to "unresolvedIntent"
  • Now run the bot. Let's type "Hi" again. This time you can see a message which we defined to "unresolvedIntent"
  • Now, give any statement from the given utterances like "about". You can see the defined flow will be started. And the bot  will look like as below

Oracle Intelligent Bots: Getting Started with Chat bots - Part 1

In this post, we are going to see how to create a sample chatbot using Oracle Intelligent Bot Cloud Service (IBCS).

Before developing the chatbot, we should understand the terminology.
  • Intent: The entry point of any conversation or use case by describing the various actions that your bot helps its users complete. It enables bot to recognize user input because each intent has a set of typical user statements associated with it.
  • Utterance: It is a typical statement or sample data for an Intent which helps to train the bot. Need to add a good pool of utterances to each intent which will decide to choose the Intent. It is not necessary to be exact string matching.
  • Entity: It is to provide a context to enable your bot to complete a user request. It is a variable or parameter for an Intent or an important word in an input. It is a re-usable component.
  • Dialog Flow: The dialog flow describes how your bot reacts as different intents are resolved. It defines what your bot says to its users, how it prompts them for input, and how it returns data. Think of the dialog flow as a flow chart that’s been transposed to a simple markdown language. In Bots, this markdown language is a version of YAML called OBotML.
  • Custom Components: To put your bot’s intelligence to work, you need to add components and then create a dialog flow. At present, we have two types of components. One is System components which are available by default with the bot and the Other category is custom components which are developed in external systems, used in the bot to completed the flow for the user request.
  • Channels: Enables user to connect to messaging clients like Facebook Messenger, WeChat or any other custom clients like mobile apps, web applications. Oracle IBCS provided client SDKs using which we can generate custom clients as well to interact with the bots.

     Please find the above screenshot of an Oracle Intelligent Bot Cloud Service. All the components discussed above are pointed on the image.
     This image is from a "Finacial Bot" where Balances, Send Money, Transactions etc are the list of intents. The statements like "Do I have enough balance?", "How much do I have available?" etc are utterances for the Intent "Balances", which means when the user gives any of these statements to the bot, then the bot will fetch the "Balance" intent.
     You can also observe "Resource Bundle" on the image which is a new feature in the IBCS which helps to train the bot for multi-language support.

     We will see how to develop our first bot using Oracle IBCS in the next article: Oracle Intelligent Bots: Getting Started with Chat bots - My First Chat Bot- Part 2

February 14, 2018

Oracle MAF 2.5.0 Released

Oracle Mobile Application Framework (MAF) released a new version 2.5.0.
This is a major release containing a number of platform upgrades and enhancements, including the following:
  • A NEW release of JDeveloper is required
  • The embedded Cordova platform engines have been updated
  • Support iOS 11, iPhone X and Xcode 9
  • Support Android 8, and the Google Pixel C phone
  • For faster performance, MAF applications now evaluate EL expressions in the Java VM layer!
  • The inputDate component has been changed such that tapping the up arrow increases the value and the down arrow decreases the value. To keep the older behavior, there is a new attribute (legacyMode) whose value can be set to true.
  • Now support JDeveloper constructs to deploy MAF applications to the Universal Windows Platform, which means that you can deploy your application from the command line
Please refer to the What's New section of the developer guide for detailed information about the changes and how they may affect you.

For additional release information, such as release notes and certification matrix, please refer to the MAF documentation on OTN

January 26, 2018

Resolving or Invoking a Method Expression from a Managed Bean in Oracle MAF

[MAF 2.3.1]

I developed a mobile app using Oracle Mobile Application Framework (MAF) in which I had a requirement to invoke a method from a managed bean method. Below is the code snippet worked for me to do this.

public static Object resloveMethodExpression(String expression,
                                             Class returnType,
                                             Class[] argTypes,
                                             Object[] argValues) {
  MethodExpression methodExpression = AdfmfJavaUtilities.getMethodExpression(expression,
  return methodExpression.invoke(AdfmfJavaUtilities.getAdfELContext(), argValues);

  •  expression:  the managed bean method EL expression
  • returnType:  Class name of the return value of the method, can be null if it is void
  • argTypes: Class names of the input parameters need to be passed to the method if any. It would be null if there are no parameters
  • argValues: Input parameter values to be passed to the method if any. It would be null if there are no parameters