Tuesday, November 2, 2021

#889 Leveraging OCI AI Language Service from Oracle Integration


Language provides you with the artificial intelligence and machine learning capabilities to detect the language in your unstructured text. Also, it provides other tools to help you further gain insights about your text.

First, a simple example of what's possible here - I enter a text for analysis - This is my second order for this product, it is really cool.

As you can see - a positive sentiment and rightly so our iBike is the best in the virtual world!
Now how can I invoke this from OIC? Imagine I have an order processing integration - the payload includes a comments field - where customer can open their hearts to us. Let's implement this in OIC.

Step 1 - create a connection to OCI AI Service

Invoking AI is just like invoking other OCI services from OIC. The connection setup is similar to that for Object Storage etc.

So I begin by cloning my existing Object Storage connection -

Naturally, I need to change the connection url - the AI url can be found here -


The Language API doc is here

All that I need to do now is fill out the missing details -

Step 2 - create an Integration to invoke the AI Service

Here are the request/response payloads for my REST based service -

There are a couple of APIS I can leverage here - 

e.g. DetectDominantLanguage - DetectLanguageSentiments

Let's go for the latter - the only payload required is a {text}

FYI - I copied the response json from the api documentation.

I now map the request comments to text an then activate / test -

So what does the result tell us?
Positive sentiment for the words product and bike.

Looks like a happy customer!

Let's try an unhappy customer - what would she write?

Only 1 "aspect" is returned for the word order. The happy customer comments resulted in 2 aspects - one for order and one for bike. So we can easily add a SWITCH to the integration and parse the sentiment(s) returned.

I set the integration Response as follows - 

I activate and test - 

Naturally, I could augment this scenario with an OIC Process which could be called for negative sentiments. A business user could read the comments and assuage the customer's fear - your order is not lost, in fact we are shipping it express to you. 

No comments: