Improve APEX Functionality Using Oracle Digital Assistant

Improve APEX Functionality Using Oracle Digital Assistant

During the recent NLOUG meetup, I gave a presentation on the integration of Oracle Digital Assistant (ODA) into an APEX application. The focus was on a problem faced by teachers at the Amsterdam University of Applied Sciences. These teachers experience that students often come with (unnecessary) questions about where they can find more information. There is a need for a central point where students can ask questions about various matters, where they receive an immediate answer or are directed to where this information can be found. A proof of concept with Oracle Digital Assistant was started to test such functionality.

What is Oracle Digital Assistant?

Oracle Digital Assistant (ODA) is an advanced chatbot and AI platform. It uses artificial intelligence and machine learning to enable natural language processing (NLP), allowing users to interact with applications in an intuitive and interactive way. ODA can be integrated into various applications and can perform tasks such as answering questions, providing support, and automating routine processes. The platform supports multiple channels, including web, mobile apps, and popular messaging platforms, making it a versatile solution for improving user experience and increasing efficiency within organizations.

Developing ODA

ODA is a set of skills (chatbots) that are started based on instructions. These instructions can come in through various channels, such as MS Teams, Slack, or web applications. Skills are individual chatbots designed to interact with users and perform specific types of tasks, such as ordering food, making reservations, and changing contact details. Each skill helps a user complete a task through a combination of follow-up questions and simple UI elements such as dropdown lists. In the example of the students, these could be questions like:

  • I want to view my grades

  • Where can I find teacher X?

  • What time does my next class start?

  • Where can I find information about the next practical lesson?

These questions are called Intents. Intents allow the skill to understand what the user wants the skill to do. An intent categorizes the user's request based on the tasks and actions the skill performs. To properly train a skill, between 10 and 30 variations of a question must be devised per intent. These variations are called utterances.

Specific information can be extracted from a user's question. Within ODA, these are called entities. Entities can take various forms, such as dates, locations, names, numbers, etc. They are often used in combination with intents, which capture the user's general intent, to generate a more detailed and accurate response. For example, in a sentence like "Do I need to bring study materials to tomorrow's science lesson," "science" and "tomorrow" can be recognized as entities. ODA has built-in entities, which are standard entities such as date and numbers. Company-specific data such as "science lesson" must be added by the developer.

Once intents and associated entities are created, it is time to train the skill. The collected utterances and defined entities are used to create a training dataset. This dataset helps ODA's machine learning models recognize patterns and identify the correct intent and entities in new user input. ODA has two types of trainers:

  1. Trainer Ht

    Ht stands for "Hierarchical Trainer" and this trainer is designed to improve intent recognition and entity extraction by using a hierarchical approach. This means that the trainer divides the intents and entities into different levels, allowing the model to better understand how different intents and entities relate to each other.

  2. Trainer Tm

    Tm stands for "Transactional Model Trainer" and is designed to improve intent recognition and entity extraction by using a transactional approach. This means that the trainer treats the intents and entities as separate transactions, allowing the model to better understand how different intents and entities are used in specific contexts.

Due to the more complex nature of Trainer Tm, a larger set of intents is required than for Trainer Ht. This makes it ultimately more accurate but requires more effort to develop. Once one or more skills are trained, they can be combined into a single digital assistant. The advantage of this modular approach is that if a change is made to a component, only that specific component needs to be maintained and not the entire assistant.

The skill can now recognize the user's intent and various parts of the question and/or task. But to actually be of service, the ODA developer must design a so-called "Dialogflow". This is the model behind the interaction between the skill and the user. A dialogflow defines the sequence of steps and the logic the chatbot follows to process a user's request. It includes the questions the chatbot asks, the answers it expects, and the actions it takes based on the user's input. The dialogflow keeps track of the conversation context, so the chatbot can provide relevant and coherent answers, even if the user changes the subject or asks additional questions. With the visual designer, the logic can be developed, where the conversation is visually represented, and the developer can model the different decisions.

Finally, the Digital Assistant must be made available. This can be done through the so-called Channels. As mentioned earlier, the digital assistant can be accessed in various ways. For this article, we limit ourselves to the "Oracle Web" channel, which is specifically suitable for APEX integration. When creating a channel, a channelId is generated. This is important for configuring the settings of the Oracle Web SDK later.

APEX Integration

For APEX integration, the Oracle Web SDK is required, which can be downloaded from the Oracle site. Once downloaded, you need two files: web-sdk.js and settings.js. Before these files can be uploaded to your APEX application, two parameters in settings.js need to be adjusted. Namely, chatWidgetSettings. URI and chatWidgetSettings.channelId. The URI is the URL of the ODA environment without https:// and everything after com/. This URI can be found in the OCI environment Analytics & AI > Digital Assistant > Digital Assistant instance > Base web url.

And the channelId is created when the channel was created.

Now the files can be uploaded to the APEX application. The easiest way to make these files available in your application is to add them to the static application files. The application will not recognize these files by itself. For this, the developer can refer to the files in the User Interface Attributes under the JavaScript section by using:

  • #APP_FILES#settings#MIN#.js

  • #APP_FILES#web-sdk.js.

Now the files are added to the application, and the init function must be added to the page where the chatbot should work. By adding initSdk('Bots') to the "Function and Global Variable Declaration" of the page, the chatbot widget is loaded on this specific page.

When the page is executed, a button will be shown at the bottom right, and the user can ask questions to the digital assistant.

The settings.js can be further expanded with numerous options to enhance the user experience, too many to cover all. Some worth mentioning are:

  • chatTitle and chatSubtitle set the title and subtitle of the chatbot

  • avatarUser and avatarBot can be set to show an icon next to the user's question and the chatbot's response

  • profile sets the user's profile. In the example below you can see that APEX variable can be passed to the ODA and used for a more personalized greeting

Conclusion

The integration of Oracle Digital Assistant (ODA) into an APEX application offers significant benefits for both users and developers. By leveraging artificial intelligence and machine learning, ODA can enable natural language processing, resulting in an intuitive and interactive user experience. The modular structure of ODA, with its various skills and trainers, allows specific tasks to be automated efficiently and accurately. The presentation during the NLOUG meetup demonstrated how this technology can not only increase the efficiency of business processes but also improve customer satisfaction by providing direct and relevant answers to various questions. With proper implementation and continuous training, ODA can be a valuable addition to any APEX application, enabling organizations to better meet the needs of their users.