Skip to Content
Technical Articles
Author's profile photo Daniel Wroblewski

Why send reply when requirement is NOT missing? 

I got a note from Joni Liu saying he liked my tutorial Create a Chatbot that Lets Customers Track Packages but there was a problem.

The tutorial explained how to teach a bot to recognize when someone wanted to get info on their package, to recognize package numbers, and to call an API to retrieve package data. But people started to put in their own package numbers — not the example I gave for the tutorial — and it turned out that the API could not handle lowercase package numbers (made up of letters and numbers).

So I added a feature, pretty simple, to convert the package number to upper case before handing it to the API. And I learned something that I always wondered about but never figured out before:

  • I understand why you would want to perform an action when a requirement is missing, that is, to tell the user to enter the missing info.
  • But what actions would you want to perform if the requirement was given successfully?

Here was an example.

Checking requirements

Here’s what I did

  1. I created a skill that requires a parcel number.
  2. If the requirement is missing, I send a message asking for it.
  3. If the requirement is not missing, I edit the memory to update the parcel number to uppercase.

To edit the memory, I simply added a reply for If #parcel-number is complete – didn’t you ever wonder when you would use this feature? and in the reply I update the memory instead of sending a message.

The new value is set to this:

{
"raw": "{{uppercase memory.parcel-number.raw}}",
"value": "{{uppercase memory.parcel-number.raw}}"
}

What’s cool is that this example uses a Handlebars helper function (uppercase) and also uses the SAP Conversational AI reference to the chatbot memory. So this provides another example of scripting, and in this case, it doesn’t involve working with an API response.

By the way, I needed to set the value as an object (with the above JSON) because the webhook searches for the raw value of the parcel-number entity in memory.

Do you have examples to share?

Please write a comment to this blog sharing when and why you used the If … is complete reply for a skill requirement.


Read more blogs and do more tutorials about SAP Conversational AI.

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Joni Liu
      Joni Liu

      Great works. Thanks Daniel Wroblewski for sharing workaround using handlebars helper function.