Integration Of Sap CAI Chatbot and Robotic Process Automation with R3 Corda Blockchain- Part:1

UMUT
13 min readSep 1, 2020

After the Sap Conversational AI and Robotic Process Automation training I received on opensap, I decided to make such an application. It was easy to apply and a very enjoyable integration. Again, as in my other articles, the subject appeals to those who do not have software knowledge. I tried to write in a way that would help anyone with an interest in the subject to understand more comfortably and create new cases.

Good readings!

Introduction

R3 Corda Blockchain platform is one of the most used Private Blockchain solutions together with Hyperledger Fabric. In this article, we will set up an “Auction” application on a Corda network and then create an API to access this network from outside. Later, we will set up on the SAP CAI and RPA (Robotic Process Automation) side and use the Corda Client API we created to trigger the processes in our “Corda Auction Network” application using “Sap Chatbot” and “Robotic Process Automation”.

Important Note: The content of this application is purely for learning purposes, and some complex processes including additional security mechanisms have been eliminated in order not to lose the integrity of the subject and to be understandable by everyone. It has been designed only to create ideas and to guide. It is not suitable for live use.

Why should I use “Sap Robotic Process”?

“Sap Robotic Process Service” perfectly reduces the labor cost in complex end user movements. For example, consider the end user transactions made in the Order and Delivery processes in our SAP ERP system. The completion of the processes makes all monotonous end-user processes, from their integration with Excel and external services, to be done in a few clicks without much coding. We can say that it is revolutionary with this feature.

In our example, we will easily manage a Blockchain application we created in the R3 Corda Network, which looks very complex, using Sap Robotic Process, and we will ensure that the transactions created in the Blockchain network are transferred to an excel file with a single touch using SAP RPA.

In addition, it is possible to use SAP RPA product with Sap AI Chatbot, another innovative product of SAP. We can integrate an RPA process that we have created into a Chatbot that we have created specifically for ourselves and trigger all processes from there as simply chatting.
Note: In this article, I will explain the two processes by breaking them apart. Because in the trial version, we cannot communicate the Chatbot and RPA product. For those who have a Sap Global Cloud account, I will show you how to do it, and they can try this method themselves.

So in this case, we will have two examples when the article ends.

1- SAP RPA and R3 Corda Integration
2- SAP AI Chatbot and R3 Corda Integration

As I said, we have the opportunity to link these two samples together very easily, but it was not possible to do this with the trial version we have.
Maybe it will be positive if we separate these examples in this article for the subject to be understood easily.
However, in order to get full performance from these products, I suggest you try to use an RPA process you have created by integrating it with the SAP AI Chatbot.

Build Your Case To Simplify The Process In Your Mind!

1- Analyze the complex movements of end users within products such as SAP S / 4 HANA or classic ERP.
2- Using the analysis you extracted, automate the process through Desktop Studio.
3- Integrate its relationship with external services connected to this process into RPA.
4- Then manage your RPA application with Chatbot.

As a result, you will have created a tremendous product that you can apply to all end user processes you dream of in the Sap products you use. Moreover, the manpower you will spend to create this will be less than you think.

SAP Installations

Sap Cloud Platform Trial Account Setup

Here we will reference previously written articles for the main setup process. If we do not do this, the article will be too long and we will be away from our main subject.
You can use this resource for Sap Cloud Platform Trial Account Setup steps.
After getting our Trial Account membership, we can continue from the step below.

Sap Robotic Process Automation On-Premise Installation

First, we go to https://tools.hana.ondemand.com/#cloud and download the appropriate package from the list below.

After downloading Sap RPA On-Premise Package, we need to install two separate applications as Desktop Studio and Desktop Agent.

Desktop Studio: We will use this application to design and manage our processes.
Desktop Agent: We will use this application to run and test the processes we created in Studio.

After the download is completed, the second option, “Desktop Studio”, is closed on the screen that appears below (X). We need to click the small arrow at the end of it (X) and select the option to save it locally and start the installation.

After the installation is complete, Desktop Studio and Agent setups will be completed. However, in order for these applications to work properly, we need to have a SAP Cloud Platform account and do some authorization on the Cloud.

Important Note: SAP RPA is a Sap Cloud product and needs Cloud structure to use it. Don’t be fooled by the Desktop Agent and Studio we set up as On-Premise in this sense. Our Agent here actually functions as a cloud connector and allows us to access our Sap Cloud account from our local device and use our Robotic Process services in the Cloud. In other words, these packages we download are not a service product in themselves, but merely intermediaries.
In addition, RPA Desktop Studio and Agent are currently working only on Windows, we will use Windows for SAP RPA Installations and MacOSX for R3 Corda.

R3 Corda Installations

R3 Corda is a platform that I have devoted a significant amount of time to lately and offers impressive solutions in the Private Blockchain lane, especially in financial cases. Therefore, while working on SAP RPA, the first thing I thought of was to integrate Corda and SAP RPA solutions. We have done successful work on Hyperledger Fabric and SAP ERP integration before, and I tried to proceed using the same logic here.

If we go into the technical details of R3 Corda in this article, since the article will be too long, we will go directly to the example. Those who want to go into detail can start here.

In order to set up and easily manage our R3 Corda sample, which we will talk to with our SAP RPA service, we first need to complete the first system requirements completely. We will install on Macosx, but you can follow the same steps on Ubuntu.

1- First of all, we install the infrastructures we need to run the R3 Corda solution with the latest version of VSCode, which makes it very easy for us to make our Corda improvements, from the links below.

JAVA 8 SDK
VSCODE
Git
Gradle

2- After installing VSCode, we install the following plugin, which is a plugin that will help us a lot while managing our Corda network.

3- Then we run mac terminal and download our corda samples package to our home directory.

$ git clone https://github.com/corda/samples-java.git

We are now ready to activate our R3 Corda network and run our Auction app on it.
In the samples-java folder we downloaded, we find the Auction-App folder in Advanced.

Important Note: In order for the Corda plug-in in VSCode to understand that this package is a Corda application, you need to make the right choice that includes the appropriate packages. If you show the Samples Java folder by saying Open Folder in VSCode and then try to go to the Auction break from it, you will have a problem using the plugin. Let’s do it as follows.

After opening the package, if you have not installed Java plugins and Gradle properly, it will give you some warning and VSCode will guide you to install these plugins. In this way, you can install Gradle. If you have installed the VSCode Corda plugin properly and you have shown the Auction-Cordapp folder correctly, you should have seen the Corda-Project assignment, which I marked in green below. This will show you that everything is fine.

From now on, what you will do to run this example will be surprisingly simple.
There are 3 main components pre-prepared in our R3 Corda sample.

  • Corda Network Infrastructure
  • Contract and Workflows to run on Corda Network
  • Our Client application that will allow us to connect externally to our workflows and smart contracts running on the Corda Network and the UI side of it written in Angular.

After opening our package in Visual Studio Code
By pressing Shift + Command + P we will view the features that Corda Extension offers us.

1- We are waiting to select and complete the transactions to activate our Corda network and deploy our nodes.

If the process is successful, you will see a screen like the one below. A, B, C and Notary Nodes have been successfully created.

Trading parties on our “Auction” Network are represented as Part A, Party B and Party C. Notary is the node that includes the consensus mechanism of our network, which is also the Ordering service in the Hyperledger Fabric solution, and is responsible for the approval and ordering of transactions. We saw that it was installed automatically when we run the .gradlew DeployNodes command via Extension.

2- The next step is to run these nodes that we deployed and for this, let’s use the extension again.

We do Shift + Command + P and this time choose Corda Run Nodes.
After running it, you will see that a separate terminal screen is opened for each node as in the VsCode terminal screen below, and each of the nodes is working independently from each other and ready to process.

You should see the screen below for each node.

What have we done so far?

We did the node setup and started our nodes.
Now the infrastructure of our Corda network is ready. Next, triggering transactions within the Corda network via the Client API. For this, we will make use of our Client subproject created before in our project.

Note: As I said before, I do not mention the details of our Corda project here, since the article is long enough, it will cause us to miss the outline. Those who want to go into details can start working from the links I direct. Those who want to work on Corda or SAP RPA in more detail, those who will take the certification exams, can also contact me on LinkedIn.

3- We will use our Corda Client API links to trigger transactions in the Corda network on SAP RPA.

Note: Normally, we can trigger this local api that we created via Cloud Connector and Sap Cloud Platform Destinations on Sap Cloud Platform. But this time I took a different path. By using NGROK, which provides us with a solution that developers will often need for testing, we will easily open our local API to the outside and execute transactions using this API link on the SAP RPA side.

At first, we will publish our api at http://localhost:8085. After that, we will open to the outside with Ngrok and we will have the ability to communicate from outside with flows in the Corda network.

Let’s follow the steps below to run our Client API and view our Angular interface on http://localhost: 8085.

We will open a new terminal screen and make the Client API working using the command below.

Mac:auction-cordapp umtyzc$ ./gradlew runAuctionClient

It does not matter if it is stopped at 94%. If you see the screen below. Now you can go to http://localhost: 8085 and upload the Demo Data to the system and manage your Corda Auction network through the interface.

By clicking Setup Demo Data, we can upload our sample data to the network to be used for the “Auction”.

After that, those who wish can make tests on the Corda network with this interface and view the logs of their operations on VSCode and some important information in a tidy manner using the Show Node Explorer option in the Extension as follows.

Shift + Command + P -> Show Node Explorer

Finally, to open our Corda API we created in our local network, let’s install Ngrok and complete the Corda process by getting our public link.

Let’s download and install the Ngrok solution from this link.

After the installation is finished, let’s open our API that we previously published in 8085 local with the following command.

Mac:~ umtyzc$ ./ngrok http 8085

Our new link is as follows. Now we can access our ap from outside.

SAP Robotic Process Automation Desktop Process Design

First we create a new project and name it as follows.

Then we come to the script section from the left menu, right click on an empty area, click on the include library script and select the “Excel Integration” package from there as follows.

After completing this process, we click on the workflow section from the left menu this time and right click on the GLOBAL tab in the menu that opens and create a new workflow. I defined his name as follows.

Now we will consider step by step the actions we made while setting up the process.

1- Connecting to an external service and extracting the data there (CordaAPI)
2- Running the Excel program,
3- Adding the data from the API to the new file created
4- Saving the file with a new name after the process is completed
5- Finally, release and close the excel

Let’s design the process through Desktop Studio as follows.
To add the activities to our workflow, simply select from the right menu and drag and drop.

First of all, let’s create Custom activity as follows, where we will write the code that will call our API, and create a context named CordaAPI Data by right clicking on the content section and saying Create New Item. Later we will use this contexti in excel. In this step, we only made definitions for Custom activity. We will integrate our code into it last.

After completing this process, we will add our workflow one after another according to the setup we previously thought as follows. Let’s find the appropriate activities from the activity section on the right and drag them.

Now it’s time to make the definitions we need in our activities such as set values, save as excel.
Let’s make the definitions as follows.
In the data section, we enter the CordaAPIData that we previously created as a context.
Start Row = 2 (because our api response will also be the 1st row headers)
Start Column = ‘A’.
This information may vary depending on the data source we will use. We configured it according to the response returned from our Corda API.
While saving, we told to create a file called CordaExcel in the Desktop.

— “C: \\ Users \\ dlkconsultancy \\ Desktop \\ CordaExcel”

After completing the above processes, we click the button marked with yellow below and do Build. Our scripts will be generated in the background and the program will be suitable for running.

We click the button below to access code blocks with custom activity and excel scripts that we previously generated.

Finally, we add the following code block into the Custom activity that we mentioned above in yellow. This code block will allow us to reach CordaAPI and print the information of the products that are auctioned in our Corda network in our excel file.

GLOBAL.step({ Custom: function(ev, sc, st) {
var rootData = sc.data;
ctx.workflow(‘ExcelWorkflowCordaAPI’, ‘e30ce5ce-fa1b-409a-a08d-01860629a73d’) ;
// Custom

ctx.ajax.call({
//daha önce Corda Apimizi dışarı açıp aldığımız url ve uzantısını //url kısmına ekliyoruzurl:”http://90a840d20449.ngrok.io/api/auction/list",
header:
{
“Accepts”:”Application/JSON”
},
async:false,
success:function(res,status,xhr){
rootData.cordaAPIData=res;
ctx.log(“success”);
},
error:function(res){
ctx.log(“error”);
}
})
sc.endStep(); // Initialize_Excel
return;
}});

We build again and run the project. After the project runs, Desktop Agent will be activated. After clicking the Desktop Agent icon in the application toolbar at the bottom right of Windows and selecting our project, we can now start monitoring what is happening.

Summary / Conclusion: The “Auction List” data from our API, which we created to access our Corda network from outside and opened to the outside via ngrok, was automatically saved to the excel file in our system in a single action.

Note: In this way, you can create services as you wish and integrate them into your UI5 program or to your favorite programs and processes such as Word, Excel and Outlook, you can connect them in a chain and trigger your RPA flows using only Chatbot, and you can integrate your end users into repetitive tasks that they waste time.

Easy to apply, limitless to imagine. With this logic, you can create many different projects.

Since this article is too long, I decided to explain the integration with R3 Corda and SAP AI Chatbot in Part 2 of this article.

Keep in touch. Stay well… :)

References

1- https://corda-certification.myshopify.com/products/corda-standard-certification-test

2- https://open.sap.com/courses/rpa4

3-https://github.com/corda/samples-java.git

--

--