Watson Assistant Chatbot for SAP Cloud Platform
Chatbots are being used in many business scenarios, within companies, interfacing clients and integrated with SAP backend systems. As a self-taught developer and architect with IBM I really like to build simple prototypes for my clients and the developer community to show the basic principles (see this example) of chatbots and other use cases. Most of them leverage the IBM Cloud and consist of:
- run-times for the application logic like Node.js, Cloud Functions (IBM’s serverless computing platform) or the low-coding platform Node-RED,
- AI services (Natural Language Processing), and
- a frontend (Node-RED, Vue.js, chat platforms).
For developers there’s much content available to get started with the IBM Cloud (e.g. on IBM Developer), but in this post I really wanted to describe a hybrid SAP/IBM chatbot scenario, which can help developers – including ABAPers with limited cloud-native background – integrate both worlds and get perhaps an inspiration for a side project.
Luckily the SAP Cloud Platform has – like the IBM Cloud – an Application Runtime service that is based on the open-source application platform Cloud Foundry. So I thought, why not get an existing tutorial, deploy it on the SAP Cloud Platform and interact with the IBM Cloud in one way or another. I tried out a relatively simple scenario, which I now want to share in my first blog post on SAP Community. I think it’s not too complicated, but if you want to try it out yourself, some basic knowledge of Node.js, npm, git and Github, and conversational systems is needed. If not done already, you’d need to install Node.js, npm and git on your machine, of course. Also, it is assumed that you have an SAP Cloud Platform and an IBM Cloud account and installed the respective CLIs.
Building the Chatbot
Artificial intelligence, conversational systems, cognitive assistants etc. are important topics for developers to master. In this post you learn how to easily build a chatbot on the SAP Cloud Platform. The IBM Watson Assistant service is an AI service to create those systems which I used in tutorials and hackathons before. It can be connected to a variety of frontends and chat platforms. This time I used a sample application based on Node.js and the Express framework, because it also has a nice web frontend that can be deployed to the SAP Cloud Platform. I modified the assistant-simple code slightly so the Node.js app could be deployed on the SCP and use my own Watson Assistant service.
My first step was to create a Watson Assistant service by importing an existing skill (JSON file) on the IBM Cloud. This is straight-forward as the figure shows.
You could now adapt the skill by modifying the intents, entities and the dialog. I then used the built-in Try it function (upper right corner) to see, if the dialog works properly and voilà – I had a running chatbot using the built-in test interface. The next step was to build the web app running on my laptop.
- I cloned the repo to my local machine using git,
- modified the environment file that contains the variables for my own project (API key and URL of the Watson Assistant service),
- installed the Node.js dependencies, and
- ran the app locally using npm.
The animation shows the dialog. Note, that both animations in this blog stem from the original repo, but they nicely show, how it works:
Lastly, I used the Cloud Foundry Command Line Interface to push the local code to the SAP Cloud Platform and deploy it there. Again, this went flawlessly as expected and I could access the frontend URL from my browser. The name of the app (defined in manifest.yml) needs to be unique as it is part of the domain name of the URL. In my case I was the first to use it (watson-assistant-simple) on SCP, but it should be modified, if the domain name is already taken by someone else.
This demo shows how to easily adapt and deploy Cloud Foundry applications on different cloud platforms and how to consume services from other platforms via REST APIs. More advanced use cases are possible, of course:
- it should be possible to use Fiori as a frontend,
- programatic calls of external systems can make the dialog more dynamic (Watson Assistant has a webhook interface for that), or
- if you want to use Watson services integrated with ABAP, you might have a look at this blog.