Skip to Content
Technical Articles
Author's profile photo Varun Kumar Saini

Making a simple chatbot with SAP Conversational AI – Part 1

In this series of blog posts, we will create a simple chatbot that takes online orders for cakes.

After getting the basic details of the order, the bot asks the user for any message to be written on the cake (eg. Happy Birthday John) and then sends these details to a backend service.

To cover these, the series is divided into 3 parts:

 

So let’s get started!

We will follow the following steps:

  1. Create a bot.
  2. Create an intent “order-cake” and add some expressions.
  3. Create entities
    1. Flavor
    2. Weight
    3. Message on cake
  4. Create a skill “process_cake_orders”.
  5. Make the skill “process_cake_orders” skilled ?

 

STEP 1: Create a bot.

Log in to your account at https://cai.tools.sap/

1.1 Select the option “New Bot” and select the following options:

1.2 Click on “Create bot”.

Now our bot is ready. It can do small talk, tell jokes, etc.

 

Step 2: Create an intent and add expressions.

An intent conveys the user’s intention to the chatbot. It contains a set of expressions using which a user’s intention can be captured.

To read more about intents, visit the documentation.

2.1 Click on the “Create” button to create a new intent.

 

2.2 Enter a name for intent: “order-cake”.

Time to add some expressions.
These expressions are used to identify what the user is trying to achieve or simply put the user’s intention.

 

2.3 Open the created intent and add expressions.

Here you can type expressions like “order”, “order cake”, “I want cake”, “order a cake” etc.

The more the number of expressions you enter, the easier it will be for the bot to recognize your intent.

 

Step 3: Create entities

Let’s create entities. An entity is a keyword that is extracted from an expression.

To read more about entities, visit the documentation.

Here we will create 3 entities:

  1. flavor
  2. weight
  3. message

 

3.1 Navigate to the “Train” page. Now click on the “Entities” tab.

 

3.2 Click “Create”. The following dialog appears.

Enter the name of the first entity: flavor.

We will use the Restricted entity type here because we have a defined list of flavors.

Click “Create”.

 

3.3 Add entity values.

Open the created entity and add some flavor values. These can be any flavors of your choice, be it chocolate truffle or butterscotch.

You can similarly create other entities.

Please note: For the third entity “Message”, the entity type will be free and there will be no entity values. This is because the message on the cake can be anything ranging from happy birthday to anniversaries etc.

Once you create all entities, the entity table should look like this:

Now that we have an intent and entities ready, we need to map it to a skill, so that we can define what the bot should do when the user is trying to “order a cake”.

 

Step 4: Create a skill “process_cake_orders”.

A skill is a block of conversation that your bot can execute to achieve a goal.

To read more about skills, visit the documentation.

4.1 Navigate to the “Build” tab.

 

4.2 Click on “Create Skill”

Enter a name for skill: process_cake_orders and hit the “Create Skill” button.

 

Step 5: Make the skill skilled

5.1 Open the created skill.

 

There are 3 things in a skill:

  1. Triggers – The intents that can trigger this skill are defined here.
  2. Requirements – The values required by the skill to perform any action are set here.
  3. Actions – The actions that the bot should perform when all requirements are satisfied are defined here.

 

5.2 Let’s start with triggers:

Here we define the intent(which we recently created) as a trigger for this skill.

The trigger says: If  @order-cake  is-present

 

5.3 Now add the requirements.

The requirements to be satisfied for this skill to order a cake is to have values of all 3 entities i.e. flavor, weight, and message.

We will add the entity values as requirements:

  1. flavor
  2. weight

We will add the message requirement in part 2 of this series of blog posts.

After adding the requirements, we have to tell the chatbot how to handle a scenario when any of these inputs are not given by the user. For that, we define a reply which chatbot sends to the user, in case a particular requirement is missing.

To achieve this, click on the Chevron of the flavor row.

You will see two options.

  1. If #flavor is complete.
  2. If #flavor is missing.

Click on the +New reply on if #flavor is missing and select send message and select text message.

Add a message of your choice.

Similarly, define a message for weight.

Now that our bot can accept a flavor and weight of cake from the user, let us check if the values entered by the user are correctly captured.

 

5.4 Time for some action.

Navigate to the Actions tab. Click on Send message.

Add the following message in the text.

Here are your order details:
Flavor: {{memory.flavor.value}}
Weight: {{memory.weight.value}}

The action should now look like this:

Our bot is now ready for basic operations.

Let us test the bot. Click on the button Chat with you bot on the bottom right corner.

 

With this we are ready for the next part of the series: Capture any text during a conversation with Conversational AI chatbot. Here we will add the 3rd requirement which is the Message on the cake.

See you in Part 2.

 

Happy bot building! ?

Cheers.

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Daniel Wroblewski
      Daniel Wroblewski

      Varun Kumar Saini This is great!!!

      I love the simple but meaningful scenario and it is explained so well. Looking forward to part 2.

      P.S.: Look at our other SAP Conversational AI tutorials at https://developers.sap.com/tutorial-navigator.html?tag=products:technology-platform/sap-conversational-ai/sap-conversational-ai. If you have ideas for other tutorials we should do, let me know. Since your at SAP, maybe we can provide this tutorial in the SAP Tutorial Navigator?

      Author's profile photo Varun Kumar Saini
      Varun Kumar Saini
      Blog Post Author

      Hi Daniel Wroblewski,

      Sure, it would be great if this tutorial can help others by including it in the SAP Tutorial Navigator.

      I will get in touch with you if I plan to write a blog post on new ideas.

      Also, part 2 is out: https://blogs.sap.com/2020/10/02/capture-any-text-during-a-conversation-with-sap-conversational-ai-chatbot-part-2/.

      Thanks 🙂

      Author's profile photo Paul PINARD
      Paul PINARD

      Thank you for creating this great blog series Varun Kumar Saini!