Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Dan_Wroblewski
Developer Advocate
Developer Advocate
449
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.
1 Comment