Skip to Content
Technical Articles

Capture any text during a conversation with SAP Conversational AI chatbot – Part 2

In this blog post, we will learn how to capture any plain text input from the user for which values are not defined in the entity.

This blog post is 2nd part of a series with the following parts:

 

So let’s get started!

We will follow the following steps:

  1. Add the requirement in our skill.
  2. Configure the fallback skill.
  3. Update the reply from chatbot.

In part 1, we created a free entity “message”, which can be used to store the message(any random text e.g. Happy birthday John), to be written on the cake.

 

Step 1. Add the requirement “message” in the skill.

After adding the requirement, 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 Message row:

You will see two options.

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

Click on the +New reply on if #message is missing.

Select send message and select text message. Add a message of your choice.

After adding the message, we will now set a field in memory, basically a boolean flag so that chatbot knows we are trying to enter a message for cake.

We are doing this because if we enter any random input in the chatbot for which an intent is not defined, then the fallback skill is triggered. And since we do not know what message a user might want to get on the cake, we do not have a scope for the message entity. Hence we set a flag when the user is asked to enter the message for cake and check the value of this flag in the fallback skill.

So we set the following value for a variable cake_message_set.

{"flag":true}

The reply will finally look like this:

 

Step 2: Configure the fallback skill.

 

Open the fallback skill and navigate to the Actions tab.

Here, we will add a new message group.

This message group will get triggered when the cake_message_set flag is set to true.

If  _memory.cake_message_set.flag  is  true

We can now take the text entered by the user as the message to be written on the cake and set it in the memory. We then unset the cake_message_set flag.

To do this, click the button Update Conversation, from the drop-down, select Edit Memory.

The following fragment appears:

In the Set memory field section, enter the memory key as message with the following value:

{
  "value": "{{current_message.content}}",
  "raw": "{{current_message.content}}",
  "confidence": 0.99
}

Then, in the Unset memory field section, enter the memory key as cake_message_set.

After this, we need to again trigger the main skill i.e. process-cake-order. For that, click on update conversation inside the same message group of fallback skill and click goto.

Then select the skill process-cake-order and press save.

The message group should now look like this:

 

Step 3: Update the cake-bot reply.

 

Let us now update the reply given by the bot to show the details of the message on the cake too.

Here are your order details: 
Flavor: {{memory.flavor.value}}
Weight: {{memory.weight.value}}
Message on the cake: {{memory.message.value}}

 

 

Our bot is now ready. Let us test the bot.

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

 

Perfect! The bot is behaving as expected.

In Part 3 of this series of blog posts, we will learn how to connect the cake-bot to a backend service, where the orders can be processed.

See you in part 3.

 

Happy bot building! 😄

Cheers.

7 Comments
You must be Logged on to comment or reply to a post.
  • Why not use the built-in feature for going to a skill and waiting for the user to provide input (“Wait for user input”) instead of adding a flag and a message group in the current skill? Is there a time to use one vs. the other, or did I misunderstand that feature?

    • Hi Daniel,

      As I have explained in the blog, we are doing this because if we enter any random input in the chatbot for which an intent/entity is not defined, then the fallback skill is triggered. And since we do not know what message a user might want to get on the cake, we do not have a scope for the message entity. For example “Happy Birthday”, “Congratulations on your birthday”, etc. If we use the “Wait for user input” feature, even then the fallback skill gets triggered. Hence we set a flag when the user is asked to enter the message for cake and check the value of this flag in the fallback skill.

      I hope that answers your question. 🙂

  • Again, really nice blog — almost finished part II.

    1. When I’m doing it, it works until I am asked for the message. When I give the message, though, the bot interprets this as the greeting skill and just says hi back to me. What have I done wrong?
    2. Small cut and paste issue: When you tell people to add a message if message is missing, you mention the flavor by mistake (step 1 above)
    • Hi Daniel,

      Thanks for trying out the steps. 🙂

      1. I think the message you tried is matching the greetings intent with more confidence and hence is greeting you back. Can you try another message?
      2. Thanks for pointing out the mistake. I have corrected it.

       

  • I created the same (I think) this way:

    • In the process_cake skill, I create reply if message is missing (same as you) — send text asking for message, set flag, but then go to new skill and wait for user input.
    • I create a new skill, whose trigger is the flag, and then unset the flag and store the entered message. I then redirect back to the process_cake skill.

    I like this because (1) it uses the wait for user input feature; (2) it does not add functionality to the fallback skill — I was once told this should be reserved for only true fallbacks.

    The only thing is I’m concerned that we were in the process_cake skill and then sort of in the middle we execute the skill “again” and maybe this messes up the skill stack — but I just don’t understand how it works underneath the hood.

    P.S.: I did Part II again and again the text I enter for the message is captured as the message but it is also analyzed for intent and returns the fallback action. Was I supposed to delete the fallback message?

    P.P.S.: On to Part III 🙂

    /
    🙂
    • Hey Daniel,

      We can surely achieve the same functionality in the way as you have described. But that adds another skill in the skill set to process this particular requirement by a skill. So to avoid that, I decided to go with this approach of using the fallback skill.

      Answering to your question, you can either insert an if condition to check whether the cake_message_set variable is defined or not, or you can delete the default fallback message. I hope that answers your question.

      Thanks! 🙂

  • Very Nice Blog. Could you please suggest me any options available to download and upload our custom bots available . As I have developed my bots in my closed organization tenant.Want to deploy the same in clients tenant.

    Don’t want to develop it again.