How To Build Chatbots

on The Personality Forge
Chapter 8: The Seek System
1 Seeks

Seeks are Keyphrases that are active only after a certain Response comes up. The selected Seek's Responses can then have Seeks of their own. You can go as deep as you want. Seeks can do all the things Keyphrases can, but they are usually shorter and have a few additional powers.

When someone responds to a Response with Seeks, the Seeks are checked first. If one is matched, the conversation continues down that thread. If not, the message is then checked against all the normal Keyphrases.

To add Seeks to a Response, click "+ Seek" to the right of the Response.

Special Seeks

yes, no, & haha

There are three Keyphrases that have extended matching power: "yes","no" and "haha". Each of these has an expanded reach in the AI Engine and cover every possible way of saying them. Seeks of "yes" and "no" are extremely useful and common.


If you add a Seek called #nomatch, it will be triggered if no other Seeks are found.

Let's say a chatbot asks "Do you love me?" and that Response has three Seeks: "yes", "no", and "#nomatch". If the person responds to the chatbot by saying "Yes, I sure do!" then the yes Seek will be triggered. If the person's response is "I need to get going", then #nomatch will trigger and the chatbot could say "Why are you avoiding the question?". If there was no #nomatch Seek, then the general list of Keyphrases would then be searched as usual.

Reusing The Original Keys

As you know, whenever a Keyphrase or Seek is matched, Key Plug-ins such as (key1) and (key2) are generated. When you are writing Responses for Seeks, you can access the Key Plug-ins from the original Keyphrase match. This lets you access the original topics of conversation in Seek Responses. To access them, put "first" at the beginning of each: for example (firstkey1) or (firstpostkey)

Starting with this conversation:

Person: "Do you ride white horses?"
Bot: "I ride white horses every day."
Person: "Even on your birthday?"

When the Seek "even on" is matched, it has access to the following Keys:

Key Contents
(firstprekey) -
(firstkey1) ride
(firstkey2) white horses
(firstpostkey) -
(prekey) -
(postkey) your birthday
Bot: "Yes, I especially like to ride white horses on my birthday."

2 Pointing To Other Keyphrases
Goto Responses

Let's say you've got a solid set of Responses for a particular Keyphrase, and you want to use that set somewhere else as well. Rather than copying those Responses, you can have a "Goto Response" that looks like this: "goto 12345", where 12345 is the ID of a Keyphrase (or Seek). When that Goto Response is selected, the AI Engine will instead choose a Response from that Keyphrase. There are three times when you should use gotos:

  1. Goto Responses really shine when you're writing Seeks. As Seeks can form complex structures, it's sometimes useful for one Seek to point into the structure of another, or end on another Keyphrase.
  2. When you want to sometimes use Responses from another Keyphrase, then you can write several normal Responses and then add one or more Goto Responses that point to the other Keyphrase whose Responses you want to sometimes use.
  3. When you want different Keyphrases to use the same Responses, use Keyphrase Lists. However, if there are too many variations to fit in one Keyphrase (this should be very rare), you can get more space by creating another Keyphrase List with a single Goto Response pointing to the first.

However, if you just want two different Keyphrases to have the same Responses, it's better to simply write them as a Keyphrase List: "keyphrase A, keyphrase B, keyphrase C". This is simpler and easier to read. Writing Goto Responses should be relatively uncommon in your chatbot.

Click the [go] box to the right of any Keyphrase in the Language Center, and you'll see a little popup that says "goto" followed by a number. That's the goto and ID that you can use as a Response to redirect to that Keyphrase's Responses. Linked Keyphrases from Bot Templates have gotos that start with the Template ID like this: "goto 1.15".

Be aware - if the new Responses you are pointing to require (key)s, make sure the Keyphrase with the goto Response is collecting the same (key)s. Otherwise the (key)s in the resulting Response will be blank. For similar reasons, you cannot goto #gossip, #favorite, or #math. All of these require a number of things from internal processing and must be triggered naturally.

Continue AIScript

There is an AIScript command called Continue that works similarly. By adding "continue 12345", where 12345 is a Keyphrase (or Seek) ID, the chatbot will use the current Response, and then add a Response from the given Keyphrase ID. For more, check out More Useful AIScript.