The OCI AI Language is one of the many available OCI AI Services. They are a fantastic complement to many other services. This modular approach allows us to have a best of breed approach where we combine the services we need in order to build a robust fit-to-purpose solution.
In the context of the Oracle Digital Assistant, we can leverage many of the AI Language capabilities, with a special focus on Sentiment Analysis (but not only).
How to start?
The AI Language service can be used with several different methods (API/CLI/SDK/Console).
The idea is to package it as part of the ODA Custom Components, which will allow us to connect to this service. This will exclude Console+CLI for obvious reasons.
I will use the JavaScript SDK – The documentation even provides sample code.
Create a working code
My first step was to create a working code to call the Language Sentiment service. I started with the sample code and updated it accordingly.
Below is a working code that makes use of my local OCI configuration keys, authenticates, builds the sentiment request message, calls the service with input “I Love Football” , and outputs the response.
Below is the response. In this case we only have 1 word with a positive sentiment (99.9% certainty).
Create a Custom Component
Now we need to wrap this in a Custom Component (CC), so that ODA is able to make use of this service.
When it comes to the AI Language authentication, we should make use of a different method (not the configuration file approach). We can use Resource Principals (if we want to deploy a Function) or Instance Principals (in case we deploy it as a node in a K8S cluster). Please note that Resource Principal authentication will not work if you deploy the CC as part of the ODA embedded container.
You can check this post that covers the different authentication approaches.
You will need to adjust the previous code inside the CC framework. On top of that I do have some more logic to extract the relevant information from the response and then send that back to the dialog flow (not visible in the snippet below)
Deploying the Custom Component
At some other point in time I will write a post about how to deploy a CC to OCI Functions and the necessary OCI Policies for it. Meanwhile, if you need more info, check this great Design Camp session.
Adding the Custom Component to ODA
Adding the CC is very easy.
My CC has some services which I will call from the SKill.
Dialog Flow
I created a basic Skill to highlight the AI Language capabilities. The CCs are called like any other custom component.
aicheck:
component: "aisentiment"
properties:
text: "${input_message.value}"
transitions:
actions:
positive: "positive"
negative: "agent"
nosentiment: "nosentiment"
Sentiment Analysis
The Skill offers two sentiment analysis options. On the first It will highlight the positive/negative words, and if there are more words with a negative sentiment, it will handover the conversation to an agent (mockup)
The second option does the same, but it sends an email instead of the agent handover.
Let’s have a look at the first option.
The below sentence will return 2 words with negative sentiment, and will end up in the agent handover.
The AI Language Service provides much more detailed information, such as confidence scores for the sentiments, but I am simplifying things here.
In a similar fashion, I provide a positive sentence.
Detect Language
The Detect Dominant Language service detects 149 different languages.
This services detects the dominant language in the input and provides confidence scores as well. Again I am simplifying the approach here.
Lets try now a less know language!
Key Word Extraction
The Key Word extraction does exactly what it states, it extracts key words. We can use this for routing.
In this use case, we look at the key words in order to identify if the message should be routed to IT or HR Helpdesk.
These are just some examples of the possible use cases that we can explore with ODA + AI Language.