Integration Of Sap CAI Chatbot + Amazon Alexa with R3 Corda Blockchain
Tags: Amazon Alexa, Chatbots, Corda, Sap, Blockchain

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 Chatbot with Amazon Alexa skill and use the Corda Auction API to interact with our chatbot.

Check out my last article about Sap RPA and Corda Integration, if you want.

R3 Corda Installations

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.

Now 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 work on Corda or 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 CAI Chatbot.

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 CAI Chatbot 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 api from outside.

SAP CAI Chatbot

First of all, we go to the Chatbot application from the link below. If we have a Sap account, we can log in with it. If not, we can create an account from scratch and try the chatbot product for free.

cai.tools.sap

1- We start to create a new bot with the new bot option on the screen that opens.