Oracle APEX Blog

Build a Chatbot on Your Lunch Break

Written by Craig Sykes | Jul 3, 2019 2:21:15 PM

I’m primarily an APEX developer, and one of the things I love about APEX is how I can create something impressive in such a such a short space of time. I can build an application in my lunch break to solve a problem or make someone’s life easier. This is not the case with many development tools, with most needing a lot of time investment before you get an end result.

If you’ve read any of my previous blogs or seen me present at a conference, you may have seen me talk about chatbots before. I’ve been looking into Oracle’s chatbot offering (now called Digital Assistants) in a fair amount of depth and I really think it comes close to APEX in the way that you can develop and deploy something impressive quickly. In this blog I’m going to show you how you can make a very basic (but relevant) chatbot in your lunch break (leaving you time to eat a sandwich).

Prerequisites:

  • An Oracle cloud account with a Digital Assistant instance provisioned (this can include the cloud trial)
  • Some pre-existing questions and answers – for this demo I’m going to use the APEX FAQs from our website: https://explorer.co.uk/faqs/

Step 1

You need to put your questions and answers into a .csv file in the following format:

questions category_path content
Who uses APEX?   The use cases for APEX range from spreadsheet replacement to enterprise systems used by thousands on a daily basis, via Forms modernization, EBS Extensions, APEX also runs Oracle Corp!
What is APEX?   Oracle Application Express (APEX) is a low code development tool for building web applications on the Oracle Database. APEX allows you to develop and deploy responsive web applications through a browser, either on premise or in the cloud using only a web browser.

Step 2

Within the Digital Assistant instance, create a new skill. You can call it what you like.

Step 3

Click on the Q&A tab and then click the ‘+ Q&A Source’ button. Fill out the form and upload the .csv file containing your questions and answers.

Step 4

Click ‘Create’ and then once the questions have been uploaded, click the train button in the top right. The Q&A option should be ticked. Don’t change anything, just press submit.

Step 5

Click on the Flows tab and paste the following YAML code into the code window. Then train again for good measure.

metadata:
  platformVersion: "1.0"
main: true
name: "explorer_qna"
context:
  variables:
    greeting: "string"
    name: "string"
    terminateChoice: "string"
states:
  qna:
    component: "System.QnA"
    transitions:
      actions:
        none: "unresolved"
      next: "qna"
  unresolved:
    component: "System.Output"
    properties:
      text: "Sorry, I did not find any match. Can you rephrase the question?"
    transitions:
      return: "done"


Step 6

Click the test button in the bottom left and try asking some of your questions. Hopefully the chatbot gives you the correct answers!

Step 7

Your chatbot is working now, but you need some way to show it off. There are loads of in-built options to allow you to expose your chatbot to the world. Click the hamburger menu, then channels and press the +Channel button to see what options you have. I’m going to go with Web for this example, but there are options to allow you to integrate with existing chat platforms or create your own UI.

Step 8

Create your channel by filling out the form, then select the skill you want to route to.

When you have done this, you will have an App ID and an App Token that you can use to connect your chatbot to the outside world. Click the ‘Channel Enabled’ slider on this screen and you’re ready to go.

Step 9

Seeing as we’re doing this during a single lunch break, we’re going to cheat a bit here. First you need to create an APEX application if you don’t have one already made. You can do this using apex.oracle.com and our previous blogs for guidance.

Next we’re going to turn to the APEX community to help us skip a few fiddly steps. Simon Boorsma has published a great Digital Assistant plugin for APEX available here: https://eocoe.blogspot.com/2018/12/apex-plugin-for-digital-assistant.html

All you have to do is read through his blog, then download and try it yourself. If you don’t want to use APEX to demo this there are loads of other options, but it might take you tomorrow lunch time as well.

Step 10

Install the digital assistant plugin into your APEX application and enter the Skill’s App ID, then the connection is made and people can use your chatbot. You can try mine here: https://apex.oracle.com/pls/apex/f?p=131622

You should now have a working chatbot. There’s no real conversational UI here, you have just uploaded some very simple questions and answers. The Oracle Digital Assistant technology goes so much deeper than this, but if you are interested then the Q&A functionality is a great place to start and there are lots of resources available online to help you expand this into a full blown chatbot.

 

 

Author: Craig Sykes 

Job Title: Senior Oracle Development Consultant

Bio: Craig is a Senior Development Consultant at DSP-Explorer. Craig has an MSc in Computing Science and is an experienced software engineer, utilising development tools such as PL/SQL and APEX to provide bespoke ERP software to both UK and international businesses. Craig has experience developing solutions to connect Oracle systems to a wide range of existing external applications within business environments.