How To Build Chatbots
- 1. Getting Started
- 2. Bot Settings
- 3. Expanding on Keyphrases
- Wildcards in Keyphrases
- The AI Engine
- 4. Keyphrase Macros
- 5. Writing Good Keyphrases
- 6. Plug-ins for Responses
- 7. Writing Good Responses
- 8. The Seek System
- 9. Keyphrase Rank
- 10. AIScript
- 11. Memories
- 12. AI Emotions
- 13. Conditional Responses
- 14. More Useful AIScript
- 15. Other Keyphrases
- 16. Robotics & The API
- 17. Future Advances
NOTE: This requires a working knowledge of Keyphrases in How To Build Chatbots. If you haven't read through that yet, start there. This is a section inside it.
Let's walk through the evolution of a Keyphrase. A common question someone might ask your chatbot is if they like something. So to respond to that, you write the following keyphrase:
do you like
This is a good start but is very limited - it wouldn't match "do you really like" or "do you actually like". So let's add a soft wildcard in there. A soft wildcard can match anything or nothing.
do you * like
That's a little better, but a soft wildcard can match anything. So while it works with the above options, this would also match "do you have a dog like mine" as well, and your responses wouldn't make sense for that. So let's limit what can appear there to word types that appear before verbs with (r).
do you (r) like
Great - now we've expanded the reach of our Keyphrase without expanding it too far. As you look through your chatbot's transcripts, you see that it's catching too many things. It matches "what do you like" and "do you really like to surf". Since we want this Keyphrase to be about things your chatbot likes, let's add a (np) to the end - making sure that what follows is a noun phrase.
do you (r) like (np)
Better! Your Keyphrase is working a lot better now. So it's working fine, but you notice the Keyphrase isn't matched when someone writes "do you enjoy ice cream". That's right, "enjoy" is another word for "like". So let's add that as an option.
do you (r) (like|enjoy) (np)
Now your Keyphrase will match "like" or "enjoy" in that position. But wait - you notice another one it misses: "do you love ice cream". There's probably a lot of words that can fit there. Luckily, there's a Word-Type Plugin for "like" that you can use to match them all. Let's replace (like|enjoy) with that.
do you (r) (v:like) (np)
It's working even better now. But then you see another way to ask if your chatbot likes something: "Are you a fan of ice cream". How to you also catch a whole lot of different phrasings of the same question? You could write a Keyphrase list with all the options you could think of, or better yet, you could use a macro, which will cover them all at once.
That's it! Your Keyphrase has maximum reach without matching anything it shouldn't. And best of all, it's short and easy to read.
If you want to get a good idea of what Macros and Modern Keyphrases look like, take a look at the Master Bot Template.
There is an art to writing good Kephrases. By this I mean flexible, useful, successful Keyphrases that will match all the versions of what you're looking for without matching too much. Here are some examples of Keyphrases with problems and how to improve them:
Keyphrase: i once knew a (np:1) that (vp:2) (np:3) on (his|her|its) (adj:4) (np:5)
This will likely never match, because it's too long. How often will someone say something that matches this? Probably never. So let's shorten it. We'll remove the end, which could be accessed by (postkey) if there's something there. Let's remove the "a" so that the (np) could also match words like "three" or "several":
Improved: i (r) once (r) knew (np:1) that (r) could (vp:2) (np:3)
Keyphrase: the wild dogs took my pajamas then ate them
This is too specific. Nobody is likely to say that exact phrase. So let's make it more general. Unless "wild dogs" or "pajamas" are something brough up by the chatbot, let's make them into (np) so they can match all kinds of things.
Improved: (np:1) (r) took my (np:2)
Sure, your Bot could respond with something general about pants, but a person would feel like your chatbot didn't understand what was said to it. This word could be part of many different kinds of questions or statements. If "pants" is a topic raised by your Bot, it'd be better to write Keyphrases with some context:
Improved: where are (prenoun) pants
Improved: i (r) (v:like) (prenoun) pants
Improved: pants are (r) (a:great|a:attractive|stylish)
Improved: i (r) (v:hate) (prenoun) pants
Keyphrase: i'm ready!
Every contraction in incoming messages is separated into individual words for the Keyphrase to match. "I'm" becomes "I am". "you're" becomes "you are". So ensure your Keyphrase is written without contractions or other punctuation.
Improved: i am ready
Spelling or Grammar Errors
Keyphrase: ur soo kewl
Keyphrase: your funny
Common misspellings and slang is corrected in incoming messages. Putting them in the Keyphrase will not match except in raw mode. One of the most common mistakes is confusing "your" which means "you possess something" and "you're" which means "you are".
Improved: you * are * cool
Improved: you * are * funny
Typically you should almost never have to adjust a Keyphrase's rank. The AI Engine takes care of finding the best, most appropriate match. Learn more about rank