Extending APEX application with Oracle Digital Assistant

0

We can extend APEX with a conversational UI which has Natural Language Processing (NLP) capabilities. To achieve this, i have used the Oracle Digital Assistant.

Prerequisites:

In one of my previous posts i showed you how to connect the Digital Assistant to Oracle ATP database using Node libraries and instant client.

In this post, we shall take advantage of Oracle REST Data services (ORDS), where we shall expose the data from the database using REST APIs.

We shall use APEX to build a low code application on Autonomous Oracle database.

We then create a Oracle Digital Assistant skill which shall pick the user intent and pass it as parameters to a Node.js function within a custom component that queries the Oracle database.

USECASE

This is a hypothetical use case. Just to unlock new possibilities with APEX and Oracle Digital Assistant at ACME Recruitment.

ACME Recruitment uses an APEX application to manage all open opportunities and applications in different regions within the different LOBs.

Below is a minimum viable product (MVP) of the APEX application. You can access the live demo here:

Live demo

Username: Recruiter

Password: Innovate@2019!

You can also import the APEX app on your environment.
Download the APEX import file here.

ACME Dashboard
ACME Job Listings

We have extended this application using Oracle Digital Assistant(ODA). This will enhance the user experience of the users searching for open opportunities. Users can search for roles using their normal natural language and ODA will handle the rest using Natural Language Processing (NLP).

ACME Recruitment can take advantage of ODA and extend their APEX application with any of the conversational channels of their choice ie. Web, Facebook, Google Voice, Alexa etc.

I have used a web channel in this demo.

Download the pre-built skill here, feel free to enhance it – it has the custom component embedded in it!

Searching for a job using Oracle Digital Assistant

The High level Architecture:

APEX+ODA Architecture

Oracle Autonomous Database REST API (ORDS)

You will have to expose the data in your APEX application using ORDS to be consumed by the Digital Assistant custom component via REST APIs.

I have done an article on how to create ATP RESTful services. Check it out!

Oracle Digital Assistant custom component

Here your knowledge of creating ODA Custom components will be highly useful!

On the skill, create an ODA “composite bag” entity which shall resolve the user intent of location and job type.

In the yaml flow create a System.ResolveEntities component to pick the user intention. You shall then pass the two variables; jobtype and location to a custom component.

jobsAvailable:     #Ideally should resolve the customer intent 
     component: "System.ResolveEntities"
     properties:
       nlpResultVariable: "iResult"   
       variable: "vacancy"
       maxPrompts: 2
       cancelPolicy: "immediate" 
     transitions:
       actions:
         cancel: "maxError"
         next: "listVacancies"
listVacancies:
     component: "vacancies"
     properties: 
       jobType: "${vacancy.value.BagItemjobType}"
       jobLoc: "${vacancy.value.BagItemlocation}" 
     transitions:
       actions:
        jobAvailablelist: "listVacancies2"
        NotAvailable: "resetVariables"
 

On the custom component, you pick the two variables jobtype and location and run a Node request to the ATP database REST API you had created.

There would be a better way to write the code below, this is just an example 🙂

'use strict';
var request = require('request');
//function to determine jobs in a given category and country
function query(jobt,jobl, callback)
{
  request({ "uri": "https://..../ords/labanish/recruitement/vacancies/"+jobt+"/"+jobl,
      "method": "GET"
    }, function (err, res1, body) {
        body = JSON.parse(body);
        callback(body, err);
  });
}
module.exports = {
  metadata: () => ({
    name: 'vacancies',
    properties: {
      jobType: { required: true, type: 'string' },
      jobLoc : { required: true, type: 'string' }
    },
    supportedActions: ['jobAvailablelist', 'NotAvailable']
  }),
  invoke: (conversation, done) => {
    
    const { jobType } = conversation.properties();
    const { jobLoc } = conversation.properties();
    // determine jobs
    var jobLocUpper = jobLoc.toUpperCase();
console.log(jobType+ " "+jobLocUpper);
 query(jobType,jobLocUpper, function (res1, err){
  var lst = "";
  if (res1 && res1.items)
  {
    if (res1.items.length) 
    {
      for (var i = 0; i < res1.items.length; i++) 
      {
       
        if (i > 0)
          lst += ", "
        lst += res1.items[i].vacancyid +": "+res1.items[i].title;
       
      }
 console.log(lst);
    conversation.variable("jobTypes", lst);
    conversation.transition("jobAvailablelist");
    conversation.keepTurn(true);
    done();
    }
    else
    {
      console.log("No items on the selected category");
      conversation.reply("Unfortunately we do not have any vacancies related to " +jobType.toLowerCase() + " in "+jobLoc);
      conversation.transition("NotAvailable");
      conversation.keepTurn(true);
      done();
    }
  }
  else
  {
    console.log("Encountered an error... please try again later or contact the demo administrator");
    conversation.reply("Encountered an error... please try again later or contact the demo administrator");
    conversation.transition();
    done();
  }
});
  }
};

Once done you pack your custom component for local deployment.

Quick Steps:

The ODA skill I shared with you is linked to my APEX application. You can import the skill and retrain it to test it.

Also visit my APEX application to validate the results. (You can manipulate data in the APEX app, check the authentication credentials above)

In ODA run utterances such as;

Hi…

I am looking for a job in Marketing…

Any IT Jobs in Africa?

What roles do you have in Europe related to technology …

Any marketing roles in ASIA?

Watch the Demo Video:

CONCLUSION

APEX enables a business create low code applications within less time. These applications are secure and can be extended to fit the business requirements.

Oracle Digital Assistant offers Natural Language Processing capabilities which can allow the user to query using their normal natural language as they express their intention. This capability comes in handy while extending Enterprise applications using a conversational UI.

I advise you to get a Oracle Free tier cloud to get started with Oracle cloud.

I welcome feedback from the above post.

Happy coding!

0 0 vote
Article Rating

I am a Cloud Solutions Engineer working with a leading cloud solutions company. I have more than 5 years’ experience in the Tech ecosystem. I began my career as a software developer. I am a tech enthusiast, an autodidact whose interests includes Data Management, Cloud Native Development, Mobile and Bots Development, Integration, Low Code Development, AI, Analytics just to say the least.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments