Tuesday, August 14, 2018

#647 OIC Insight REST API

I have already done some introductory posts on Insight.
I suggest you review them now, if you are unfamiliar with this component of OIC.

Introduction to Insight in OIC - click here

Introduction to Insight - click here

The first post mentioned covers instrumenting an OIC Integration for Insight.
Essentially, I map certain Invokes in the integration to Insight Milestones.

But what happens I want to instrument a business process for Insight?
Currently Oracle does not provide such a mapper.

What we can use though is the Insight REST API.

Here is a simple example -

My integration processes an order and then calls a business process to do the necessary human approvals.

The integration is as follows -

The processing logic is very simple -
1. Check if the customer exists
2. If the customer does not exists, send the order for fraud investigation
3. If the customer is kosher, then create the Order in the ERP system and call a business process
to do the human approvals necessary.

The business process is as follows -

Bear with me for a while on the black boxes!

The logic is very simple -
1. Orders for €100 or less are auto-approved.
2. Larger orders are sent for human approval
3. Rejected orders are reviewed by a manager

So now to the model that will give us insight in to what is going on here -

Milestones 1 to 3 will be set via the integration.
Milestones 4 to 8 will be set via the business process.

The business process will call a separate integration that will leverage the Insight API
to update the milestones for a particular order.

Let's look at how simple it is -

I just checked the checkbox.
I see the actual url and payload, when I click on the info icon.

So we have this generic event operation -
The payload is as follows -

  "modelId" : "NCOrderProc_i4dFFzz8",
  "correlationValue" : "",
  "milestoneId" : "OrderAutoApproved",
  "eventTime" : ""

You see the modelId value, which specifies the Insight model I want to use.
The correlationValue is a unique key that can be used to identify this order as it moves through the
integration and business process. In my case, the orderNr field.
The milestoneId identifies the milestone I want to update for this particular order.

The eventTime is optional, so I will let Insight take care of that.

I now test this REST request using Postman -

Note the response -

    "type": "ok",
    "message": ""

I now create a new integration that calls this service -

The REST trigger request payload is as follows -

  "modelId" : "NCOrderProc_i4dFFzz8",
  "correlationValue" : "",
  "milestoneId" : "OrderAutoApproved"

I now return to my Process and "import" the integration -

I now leverage this in my process -

The black boxes are revealed.
Let's look at one of these tasks -

I now test, by executing the first integration -

Firstly, a look at the Insight dashboard before the test -

Now to the test - order nr 123011

I approve the order -

great stuff!

One can drill down from the Milestones summary to the individual orders -

We can also get a detailed view on individual order progress -

And while we're here...

Note the Last 5 Days timeframe.
How can we change this?

One can also define which milestones should be shown -

No comments: