Category: featured

Continuous Delivery – OPA and Postman, Newman and Jenkins #1

Continuous Delivery – OPA and Postman, Newman and Jenkins #1

For the first time in a while I was working to set up an example platform for testing purposes. Whilst a good portion of it is not specific to Oracle Policy Automation / Intelligent Advisor, it seemed both useful and appropriate to document some of the ideas, steps and conversation points in some posts here on the website. So without further ado, let’s get started. In this series we will look at setting up Oracle Policy Automation, Postman, Postman Runner, Newman and Jenkins to enable lights-out testing of REST batch or XML-based projects. Then, once we’ve done that, we will extend our reach to include HTML Interviews.

Firstly, let’s get a handle on the different tools in the kit. Postman, as many will know, is a visual client for testing REST APIs – at least that is what people know it for – but it is in fact capable of making any kind of HTTP call. Although the examples here will focus on the Oracle Policy Automation Batch API, you could use it for SOAP Assess as well.

Learn About Postman

Download Postman for Windows, iOS or Linux

To make a call to an Oracle Policy Automation Project, here are the prerequisites

  • The Project needs to be deployed
  • You need to have an API Client user and password
  • You need to be able to build a sample case.

So, let’s get started!

Assuming you have an Oracle Policy Automation Hub at your disposal, or someone who can sort you out with access to one, then you need to start with the creation of an account of type “API Client”. You will need to be given access to the determinations API, for at least the Collection (or “workspace” as it is now known) and then the account needs to be activated. It probably will look something like this:

Create User for Postman

  1. Go to Permissions > API clients
  2. Create a user and enable them
  3. Select at least the workspace where your project is deployed
  4. Save the user

Your project will need to be deployed in web service mode (not Interview mode, but if it is also used as an interview that’s fine too.

Check Project Deployed

So now you are ready to fire up Postman and get this show on the road. Remember that when using the REST api for determinations, you are going to be using OAuth2 as your authentication mechanism. This requires you to make a call first to an authentication URL, and receive a token. That token is valid for 1800 seconds, and must accompany any calls you make to your project. So, here is what you need to do in Postman:

Create a Collection. To keep things organized in Postman, put stuff in a Collection. Create one, give it a good name and then later you can put all your different Requests to OPA in this Collection.

Postman Collection OK

While creating your collection, you can set up the Authentication as well. This way, any Request you make that is stored in this collection can inherit the authentication method you define. It’s easier than doing it for every request (although that is also possible).

Postman Authentication Start

Select OAuth 2.0, Request Headers and then click the Get New Access Token button. Since this is the first time you have done this, you will now be tasked with filling in a detailed dialogue to explain to Postman how to go and get the magic “token” for Oracle Policy Automation. The screenshot is accompanied by comments below for each of the steps.

  1. Give the Access Token Authentication a name. You might have multiple Hubs and need to have different data for each of them, so a name is a good thing.
  2. Select Client Credentials
  3. Enter the address of the authentication endpoint. This is something like the address above (replace “http://localhost:7777/opa19d/” with your own URL to your Hub. Note that recently the Authentication URL has evolved, and it is now versioned. Check your version of the documentation to see if you can use the new URL format (“api/version/auth”) and gradually migrate all your calls to this new format, even if the old format works for now (this was introduced in version 20A).
  4. Enter the API Client you created or decided to use
  5. Enter the password you set up.
  6. Select Send client credentials in body
  7. Click Request Token

If everything went according to plan, you should see this:

Postman Authentication OK

Obviously, click Use Token. You are now ready for showtime. You have 1800 seconds to get your first request into Oracle Policy Automation!

Finish your Collection creation (we will be using the other features of the Collection later, in the other parts of this story). Create a new Request and save it in the Collection.

Let’s assume you have a Project ready to go. If you don’t the project I’m using in this demo can be downloaded here. The Body of the request (using Raw JSON as your format) would look something like this:

{ "outcomes": [
"b_success",
"resultstepnumber",
"resultstep",
"totaltime"
],
"cases": [
{
"@id": "1",
"origin": "Miromesnil",
"destination": "Oberkampf"
},
{
"@id": "2",
"origin": "Grands Boulevards",
"destination": "Concorde"
}
]
}

This assumes your project has a boolean to indicate success and some other attributes (in my case, the step number, the step and the total time. This project calculates the time to travel between two Paris Metro stations, in the days before confinement and lockdown. There are two cases to be tested. They are based on two attributes, namely origin and destination.

The output should look something like this:

{
"cases": [
{
"@id": "1",
"b_success": true,
"totaltime": 42,
"theresults": [
{
"@id": 0,
"resultstep": "Miromesnil",
"resultstepnumber": 1
},
{
"@id": 1,
"resultstep": "Saint Augustin",
"resultstepnumber": 2
},
{
"@id": 2,
"resultstep": "Havre Caumartin",
"resultstepnumber": 3
},
{
"@id": 3,
"resultstep": "Auber",
"resultstepnumber": 4
},
{
"@id": 4,
"resultstep": "Opéra",
"resultstepnumber": 5
},
{
"@id": 5,
"resultstep": "Richelieu Drouot",
"resultstepnumber": 6
},
{
"@id": 6,
"resultstep": "Grands Boulevards",
"resultstepnumber": 7
},
{
"@id": 7,
"resultstep": "Bonne Nouvelle",
"resultstepnumber": 8
},
{
"@id": 8,
"resultstep": "Strasbourg Saint-Denis",
"resultstepnumber": 9
},
{
"@id": 9,
"resultstep": "Réaumur Sébastopol",
"resultstepnumber": 10
},
{
"@id": 10,
"resultstep": "Arts et Métiers",
"resultstepnumber": 11
},
{
"@id": 11,
"resultstep": "Temple",
"resultstepnumber": 12
},
{
"@id": 12,
"resultstep": "République",
"resultstepnumber": 13
},
{
"@id": 13,
"resultstep": "Oberkampf",
"resultstepnumber": 14
}
]
},
{
"@id": "2",
"b_success": true,
"totaltime": 12,
"theresults": [
{
"@id": 0,
"resultstep": "Grands Boulevards",
"resultstepnumber": 1
},
{
"@id": 1,
"resultstep": "Richelieu Drouot",
"resultstepnumber": 2
},
{
"@id": 2,
"resultstep": "Opéra",
"resultstepnumber": 3
},
{
"@id": 3,
"resultstep": "Pyramides",
"resultstepnumber": 4
},
{
"@id": 4,
"resultstep": "Madeleine",
"resultstepnumber": 5
},
{
"@id": 5,
"resultstep": "Concorde",
"resultstepnumber": 6
}
]
}
],
"summary": {
"casesRead": 2,
"casesProcessed": 2,
"casesIgnored": 0,
"processorDurationSec": 0.04,
"processorCasesPerSec": 45.45
}

For the sake of space, I’ve cut this off before the end. But you should be getting the idea. The output is the time taken, and the steps from the origin to the destination. There are some stations on my map which are inaccessible (because I didn’t fill in the entire map of the Paris Metro) so the boolean tells me if the route is possible, and the total time is also shown. Now that we have the basic setup, in the next part we will add

  • A test script to calculate average response time
  • A test to see if the route is possible
  • A command line to be able to run this without Postman

See you in the next part!

Extension Code Generators for JavaScript

Extension Code Generators for JavaScript

Over on my other home (https://siebelhub.com) we use and promote the use of Code Generators : because most of the JavaScript people need to create is in fact very structured, because of the underlying extension architecture. You don’t write just any code, you write code the way you have to write it. So how to write Extension Code?

[Update 1 November 2018 : I added fullCustomInput as an option. I also added more explicit logging – so if you use multiple files you can see which is doing what. I also tidied up a few things]

It struck me the other day that this is equally true now for Oracle Policy Modeling – JavaScript extensions have a very well defined structure, and as I said above : you don’t write just any code – you write it the way you have to write it, in order to fit into the underlying architecture of our beloved interview.js.

Since I find myself often repeating the same JavaScript task over and over again – for example I need to create 2 custom Labels for 2 different projects or customers – I do a lot of cutting and pasting. But that often goes wrong as I forget I’ve renamed something or changed a variable somewhere.

So I decided to create a Code Generator – a sort of tool to create templates of code that I can use to create new files. And I decided to use Oracle Policy Automation for the job. Here is the sort of thing I am talking about:

Extension Code

By answering a few questions about the code you want to write, the Project generates a template for you to copy and paste into a new Text File and there you have your code to start writing something interesting. There is a Copy to Clipboard button at the bottom of the code.

In the end, I decided to add a few things to the examples to act as learning tools:

  1. The Input Control has Validate and Update options that help understand the way these Keys actually are supposed to work. Validate throws an error message to the user if the text entered does not match a specific validation rule.
  2. The Update Key shows how update is fired whenever anything on the Screen is updated. Useful for updating your Control in response to other activity on the Screen. As an example, the color of the Input changes each time Update is fired.

The Extension Code Generator also includes the custom Search as templates with the following options:

  1. Search lets you choose from a series of standard searches (Airlines, Railways Stations, etc) as well as allowing you to configure your own REST call and lets you add any Headers you need to make your call.

Here is a video that will hopefully shed some more light on what this Project does (or tries to do)!

This seemed like a fun thing to do in Oracle Policy Automation – if you would like a copy of the (18C) project then please leave a comment and I will tell you all about it’s foibles :).

Oracle Policy Automation & Siebel #1

Oracle Policy Automation and Siebel Innovation Pack 16 #1

Oracle Policy Automation and Siebel Innovation Pack 16 : Tutorial Part OneFor some considerable time now, the good people at Oracle have made available a White Paper describing an alternative integration to Oracle Policy Automation and Innovation Pack 16 integration (as opposed to the Siebel Innovation Pack 15 approach involving a good deal of HTML and so forth, and not supporting some of the new screen layout features and dynamic elements of Oracle Policy Automation).

The white paper is clear enough on the concepts, and some of the screenshots are excellent 😉 but I am often asked about the details of the setup and implementation. In fact it is something I have to do quite often anyway. So I thought I would publish here some content that shows how Oracle Policy Automation and Innovation Pack 16 can work together.

This content is obviously a mixture of technical and functional, and by definition quite “Siebel-oriented” but I figured it would be of interest here as well, since we all might find ourselves in projects where the two behemoths meet. And I suppose that even someone who just wants to figure out how Oracle Policy Automation connects to “something” might find it interesting as well.

A word of warning : these videos were recorded “live” without editing – or at least without much editing – so there are “troubleshooting” sequences where I do something wrong and then go off and fix it : I figure that keeping that stuff in makes for a bit of “reality TV” so you can maybe gain time yourselves when you get into similar problems. Oracle Policy Automation and Siebel Innovation Pack 16 integration sometimes takes a bit of getting used to.

Finally, in case you were wondering, this is also the foundation for the Oracle Policy Automation and Siebel 16 Workshop that I run from time to time. So, to keep the post from becoming too long, I am going to publish this in several parts. The first part (this post) looks at the various options, the different functional scenarios and the technical approaches that we might encounter in Oracle Policy Automation and Siebel 16 environments. The next post will continue the process.

Welcome to the Videos

What will you need : an Introduction and some Prerequisites

Getting Oracle Policy Automation and Siebel 16 Connected : Part One – Design Time

Next…

In the next post in a couple of days, you will continue to learn about the Connection and test the first two operations using SOAP UI, before you move on to the core of the integration.

Oracle Policy Automation Public Cloud with Oracle Service Cloud #1

Using Oracle Policy Automation Public Cloud with Oracle Service Cloud

Introduction

We are continuing our Lazy Expert series of posts, with an explanation of how OPA Public Cloud, and the rulebases deployed there, can be used within the Oracle Service Cloud application. In case you have missed out on our first part of this series, you can find it here. With the right Nudge, our Lazy Expert is not so lazy after all.

One of the earliest pre-built connectors for OPA comes from the Oracle Service Cloud Service, to connect with an Oracle Policy Automation Public Cloud Instance. Since then, we have seen multiple releases of this connector and each subsequent release improves the functionality available with the OPA Public Cloud Service, as well as how it is used together with the Oracle Service Cloud Service. For the rest of this content, we will be referring to these applications as OPA Cloud and Service Cloud respectively to gain a few centimeters of white space.

OPA Runtime Nudge (Trigger) Possible Scale of Invocations / Volume Typical Application / Solution Architecture Use by Service Cloud
Policy Hub (OPA Public Cloud) HTTP(s) URL based invocation of the Interview Service 100s of Thousands of invocations a day OPA Policy Hub, as another Web Application, provides the Interview Session screens using the UI as configured by the rule author.

 

This Assessment wizard can be made available within the “Agent Desktop” for the agent who is providing assisted service as well as embedded into the “Consumer Portal” for the consumer who is interested in achieving self-service.

 

It is possible to pass additional parameters through the URL, pre-load the Interview session with data from Oracle Service Cloud application and,

 

Persist / Save the data back into the Service Cloud application itself on completion of the interview and an appropriate assessment is made by our expert.

OPA RightNow Connector is a special implementation of the Web Service Connector architecture provided by OPA Policy Hub.

 

This “Connector” connects to a Service Cloud Instance as a data source and supports pre-loading and saving of data to / from the connected Service Cloud Instance.

For those of us trying to figure out the inner working of this connector, we will be using the sample rulebases provided by OPA Cloud. The complete list of example projects for the (freshly minted) Nov 2016 release of OPA can be found here. Such a hands-on exploration works best if you know both the applications well enough to administer and configure them, or spend some time together as a team that has the collective knowledge of both the applications.

The sample rulebase we use for this post is “RightNowSimple”. This is a fairly simple project that can be used to test the connectivity with the Service Cloud Instance from OPA Cloud and without making any changes to the Service Cloud Application. The supported objectives of this rulebase are

  • To collect the basic user profile information and their opt-in preference for marketing emails
  • If they opt-in, and only if, then collect the additional email address information
  • With the collected information and preferences, create a new “Contact” Record and the associated follow-up “Tasks” to be performed in the connected Service Cloud Instance.

Pre-requisites:

  1. OPA Cloud Instance provisioned with the necessary connection to the Service Cloud Instance. This is an improvement from earlier versions in that Oracle, along with provisioning the OPA Cloud Instance, will also perform some of the initial setup tasks needed to connect to a Service Cloud Instance from OPA Cloud. If this is all done correctly during provisioning, you should see the following entry in the “Connections” tab of the OPA Policy Hub administration site. The green check mark against the Oracle Service Cloud Connection signifies that the provisioning is all done correctly and that the Oracle Service Cloud connection is ready to use. Please also note the use of the SOAP service end-point for the associated Service Cloud Instance.

Oracle Policy Automation Public Cloud

  1. The new Permission model in OPA Cloud allows for “Collections” to be created, for the purpose of grouping rulebases and granting permissions to users at the Collection-level. In our case, we created a collection named “Service Cloud Collection” to group all the rulebases related to Service Cloud. If this is not available, you can always use the “Default Collection”, which is made available by default in OPA Cloud. Also the OPA Cloud Admin can specify which connections each of these collections will have access to. You will further see its impact when we are ready to deploy the rulebase.
  1. Oracle Policy Modeling Version 2016 is installed on your local machine with all its pre-requisites like Java RunTime Environment and Microsoft Office Word and Excel. Note that the Java RunTime requirement is now for version 8.

Explore the RightNowSimple Rulebase:

  1. Open Oracle Policy Modeling Nov 2016 release
  1. Click on “Example Projects”, search for RightNowSimple and select the project to create the local project on your default Projects folder.
  1. Review the Rules.docx rule document and the Data tab for the included entity model, its usage of Inferred Entity Instances and application of additional reasoning with the inferred entity instance attributes.
  1. Review the Interview screen design and its usage of rules for Screen Visibility (for “email address” Screen) and Screen Control Visibility (for “Interview Complete” Screen).
  1. Review the Data Model for the entities “Global” and “the task”, their containment relationship, their respective mapping to “Contact” and “Task” entities of Service Cloud, their attributes and public “Names” for those attributes, “Mapped Out” attributes for all the inputs being sent to “Service Cloud” and the “Mapped In” attributes for the outputs being received from Service Cloud.

 

Oracle Policy Automation Public Cloud

  1. As per the above rulebase configuration, when the Interview is saved / submitted, a new contact record and the associated follow-up tasks are created in the Service Cloud database.

Deploy and run the RightNowSimple Rulebase

Let us now deploy this RightNowSimple rulebase to the OPA Cloud Policy Hub, using the Service Cloud Collection that is now available in the Policy Hub.

  1. Connect to the OPA Cloud Policy Hub using the appropriate admin credentials for your instance.
  1. Update the Connection used by the RightNowSimple rulebase, to make it ready for deployment.

Oracle Policy Automation Public Cloud

This can be done by clicking on the “Mapping Settings” in the tool bar or the “Global” Entity to open the “Mapping Settings” dialog, changing/selecting the Service Cloud connection used by the rulebase and then refreshing the “meta data” that is made available through this Service Cloud connection. This meta data is required to accomplish the necessary mapping between the OPA Entity model and the Service Cloud entities.

  1. Deploy a Snapshot / Activate the rulebase on the OPA Cloud Policy Hub, using the appropriate Policy Hub Admin credentials for your OPA Cloud instance. For a quick deployment and test of the rulebase, make sure that the “Activate Immediately” check box is selected and deploy. Note Down the URL.
  1. Once the deployment is complete in the previous step, you will be able to copy the Interview launch URL for this rulebase. Go ahead and launch run the interview session with any input you would like to use and complete the Interview as per the instructions provided on the screen.

Verify the results in Oracle Service Cloud:

  1. The New Contact ID displayed on the summary screen, on Interview Completion indicates that the connector worked behind the scene, using the mapping configuration modeled in the rulebase, and created the contact record in the Service Cloud instance.
  2. Now login to your Oracle Service Cloud instance to verify the new Contact record created and the associated tasks, as inferred in the rulebase. Also compare the mapping settings in the rulebase to the actual filed values that are now inserted into the Service Cloud Instance.

Oracle Policy Automation Public Cloud

With this detailed background, check this space when we will continue next with part 2 of this blog that focuses on embedding such interview sessions into the Consumer Portal of Oracle Service Cloud.

 

Worldwide
Logo by Southpaw Projects LLC