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: Do you have a store in berln
Bot: Yes, we have recently opened a brand new store in berln! (repeats user's spelling mistake)
In this dialog, both the user and the bot are referring to the city 'Berlin' 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: Do you have a store in berln
Bot: Yes, we have recently opened a brand new store in Berlin! (corrected spelling)
As 'berln' is both missing an 'i' and is lowercased, we have to take the following steps to get it correct in our bot's reply:
We start from the 'User wants to know if we have a store in city' flow which we have created and extended earlier.
_.getUsedWords(_.FINAL).join(" ")
in the attached script.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 is now accomplished, so why not give it a try? Go to tryout and test the following dialog:
User: Do you have a store in berln
Bot: Yes, we have recently opened a brand new store in berlin! (corrected spelling but still lowercased)
Now that the spelling is fixed, it would be nice to return the city name with the first letter capitalized. To do this, simply:
.capitalize()
to _.getUsedWords(_.FINAL).join(" ") in the attached script.That's it! You are now all set to try out whether the bot can correct your simple spelling mistakes. Go ahead and have a play in tryout!
Was this page helpful?