IBM ADS Automated Decision from zero to a published REST Service

Aleksandr Khalikov
8 min readApr 15, 2021

--

Image belong to IBM Company

Not long ago I started playing with one of IBM’s tools for Decision Automation and here I would like to publish a short instruction of how to begin developing in it and at the end get a REST Service that you can call from any system as an endpoint (I’ll use Postman).

First of all what is Automation of Decision making?

It is a modern practice of automating most of everyday tasks which contain some kind of business decision. For a bank that can be a loan approval, for insurance company that can be a personalized offer based on clients insurance data. All automated decisions are implemented as decision services. There is a way to store all business logic in a code of a web service, but in an enterprise scale this becomes too sophisticated.

That’s where IBM Automation Decision Service (aka IBM ADS) comes in handy.

IBM ADS is a component of IBM Cloud Pak for Business Automation that allows you to develop an entire solution from scratch to a web service that can leverage predictions from Machine Learning models and that can be done without a line of code, using only a web browser of choice. I’ll show you how.

You start from IBM Business Automation Studio.

IBM BA Studio home page

Here you need to click on Automations (Yes, there are other buttons, but that is out of scope of this article)

Click on this

Now you need to create a Decision Automation. Give it a Name and an optional Description.

I called mine “TitanicProblemAutomation” because in the future I want to implement a Web Service that will recommend buying or not buying a ship ticket based on customer data and Survival Probability that will be received from a Machine Learning service that is implemented externally (it will be a neural network for one of that basics Kaggle Titanic problem). For now let's just implement it without ML.

Next you’ll see 5 tabs:

  • Decision services
  • Load changes
  • Share changes
  • View history
  • Deploy

Click on that blue button that says “Create” to create a decision service. Give it a name and an optional description. I called mine “Titanic Passenger Survival Probability Service”.

Next you’ll see another 4 tabs:

  • Decision models
  • Predictive models
  • Data models
  • External libraries

We will start with creating a Data model. Click on Data models tab and then click “Create”. I called mine “Data Description”. Next you need to create the Data model itself on the “Modeling” tab. Just click on that blue plus sign:

Let's take a look on my Data Model:

Data Model description

There are 7 Data types:

  • Baggage (complex type)
  • Baggage Size (enum)
  • Coupon Code (enum)
  • Passenger (complex type)
  • Ship description (complex type)
  • Ticket (complex type)
  • Ticket Class (enum)

Let’s take a look at Passenger data type that has 5 attributes:

  • age
  • first name
  • gender
  • last name
  • coupon code
  • ticket
Passenger data type description

You can add as many attributes as you need. All attributes can be implemented as a List. Upper you can see how you can refer to Passenger and all of its attributes in a verbalized way. You can change that verbalization if you need.

Let get back to “Titanic Passenger Survival Probability Service” and create a couple of Decision models. As usual to create something click on blue plus button. I called mine “Survival Probability” and “Coupon code tickets”. Here comes the idea of decomposition of your decision. You can implement your solution as a combination of multiple Decision model to simplify business logic. In this case “Coupon code tickets” will calculate the price of a ticket with a promo code discount. Let’s take a look at it:

Coupon code tickets Decision model

In IBM ADS you’re composing a decision model with decision nodes of different type. Green nodes represent an input data. Here the input data are a Ticket and a Coupon Code. These Data types were created in the Data model. Blue nodes represent Decision nodes, that consist of Business Rules or Decision Tables, where you describe your business logic. You can see below each node and its output data type.

Let’s take a look at Final Ticket price Decision node:

To add Business Rule or Decision Table, click on “Logic” tab next to “Details” tab and then click on blue plus. I’ve created a Decision Table named Calculate Ticket Price.

Calculate Ticket Price Decision Table

Basically it multiplyes the price of a Ticket by Coupon Value. Right-click on the right column to edit its business logic as shown below

Now let’s get back to “Survival Probability” Decision model. You can see its structure in picture below. There are 2 nodes at the bottom: Passenger description data with a Data type of Passenger and Coupon code tickets Decision model with a Data type of Ticket, a Decision model that we implemented above. These nodes are input for “Final ticket price” Decision node. In IBM ADS you’re working only with needed information. That is another way to simplify your development. First you choose what will be input and output, then you implement business logic. Input and output arrows can be attached by drag and drop.

“Final ticket price” Decision node have one Business Rule named “Calculate ticket price” that is implemented as shown below:

What is great about IBM ADS is autocompletion. You only need to press space on your keyboard and just choose what you want to see in your Business Rule or Decision Table as Business logic. That is way simpler for a business user, because you don’t need to remember ADS syntax.

Autocompletion of Buseness Rules

Let’s just briefly look at the other two Decision nodes and move forward to the last paragraph of this article. “Survival Probability” node contains one Business Rule in it called “Evaluation of survival probability”

and “Recommendation to sail” node got “Suggestions to sail” Business Rule in it:

For Business logic that’s it. Now let's test it and deploy after. Get back to the diagram and click on “Run” tab:

Run tab is for testing

I’ve created test data with that blue plus button. You can either edit it as Form or JSON

{
"passengerDescriptionData": {
"age": 22,
"first name": "Karl",
"gender": "male",
"last name": "Black",
"ticket": {
"class": "Budget ",
"price": 650
},
"coupon code": "BlackFriday"
}
}

Now click big blue button that says “Run” with Play sign on it. You’ll see the result that also can be viewed as Form or JSON. Now when everything has been tested and is working we need to deploy and expose our service to be able to call it as a REST endpoint. Click here to get back to TitanicProblemAutomation:

First you need to connect to Git repository to be able to share your project somewhere. To do it click on Project settings for Git in top right hand corner. I hope that you can find how to connect to Git by yourself.

Now go to “Share changes” tab, choose what you want to share on Git. In our example just choose everything and click “Share” button. That's it, your project is on Git.

Next click on “View history” tab to create a Version. In my case it’s version 1.0

Next click in “Deploy” tab, choose a version you want to deploy and click “deploy”. You will see something like this:

Now on the home page where you started you can see that your Automation Service is published.

That’s basically it 😁

Now you can look at your Automation Service in Swagger and call it from Postman. Let’s take a look how to do it.

In your published service you’ll have 2 operations: couponCodeTickets and survivalProbability. You need to get an access token to authorize in Swagger and Postman. Go back to Deploy tab, then in Developer menu of your browser click on Web inspector, then go to Storage Inspector, then go to Local Storage and copy the value of access_token (IBM documentation on that. Step 6)

Following IBM documentation our decisionID should be like this:

decisions/titanicproblemautomation/titanic_passenger_survival_probability_service/titanicPassengerSurvivalProbabilityServiceDecisionService/1.0/titanicPassengerSurvivalProbabilityServiceDecisionService-1.0.jar

Now you can execute it in Swagger:

And at last let's go to Postman.

Basically you already got all you need. You need and Endpoint URL, access token and Request body (look at Test data as JSON).

That’s it 😁

You’ve just implemented an Automation Decision service as a REST service without a single line of code.

Hope that was helpful and interesting. Thank you for reading this.

--

--