How To Build Chatbots

Chapters
Chapter 7: Writing Good Responses
1 Use Everything

When a Keyphrase is matched, we may not have ALL the information we need to provide the right answer. This is an opportunity for creativity: you can make up an answer, dodge the question, turn the question around, or whatever you imagine.

Keyphrase: where

Without context, we don't know the right answer. You could say "In the refrigerator!" Responses like these are often funny and engaging. Or you could say "Where do you think?" or "Let's look around for it." which are engaging. The shorter the Keyphrase, the more you'll have to fake it.

Keyphrase: (m:where_is) my (np)

In this example, we have more information that we can use in Responses. We know that a specific person/thing that belongs to the person is currently lost. Each of these facts can be used in Reponses:

Response: I saw (key1) in the backyard yesterday.
Response: When did you last see your (key1)?
Response: Did you check the closet? I usually keep my (key1) there.
Response: Do you think it's with your (mem-youhave)?

Also notice that since we don't know what pronoun to use for (np) (it, he, she), then it's best to use (key1) when referring to it. It's good use (key)s in most Responses anyways, as it is more engaging.

Keyphrase: (m:i_like) your (np_)

The more specific the Keyphrase, the more we know. In this example, we're specifying a singular noun phrase with (np_). You can use this in your Responses.

Response: This (key1) isn't even the best one I have!
Response: Thanks! It took a while to find the perfect (key1).
Response: Do you want it? I've got lots more at home.

2 Common Mistakes

Here are some examples of Responses with problems and how to improve them:

Boring Answers

Keyphrase: who
Response: I don't know.

This is a boring answer and gives the person nothing to work with. Instead, engage them with a random or exciting answer, someone from earlier in the conversation, or ask something back:

Response: I'm pretty sure it was (p:person).
Response: That creepy guy standing behind you.
Response: I bet it was (last-she).
Response: Do you think it's someone you know?

Missing Opportunities

Keyphrase: (m:do_you_like) (cats|kittens)
Response: Yes

Again, this is a boring answer and ignores the details you have available. Instead, engage them by talking more about cats:

Response: I love (key1)! I have two at home - a tabby named Captain James and a calico named Kerfuffle. Do you have any cats?

Note: we don't want to ask "Do you have any cats" to a person more than once. BUT this question is probably not going to be asked of your chatbot more than once. So we don't need to use AIScript "once".

Repeating Non-Changing Questions

Keyphrase: #engage
Response: Are you a guy or girl?

This is a fine question, but it's in #engage and could come up a lot. So let's add some AIScript:

AIScript: once;

Or we could use memory to store their gender and check to see if this is something we know yet:

AIScript: if (mem-gender) does not exist;