JMJ CLOUD
  • Home
  • Projects
  • Blog
  • About Us
  • Contact Us

Our Blog

Talk to Your ERP with Alexa and ORDS

9/28/2017

0 Comments

 

Introduction

Picture
Oracle REST Data Services (ORDS) is a no cost option of the Oracle Database. It allows you to securely expose data in your Oracle Database via REST web services. ORDS is available on-premise as well as in cloud offerings such as Exadata Express and Database Schema Service. We have used ORDS to integrate on-premise and Cloud based ERP systems for years. It is a proven method of integrating with an Oracle database via REST. Sounds pretty useful right? Well, that is just the start, there are many other use cases for ORDS that reach into other technologies such as IoT (think receiving feeds from connected devices) and mobile (providing REST end points for native mobile Apps). In this post, I am going to talk about AI and how ORDS can be used to build an Alexa service based on data in your ERP (e.g. Oracle e-Business Suite and even ERP Cloud).

An Alexa Interaction

Before going too much further, it is worth spending some time to understand how voice services work. The diagram below illustrates a typical voice based interaction between an Alexa device and a back-end service provided using ORDS.
Picture
  • Your Alexa device is always listening for one of its wake words (Alexa, Echo or Computer).
  • Once Alexa hears its wake word, it knows it needs to pay attention to any subsequent speech.
  • It passes this speech to the Alexa Voice Service (AVS) in the cloud.
  • Amazon converts the speech to text and attempts to determine the skill that was requested based on the invocation name. In the above example, ‘Ask My Database’.
  • Once it recognizes the skill, it forms as structured JSON request and sends it to our ORDS REST end-point.
  • The proxy receives the request over https and then passes it on to ORDS via http.
  • ORDS determines which handler to carry out the request based on the URL called by Amazon.
  • The handler performs PL/SQL logic then returns a JSON response to Amazon.
  • Amazon turns the response into speech and instructs the Alexa device to speak the response back to the end user.
  • All this happens in less than a second. 

Anatomy of an Alexa Skill

I am sure most of you are aware what Alexa is, but what is an Alexa Custom Skill? Let's take a look at the Anatomy of an Alexa Custom Skill:
Picture
Invocation Name
This is phrase that Alexa uses to identify your skill as opposed to any other skill. The various components of a Custom Skill are also packaged into an Invocation when you define the skill in the Amazon Alexa developer console.

Intent Schema
A set of Intents (the Intent Schema). Represent the actions your user can perform with your skill
In our example, we have one which is "getDatabaseSessions". The intent defined here is passed into our web service and we will use this to determine what code to run to fulfill the intent.

Custom Slots
Slots can be thought of as a way to inject variables into the intent. In our example, we are including the session status that we want to inquire on. These will be called out in the JSON sent to our web service

Utterances
Utterances are what the end user will make in order to execute an intent. An utterance ties together the Intent and the Custom Slots (or variables). Alexa identifies the intent based on the utterances defined
Utterances are also used to provide variations of phrases users may use to invoke your intent.

 Other Considerations for an Alexa Skill

Picture
​Now we understand the concepts, what other considerations do we need to make when configuring our custom skill?

Testing
Once you have a working service, you will need to perform formal testing. Amazon provides several options including:
  • On-Line Simulator. Type your sample utterance into a testing tool provided by Amazon and see the JSON that passes from Amazon to your ORDS service and the response your ORDS service passes back to Amazon.
  • Unit testing on your Alexa device linked to your Amazon developer account.
  • Share your services with unit testers or other developers via developer account sharing.
  • Invite up to 2,000 users to beta test your skill using the Beta testing feature. 
​Security
Before publishing your service you will need to consider security for your REST service which, by necessity is exposed to the internet.
  • Secure your ORDS REST service by verifying the unique Skill Id that that is passed to you in the JSON payload.
  • For added security, use Account Linking which utilizes OAUTH to authenticate against your ORDS REST service.

Publishing
  • Submit your skill for certification and publication.
  • If you do not want your skill published, another option is to keep your skill in Beta testing mode where you can invite up to 2,000 users to use your skill. You can manage users access and revoke access when necessary. This may be a good option for corporate users who don't want their skill published to the general public.

Secure ORDS Web Service End Point
One of the last steps in configuring your skill is to provide the URL for your ORDS REST service. For this, your service must be running SSL:
  • During development, you can upload a self-signed certificate.
  • From Beta Testing on, you must use a certificate from a trusted authority.
  • Tip: Lets Encrypt provides free SSL certificates which work fine with AWS.

It's Time to Talk ORDS

Picture
Amazon requires a POST service to POST the payload it generates from the Alexa request to. This means creating an ORDS module with a template and a POST handler. Read this previous POST which talks about how ORDS services are structured to find out more.

At a high level, this is what your handler will need to do:
  • Parse the JSON payload sent by Amazon
  • Verify caller using the application id contained in the payload
  • Determine the intent and custom slot values
  • Run PL/SQL logic to fulfill the user's intent
  • Build a JSON response to send back to Amazon

Voice Enable Your ERP

With a history of delivering solutions for Oracle EBS and Cloud ERP, the team at JMJ Cloud have the ability to bring together the worlds of AI and Voice Services with the world of ERP. It's the possibilities of using these technologies together that excite me the most. Think about it, if you are using Oracle EBS, you have an Oracle database already. If you are using APEX and ORDS to extend EBS (if not then you should be) then the chances are you have all the architecture in place to host a REST service that can be used for an Alexa Skill. You now have the opportunity to introduce your business to the wealth of information stored in your ERP via a new medium, voice. 

"Alexa ask EBS for my daily financial briefing"
Think of the CFO who wants to get a morning briefing on the state the company's financials. He simply asks Alexa, which in turn calls an ORDS service to pull the data from EBS and respond with:
  • Your total revenue for yesterday was 1.2 million US dollars
  • Your current cash on hand is 500,000 US dollars
  • Your current open receivables are 200,000 US dollars
  • <this list is just about endless>

Don't Stop There

We are really just getting started, why not voice enable all of the things? Using the APEX_WEB_SERVICE API, you can call out to both REST and SOAP web services. Now you have access to any data that is exposed via a web service (which is just about all of the data). This allows you to build Alexa Skills that not only pull data from EBS but also consolidate it with data from other sources.

"Alexa ask HQ for my daily corporate briefing"
  • Current headcount is 12,000 (from your ERP Cloud HR system)
  • There are 200,000 US Dollars in open quotes (from your Salesforce system)
  • There were 2 reported accidents yesterday (from your in-house accident reporting system)
  • The US trade deficit with China grew by 2% yesterday (from a data.gov web service)
  • XYZ Corp was mentioned 2,000 times yesterday (taken from the company twitter feed)
  • <again, the list is just about endless>

Conclusion

As you can see, the potential is fantastic. Just as importantly, the technology is here, it works and if you are running an Oracle database (on-premise or in the cloud) you won't have to pay a dime extra to fulfill this potential.

​It's just another reason to consider APEX and ORDS, both no cost options of the Oracle database.

​This Blog Post was developed from a presentation I did at KSCOPE and Open World in 2017. You can download the full presentation here.
0 Comments

Your comment will be posted after it is approved.


Leave a Reply.

    RSS Feed

    Popular Posts

    - APEX Dog Food
    - Cloud ERP & APEX Mashup
    - Modernizing EBS with APEX
    - Easy APEX_WEB_SERVICE
    - Running APEX in RDS
    - ORDS What & Why?

    Categories

    All
    APEX
    AWS
    Fusion Cloud ERP
    INTEGRATION
    MS GRAPH
    OCI
    ORDS
    PaaS
    RAD
    REST
    SOAP

    Archives

    October 2021
    February 2021
    January 2021
    October 2020
    September 2020
    June 2020
    May 2020
    April 2020
    February 2020
    January 2020
    October 2019
    September 2019
    August 2019
    July 2019
    June 2019
    April 2019
    March 2019
    February 2019
    January 2019
    December 2018
    November 2018
    October 2018
    September 2018
    August 2018
    July 2018
    June 2018
    May 2018
    April 2018
    March 2018
    February 2018
    January 2018
    September 2017
    August 2017
    July 2017
    June 2017
    February 2017
    January 2017
    December 2016
    November 2016
    October 2016
    September 2016
    August 2016
    July 2016

Company

About
Contact
Blog
  • Home
  • Projects
  • Blog
  • About Us
  • Contact Us