A technical deep dive into the world of chatbots
In the first part of the blog "Increase your productivity by deploying chatbots" an introduction to chatbots was given. How can chatbots be used to increase productivity and customer satisfaction and what possibilities SAP Conversational AI offers for this. Some concrete examples were given including a demo of a chatbot which gives the user answers about the status of purchase orders and invoices within the P2P process. In this blog, the technical aspects of a chatbot and SAP Conversational AI (SAP CAI) are discussed.
Components in SAP CAI
A chatbot in SAP Conversational AI consists of a number of components, which are strongly interrelated. Broadly speaking, a chatbot can be subdivided into the following components:
Intent - a set of expressions that mean the same thing:
For example, the "Leave application" intent can consist of: "I want totake timeoff", "I want to takedaysoff", "I want to take time off next week", etc...
Entitity - keywords distilled from sentences:
Date, time
Period
Reason for leave of absence
Default "gold" entities available within SAP CAI
Skill - logic of the chatbot:
E.g. "Question period of leave" or "Question reason for leave".
A skill consists of trigger(s), condition(s) and action(s).
Trigger - start a skill
E.g. intent "Leave application" has occurred
Condition - before proceeding to the action of a skill
E.g. entities "Period" and "Reason" must be present
Action - outcome of a skill
Calling another skill
Calling external web service
Send message to user
Updating the memory conversation (memory)
Intents
An intent is therefore a collection of expressions that a user can set, which all refer to the same basic subject.
The "Help" intent could therefore be displayed as follows:
Entities
Within SAP Conversational AI, a number of so-called "gold" entities have been made available as standard, which are enriched with extra data. The gold entity 'Location' is standard enriched with, for example, latitude and longitude, possibly postcode data, etc. When someone appoints 'Amsterdam' in a conversation with the chatbot, the entity 'Location' is processed as follows.
The standard 'gold' entities will generally not be sufficient for the specific purpose of the chatbot. It is therefore possible to create your own custom entities. If, for example, a chatbot has to deal with the recognition of invoice numbers, this will be included in the chatbot's memory as follows.
Custom entities can be set up as a free or restricted entity. With a free entity, machine learning is used to recognize entities from expressions. For these entities there is no delimited list available, so you want the chatbot to recognize the entity automatically. To do this, the chatbot needs to be trained and monitored until the chatbot automatically recognizes the entity.
When a restricted entity is set up, a specific list is available within which the words must fall from the expression. There is no automatic detection based on machine learning. A word will not be recognized as an entity if it does not explicitly appear in a predefined list.
For both free and restricted entities it is possible to include a certain threshold of recognition. In this way, possible typing errors of a user will still be linked to the correct entity. In the sentence "It snows in dsecember", dsecember is still linked to the restricted entity "Month", which consists of a list of twelve values (January, February,....december).
Coherence components
In the Bot Builder the chatbot is shaped. This is where the chatbot is trained, developed and monitored. The diagram below shows how a conversation with a chatbot, developed in SAP Conversational AI, proceeds.
Input from the user is received. This can be done by using the Bot Connector, when it is used for example to access the chatbot via Skype. It can also be a custom application, which sends the input of the user directly to the Bot Builder.
"How is the weather today in Amsterdam?When the Bot Builder receives input, it is sent to the Natural Language Processing (NLP) API of the SAP CAI platform. The NLP ensures that structured information is distilled from the message and returns it to the Bot Builder.
IntentWeather
Entity location is "Amsterdam
Entity date is "Today"The structured information is passed through the conversation flow in the Bot Builder and by means of so-called skills, conditions and actions a message is sent back to the user.
Skill "tweather" is triggered by presence intent "Weather"
Required conditions "place" and "date" have been recognized
Action webservice againonline.nl is called with "Amsterdam" and "today".
Action message is sent back to user with reply from weeronline.nl
Avelon P2P Chatbot
As mentioned in the first part of this blog, Avelon has developed a chatbot within the P2P process that can answer questions about P2P:
Header and line information of a purchase order
Purchase orders from a specific supplier
Approval status of a purchase order
Receiving invoices on a purchase order
Payment status of a specific invoice
This allows the chatbot to answer a large number of questions that would normally end up with employees of the purchasing department or accounts payable department. Think of questions like:
"I requested 5 laptops a few days ago, what is the status of this purchase order?”
"How much was billed at purchase order 4500091234?"
"With whom is this purchase order for approval?”
"What is the status of this invoice?”
This chatbot is integrated in the SAP Fiori Launchpad. In the print screen below an impression of this chatbot:
Technical implementation Avelon P2P chatbot
For the Avelon P2P chatbot, various entities, intents and skills have been developed within the SAP Conversational AI platform in order to be able to provide the best possible answers to possible questions regarding the P2P process. For example, an intent has been developed to recognize that someone is asking about the status of a purchase order. In addition, entities have been developed to recognise a supplier, invoice number or purchase order number, for example.
Based on the recognized entities and intents, the relevant skills are called. For example, a skill is present that retrieves the approval status from the SAP backend system when requested. Retrieving and returning information from the SAP backend system is one of the possible actions in the developed skill.
The retrieval of data from SAP is realised by means of so-called webhooks. With these webhooks external web services can be called, in which the context of the conversation as JSON is given to SAP. For example, the JSON contains the purchase order number that the user has named, which can be used to retrieve information about the purchase order from SAP. In SAP, so-called SAP ABAP REST services have been developed for various webhook calls. These REST services distil the information from the JSON and return an answer in JSON format to the SAP Conversational AI platform.
The answer of the webhook call should be returned to the Conversational AI platform in predefined JSON format. The answer of the webhook is immediately the message shown to the user. It is also not possible to deviate from the format that the SAP Conversational AI platform expects from the response of a webhook call. An example of such a response is as follows (see figure "JSON webhook response").
The above answer translates into the chatbot as follows (see figure "Answer webhook in chatbot").
In addition to the Webhooks option, it has recently become possible to call up external APIs using the Consume API Service. This has the great advantage that external web services can be called directly from the Conversational AI platform, without the need to develop a separate application. The web service of Google Maps, for example, does not have the JSON response that the SAP Conversational AI platform expects. With the Consume API Service option this is also not necessary and the response of the external web service can be processed in steps after the call of the web service.
Through this external API call, we can not only provide information about purchase orders, but also say something about the weather in Amsterdam.
For questions or information about the application possibilities of chatbots within your organization or for questions regarding SAP Workflow, Fiori, SAP Invoice Management (SIM) or SAP Master Data Governance (MDG) you can contact Victor van den Hazelkamp.
Related posts