SAP Conversational AI
Once SAP wanted to accelerate their SAP Leonardo ML learning on 2018, they acquired Recast.AI which was an artificial intelligence bot platform company. It was a high performance natural language processing platform with more than 20 language support. Of course idea was using it for SAP applications and improving the user experience. The reason i am telling the history is the totally different experience i had while using the application comparing to other SAP cloud applications. Let’s proceed on signing up and login to the system.
After opening the application, you will have some nice impressions.
- Very fluent and nice UI/UX developed by React. You can notice difference comparing to SAPUI5 based SAP products.
- Totally different from BTP Cockpit experience. Clean, neat and very light weight application. You can feel the application performance during navigation.
- Github-like experience
- No guidance needed, extremely easy to use
Bot Creation
We just click New Bot and straight away choose parameters from wizard and finalize bot creation. I used greetings template here.
Intents
Intents are set of expressions for your bot’s understanding. They should be distinct enough to avoid misunderstanding. SAP suggest here to add as much as we can with different grammatical structure.
On top of greetings template, I only added a status intent. Later on we will use this intent on our skills.
Since SAP suggest expressions with different grammatical structure, it can contain “is production fine”, “is production healthy”, “List all errors”, “is there any errors”, “show me production issues” which has similar meanings in a different structure.
System suggest to add min 50 expressions for a proper dataset but i just left it at 17. You need to tag keywords which is called entities and group them accordingly. This will be used while getting back our reply and trigger our service based on above values. My plan was not only ABAP dumps but also system resources like CPU and Memory utilization that is why i have other questions.(I just noticed it would be a good idea to split system resources). Here i will just focus on ABAP Dumps.
You can also set strictness based on the input.
Skills
Skill is just a functionality where our bot can execute based on a conversation with the user.
Below are the skills which you can configure one by one based on the intents you added on the first page. It has quite nice interface.
Greetings skill is coming from the template, statuschecker is the one i created. We also have her fallback where system will trigger i don’t get what you mean messages and also disambiguation where user inputs can trigger multiple skills and bot will ask which one she really mean.
Once you created skills, you just need to assign your intents to trigger them. I have a status checker skill here where it should be triggered after user input matches with my STATUS intent which i configured on previous page. You can include multiple intents here under a skill. Greetings skill contains both greetings like hello, hi and also goodbye intents like bye, see you etc.
Model Training
Model training is very easy with just one click. Actually it took too much time for me notice this button and i was wondering why my chatbot is not working. Make sure this icon is always green. You can click Train button once this button turns to yellow (once you update intents).
Trigger and Actions
We set up our questions(intent -> expressions), tagged keywords inside the expressions (entities) and now we need to set up bot trigger conditions and actions.
We just set IF conditions based on the intent we created earlier.
This will trigger the skill if our STATUS exists in user input.
Test your skill
Once your model trained, just to go TEST link on the right side of your browser to see if your bot can capture the intents and expression entities correctly.
Here is the output of my message “is there any problem in production system?”
As you can see, bot successfully captured status intent and extracted status and system entities. If you check above my expressions does not include problem word but system can capture it correctly.
If you see above, our STATUS intent has been captured with STATUS and SYSTEM entities. confidence is very high and everything looks proper. Now we need to assign some messages and services for response.
Now based on the values we captured, we can return back message and trigger our SAP integration.
Here i set 2 seconds delay to make it more realistic before i trigger the service to check status from SAP. Another thing is, i checked the documentation only for reaching the environment variables likes {{#system.value}}. This will allow us reach captured entity values from user input.
Once we return messages, we will trigger a webook to connect our backend on-premise system.
Here comes our SAP integration.
SAP Integration
You have several ways for connecting the bot to your on-premise system. SAP way would be using API management and cloud connector most likely but i don’t want to go 200 easy steps of configuring cloud connector and trying API management here. I have a better option (personal view) here by using AWS API Gateway and AWS Lambda functions.
API Gateway in AWS is similar to API Management in SAP, AWS Lambda maybe something like SAP CloudFoundry application (but not sure, never implemented an app in cloud foundry).
Once request reaches to API Gateway, it will forward to AWS Lambda where our serverless backend codes are working and it will do all authentication operations to our frontend server and send the request. Later on we will get error logs(st22) via RFC from our production server and get back to Lambda.
Once Bot posted the request to server, i just need entities detail under nlp object. That is why i am parsing the correct object here and sending to SAP. In the blurry area i have my authentication details to SAP REST API to post the data.
Remaning part is capturing the request in SAP, parsing the content and reading ST22 via RFC from production. This is too detail, so i will skip that part. Any ABAPer can do that.
Above you can see my print statement, it is just to see what Bot is sending in detail. Below you can see a sample content;
Testing SAP Conversational AI
Just click the text button at the bottom of page and you can test straight away. Below is a sample where it connects and displays my ST22. I asked same question in different way and in all scenarios AI captured what i really wanted to say.
and this is what i send from ABAP REST API;
ST22 from Production
Embedding to SAPUI5
You can connect your bot to SAPUI5 application from the connect tab. I think Web Client should also work but i used Webchat selection. It will give you a javascript file to embed your index.html
Once you add this script to index.html it will appear on bottom right of your screen. Below is a full working example in our SAPUI5 application.