Mobile Menu

The author’s background experience

I have been implementing SAP projects for the last 12 years, working in different countries for different industries and clients’ sizes. For about 5 year I’ve been a part of SAP Values Prototyping team delivering rapid prototypes and proof of concept all over the globe. Currently, I’m leading the SAP Practice and SAP Innovations at Skybuffer.

Introduction

During our SAP products strategic development, we always face a need to make customers acquainted with our applications and the company’s general info and policies in a convenient and easy way. So we found SAP Recast AI platform and decided to use it and build a smart chat-bot for our website.

As SAP Recast AI is not so widely used yet, and there is not so much information about it, I’ve decided to share my experience on some of its peculiarities with SAP Community.

This article shows how you can train your bot in such a way that it should be able to get a chat user’s first and last names in a smart way of not asking for the last name in the infinite loop manner, and at the same time the chatbot does not fallback with “No reply” state.

Prerequisites

You are to sign up to Recast AI platform and create an initial version of your chat-bot.

Business case

Your bot asks for the chat user’s name at the very beginning of their dialogue. However, it should be able to get names (#person entity) any time during the conversation.

The bot should keep the first name and the last name during the entire conversation, until the memory variables are not cleaned up in the Requirements or Actions sections.

The bot should not ask for the last name for the second time in case the user refuses to provide it.

The bot should consider any reaction to the last name asking question as a refusal to provide it without gaps in the fallback actions stack.

Steps to meet the requirements

Create intent: @zxai-my-name-is

Consider entity: #person

Skills:

  • create skill zxas-get-user-name
  • create or update fallback skill zxas-fallback

Solution

Step #1: Create Intent in Train Section

16

Step #2: Create Skill that is Triggered by Intent

17

Step #3: Define Triggers for Rules

18

Here it is possible to see that trigger is quite complex. That is done to avoid infinite loops in case when either the chat user is kind of playing with the bot, or when the bot is falling back because of implementation gaps.

So, in case we read the trigger in the humanized way, we can get the following sentence:

“trigger the skill when user mentions their name in the form of a phrase like:

“my name is”

or there is a #person entity that has been discovered by Recact.ai NLP engine.

Simultaneously, we should not trigger that skill in case we even have the chat user’s last name, if it might be #person entity, though it is not connected to the chat user’s first or last name”.

Step #4: Process First Name and Last Name in the Sequence via Requirements Section

19

Here it is wise to have both the actions for getting and missing #person entity for both the names

20

In case the requirement is completed, we can write a confirmation back to the chat user:

21

In case the requirement is missed for the first name, we can insist on capturing the chat user’s name (until we get it):

22

However, for the last name we will ask only one time and use the memory to remember it:

23

Note: Using AND rule in requirements section allows us to process JSON array that could be available for the skill as a result of Recast.ai NLP engine phrase processing:

24

Step #5: Fallback Processing in case the Chat User has Refused to Provide the Last Name

We set the memory variable to “active” value:

user_last_name_asked = “active”

in case the chat bot has already asked for the chat user’s last name.

Using this variable, we suppose to accept any reply of the chat user that does not have #person entity as a negative reaction to the request to get the last name. Considering the number of possible reactions (phrases) of the chat user, it is very complicated to foresee what they can tell the chat bot, in this case we process the negative reply via Fallback skill Action:

15

For instance, in the Fallback action, when there is no #person and no User Type (our custom business case) provided, we can route the conversation to ask about the type of the current chat user.

Result

Here is a sample chat of the result when the chat bot captured the chat user’s first name successfully, though the chat user refused to provide the last name:

25

Conclusion

This is just a simple hint of how the bot can responsively react in the dialogue by asking the chat user to give their first and last names in the smart way and at the same time consider that the chat user might refuse to provide the last name and say so in any imaginable way.