Are you often busy answering questions that you have answered a hundred times before?! You published FAQ documents and articles but customers and colleagues still prefer to contact you directly, e.g., in a Slack channel? What if there was a chatbot with you in this Slack channel that can automatically answer the frequently asked questions and only leaves the interesting questions for you to answer? What if this chatbot was additionally self-learning getting its knowledge from Stack Overflow? Maybe also from a company internal Stack Overflow instance? Wouldn’t that be amazing?!
My name is Lasse and I am a vocational training student at SAP and the Technical University of Munich (TUM). I spent six months with the Kyma Adoption team of SAP in Munich and developed a chatbot that can do all the things described above. In this blog article, I will explain the general architecture of the bot and what prerequisites you need to setup the bot and adapt it to your use-case. After reading this post, you can go to the GitHub repository containing the code of the bot and follow the instructions there on how to setup the chatbot.
Description of the Chatbot
The need of the Kyma Adoption team when I joined them, was pretty easy to understand. They wanted to have a chatbot that could join the Slack channel the team uses for internal customer support. This chatbot should answer questions about the Kyma runtime and learn from the SAP internal Stack Overflow instance to improve its performance day by day. My task was to do some research and afterward implement such a chatbot.
During my research, I learned about the SAP Conversational AI (CAI) platform. This is an intuitive to use platform for quick and simple implementations of chatbots. It allows to setup specialized FAQ chatbots that can answer questions based on question-answer pairs saved in an internal CSV file. Additionally, it provides interfaces to connect the bot with communication platforms like Slack. Subsequently, I created such a chatbot and connected it to Slack. Therefore, the remaining problem to tackle was how to make the bot learn from Stack Overflow.
How to Make the Bot Learn From Stack Overflow
I decided to implement a CronJob that can update the chatbot on a fixed time schedule, e.g., once a day. This update should be based on the knowledge provided on Stack Overflow. The CronJob must be deployed somewhere on a cloud platform – I decided to use the Kyma runtime. The SAP BTP, Kyma runtime is a fully managed Kubernetes runtime based on the open-source project Kyma. Therefore, I started to implement a Kubernetes CronJob that I named “update-bot”. The functionality of this “update-bot” CronJob is visualized in the following figure (the reason for using the SQL database is provided below the figure):
What you can see in the figure is that the CronJob first makes an API call to Stack Overflow and receives all the questions and answers with a specific tag – in my case “kyma-runtime”. Afterward, it should update the CSV file of the chatbot with the new knowledge. The chatbot platform SAP Conversational AI also provides an API so that the CronJob can also request all the knowledge the bot currently has. However, the CronJob does not know which question in the chatbot knowledge corresponds to which question of the knowledge coming from Stack Overflow because both the SAP Conversational AI platform and Stack Overflow automatically assign each question and each answer unique identifiers. Therefore, an additional database is needed that stores all question IDs from the Conversational AI platform, the corresponding question IDs from Stack Overflow, and timestamps. For this purpose, I chose a simple Microsoft SQL database that I also deployed in Kyma. When the CronJob encounters a question-answer pair coming from Stack Overflow that is either not at all in the chatbot knowledge or that must be updated, it performs the adding or deleting plus adding via the API of the SAP Conversational AI platform.
If the chatbot has no answer to an asked question it stays quiet and waits for a human expert to answer. A possible further improvement of the bot would be to enable it to automatically add the question (asked by the customer) and the corresponding answer (given by the human expert) to Stack Overflow.
Takeaway and Instructions on How You Can Setup the Chatbot
Your takeaway from this blog should be that it is relatively easy to setup a chatbot, to include it into a Slack channel, and to even make it self-learning from Stack Overflow. If you are now eager to set it up yourself, please check out the directory chatbot-conversational_AI in the GitHub repository kyma-runtime-extension-samples maintained by the Kyma Adoption team. There, I published all the code I developed and provided a detailed step-by-step instruction on how to setup the bot. Amongst other things, you will find the “update-bot” CronJob, an observer tool to test and supervise the chatbot and the described SQL database. Feel free to test it and provide me with some feedback. Thank you!
And keep in mind: You don’t have to answer the same questions again that you have answered a hundred times before! Let a self-learning chatbot do that!