Category: Blog artikelen
Author: John van Pelt, Senior consultant

Easily create your own chatbot step by step with SAP Conversational AI

Last week we already shared an article about the rise of chatbots and the advantages these bots offer for companies. Now we will go deeper into SAP Conversational AI, a platform from SAP with which it is relatively easy to create chatbots. Using various scenarios, we will show you step-by-step how you can build these chatbots yourself.

Summary: What's a chatbot?

By means of NLP (Natural Language Processing), machine learning and artificial intelligence, a chatbot can extract intentions from sentences to which, if properly trained, actions can be linked. This bot can then handle certain conversations autonomously, so that it is no longer necessary to create a human counter-component. In this way, the employee can spend the time that is freed up to pay more attention to the more complex scenarios.

SAP AI chatbots

SAP Conversational AI, formerly recast.ai, offers companies the opportunity to improve their customer service through automation. To test the functioning of the platform we developed a case.

We put it to the test and created a simple chatbot that could support a customer in case of a rate failure on his/her electricity meter.

Functional: how does the chatbot work?

In this case I worked out the following 4 scenarios in which the chatbot has to perform various actions to answer people's questions about the tariff failure to completeness:

  • The question tree
  • Fallback
  • Semi auto detection
  • Full auto detection

The question tree

This is the scenario where a chatbot recognizes that it is a rate failure but lacks all the necessary entities. To find out the correct data, the bot needs to ask questions so that a malfunction can be created automatically.

In the video above we see a greeting from the customer which shows that it is a rate failure. The bot is not able to recognize whether this is a day or night rate failure, which is why it has to be asked what type of failure it is. As soon as this is known, the chatbot asks for the address where the technician can be sent to. This is checked against an address database and then automatically creates a malfunction in an external system from which the technician can be controlled. Finally, the chatbot responds politely to a thank you from the customer.

Fallback

A chatbot is as smart as it is trained. That's why it's smart to always take into account the fact that questions are entered that are not understood by the bot. In the context of good service, it is good to give an appropriate answer in these situations as well.

So in this video we see that the bot does not understand what is being asked of him. In this case, two scenarios are possible. It is possible to give a default response, indicating that the chatbot does not understand the question. In addition, it is also possible to directly connect to the service desk to continue the conversation with the customer.

Semi auto detection

In this scenario, the chatbot can trace the type of malfunction from the sentence, however, it will still need an address to send the mechanic on his way. That is why the bot asks a follow-up question to find out the correct address.

Full auto detection

In this scenario we see the power of this platform. Where in the above scenarios we only tried to distil a single entity from a sentence, we now see that the platform recognizes all indicated entities from a story typed by the customer. In this way, the customer is helped at once and automatically to his satisfaction.

Technical: build your own chatbot

The first impression of the tooling of SAP Conversational AI is more than fine. The UI is intuitive, the documentation is in order and there are some good blogs, like this one, that can help you on your way. There is also a slack channel where questions can be asked, although there doesn't seem to be much life in it anymore.

As indicated in the above blog of SAP Conversational AI, making a bot consists of 5 steps:

  • (Train) Train the bone
  • (Build) Building a conversation flow
  • (Code) Calling external APIs
  • (Connect) Offer to the outside world
  • (Monitor) Monitors

These are also the 5 tabs you have at your disposal in the workspace of your bot

Training the bot

The training consists of 2 facets, intents and entities. With the intents you define the intentions that the bone can get out of a certain sentence/word. This can be a greeting or thank-you, but also, for example, the indicated type of disturbance. The entities are the entities you need for your conversation flow. In the example above, these are the problem type, zip code and house number.

On the intents we are going to define a whole bunch of sentences/words that have the same intention. The intention is that this will be a healthy mix of sentences without/with some entities and sentences from which all entities can be extracted.

In the example above about the problem type it looks like this:

On these sentences you can indicate the entity, below you see an example with on the first sentence no entity but the intention of a tariff malfunction. The second and third sentences indicate respectively a day and night rate failure which are part of the entity problem type.


To be able to communicate a type of failure to an external system, it expects a fixed value per type of failure. Sometimes it is necessary to provide a specification, such as a day / low / off-peak rate. Without a specification, it is questionable whether the external system understands what is meant. The tooling has created the so-called 'enrichments' for this purpose. When you go to the entity you will see a list of synonyms:


From the enrichment you add a new variable and give these fixed values, then you can link the synonyms to these values:

When the AI now detects a certain synonym, the entity problem type will automatically be supplemented with the variable id and the value 0501 or 0502. In this way, it becomes clear which problem type is meant in concrete terms.

Building a conversation flow

A conversation flow is an elaborated schematic that allows the chatbot to automatically execute the right flow in a conversation. Here we work with so-called skills. In the example above, I have defined the following skills.

The skill greeting and say-thanks work in the same way as the fallback but there is an intention attached to this. This can be seen on the tab triggers. Next you will see the message that will be returned in the actions tab.

In the skills discover and address it becomes interesting. This includes the business logic for this fault bot. When we look at the skill discover we see the following on the requirements tab:

Here we see that it is tested whether the entity problem type is there, if not the question from the 1st scenario is shown.

The entity address is an entity that is not determined by the bot but is returned by an api call, more about this when calling an external API. This entity is therefore initially never known and will always be the missing route. In this route I make a redirect to the address skill.

This skill will determine the zip code and house number and then makes an API call to an external address database.

Above you see again the consideration whether the entities zipcode and house number are automatically determined, if not a question is asked to enter them. After that we come again to the entity address, which is still empty, where the API call is made.

Now that these 3 entities are filled, all requirements of this skill are met. After this the actions are executed.

In this case you'll see that a message is shown and a redirect back to the discover skill is done. There, after this API call, all requirements have been met and the API call will be made to the planning system and a reset of the chatbuffer will be done.

Calling external APIs

In this example there are 2 custom APIs that are called. The first is to look up the address based on postcode and house number and the second is to create a failure in the planning system.

The bot webhook base url can be maintained in the project settings of your chatbot. In the example above I set up a node.js server with 2 routes (https://nodejs.org).

In the payload of your request you get the context of the bot. Here you see a variable entity that contains the elements you can work with. Based on the postcode and house number, the full address is determined and returned in a string to the entity address.

An important point of attention when calling an external API is the memory object. This is overwritten from the response, if there is data in it that you still need in the follow-up process you will have to give it back.

Offer to the outside world

Within this platform it is super easy to activate the chatbot. When you go to the connect tab you will see all possible standard tooling such as telegram, facebook etc. But also the possibility to connect to the chatbot via the SDK. When you click on an option you will see the steps that you have to perform in order to get to a working bot in that particular medium.

Monitor

On the monitor tab you can see what is typed against the bone. Here you can also analyze if the right intent and entities are determined. If necessary, you can also assign them from this overview screen and adjust them where necessary.

SAP Conversational AI is easy to use

It is relatively easy to build a working chatbot via SAP Conversational AI and to have simple tasks handled automatically. To continue to guarantee quality, a lot of time will have to be put into monitoring and adjusting, especially in the initial phase. In our opinion, this AI platform is a pleasant solution to set up your own chatbot and to automate the (online) customer service.

  • Customers get a good answer immediately and are helped faster.
  • Automating simple questions saves time that can be spent on other tasks.

Do you have questions about chatbots or are you looking for ways to improve your customer service or other business processes? Oliver IT specializes in developing smart automation solutions that optimize work processes. Please contact us, we'll be happy to think along with you.


Read here part 1: AI chatbot: a strong database increases the service level

Specific questions?

Enter your e-mail address and Oliver IT will contact you as soon as possible!

Done! We will contact you soon!
Jeroen Jansen Consultant
Jeroen Jansen