We have already seen how you can use the user's own words in your bot's reply. Here we will show you how to normalize the user's words before returning them. This can be useful for slightly misspelled inputs like the following:
User: I want to order an espresso
Bot: Ok, what name shall I note for the order?User: Elizabth
Bot: Thanks for your order, elizabth. Your espresso will be ready for pickup in 5 minutes. (misspelled and lowercased name)
In this dialog, both the user and the bot are referring to the name 'Elizabeth', which the user has misspelled. The dialog nevertheless succeeded because Teneo has a built-in spelling normalization. We can access the normalized spelling of the user input to get the following dialog instead:
User: I want to order an espresso
Bot: Ok, what name shall I note for the order?User: Elizabth
Bot: Thanks for your order, Elizabeth. Your espresso will be ready for pickup in 5 minutes. (corrected spelling)
As 'Elizabth' is misspelled, we have to take the following steps to use the correctly spelled word in our bot's reply:
We start from the 'User wants to order a coffee' flow which we have created and extended earlier.
%$PERSON.NER^{userNameForOrder = _.getUsedWords(_.FINAL).join(" ")}
The following picture illustrates the scripting API call in more detail:
It consists of three parts:
A full list of possible parameters to be passed to this scripting API method is given here.
The spelling normalization part has now been implemented, so let's give it a try! Go to Try Out and test the following dialog:
User:
I want to order an espresso
Bot: Ok, what name shall I note for the order?User:
Elizabth
Bot: Thanks for your order, elizabeth. Your espresso will be ready for pickup in 5 minutes. (corrected spelling but still lowercase)
Now that the spelling is fixed, it would be ideal to return the name with the first letter capitalized. To do this, simply:
%$PERSON.NER^{userNameForOrder = _.getUsedWords(_.FINAL).join(" ").capitalize()}
For cases where you do not want to normalize the name but still capitalize the first letter use this condition instead: %$PERSON.NER^{userNameForOrder = _.getUsedWords(_.FINAL).join(" ").capitalize()} / (! %$PERSON.NER & (*)^{userNameForOrder = _.getUsedWords(_.FINAL).join(" ").capitalize()} )
That's it! You are now all set to test whether the bot can correct your simple spelling mistakes. Go ahead and experiment in Try Out!
Was this page helpful?