How To Build Chatbots

on The Personality Forge
Chapter 14: More Useful AIScript
Emotion AIScript

While emotion can be set using the "Emotional Effect" select box on the add or edit Keyphrase page, it can also be added via AIScript, where it can be used in Responses as well. Emotion AIScript follows the pattern of numeric memories:


Where: Keyphrase, Response

AIScript: emotion + number;
AIScript: emotion - number;
AIScript: emotion = number;

Example: emotion + 2;
Example: emotion - 1;
Example: emotion = 3;

What It Does: The chatbot's emotional feelings toward the person is changed according to the value of emotionchange.

Alternate: emo can be used instead of emotion


These AIScript commands are used to control the chatbot's facial expression in robotics or other implementations using the available to those with Chatbot API. There is a built-in expression library that uses a number of factors to determine expression. This AIScript statement is for adjusting and fine-tuning your chatbot's expressions.

Expressions: normal, happy, angry, averse, sad, evil, fuming, hurt, surprised, insulted, confused, amused, asking

Where: Keyphrase, Response

AIScript: express: expression;

Example: express: amused;

What It Does: The chatbot's face will make the given expression.

Alternate: exp can be used instead of express

Seek AIScript

Where: Keyphrase, Response

AIScript: copy seeks responsenumber;

Example: copy seeks 1;

What It Does: It uses the same set of Seeks (and their Responses) as the Response indicated. If this AIScript is placed in the Keyphrase, then all its Responses will use the set of Seeks indicated. If it's placed in one or more Responses, then those Responses will use the set of Seeks. Note that these Seeks become available to the Responses in addition to any other Seeks they may have.

The responsenumber is the number to the left of the Response on the Keyphrase editing screen: 1, 2, 3, etc.

Example: Copy Seeks are for situations where your chatbot may have many Responses for a specific Keyphrase but they are essentially the same and might raise the same follow-up questions. The idea of copy seeks is to prevent needing to repeat writing the same seeks for every response you have.

Keyphrase: (m:you_must) (come|) visit me < ?PF copy seeks 1 ?>
  • Response 1: I wish I could.
    - Seek: why, how come
    - Seek: (well|but) i * want you to$
    - Seek: (m:you_do_not_want_to)
  • Response 2: I'm afraid I can't right now.
  • Response 3: That would not be possible.

In this example, Response 2 and Response 3 will also respond to the same Seeks that are in Resopnse 1 - just as if they existed there as well.

Other AIScript

While it's great to have Compound Sentences, sometimes there are rare situations where you don't want your Responses to have a chance at having another Response follow.

Where: Keyphrase, Response

AIScript: no compound;

What It Does: Prevents another Response from being added to the end from Compound Sentences.

Example Response: knock knock
(You wouldn't want anything to follow this)


Sometimes you want to respond to something and then continue on to something specific.

Where: Response

AIScript: continue keyphraseID;

Example: continue 1234;

What It Does: This Response will be followed immediately by a Response from the given Keyphrases.

Message: This story is awesome!
Response: I know! Let me continue..
+ AIScript: continue 1234; (the Keyphrase ID where the story continues)
= Bot says: I know! Let me continue.. Then I climb up on top of the fountain with my pants on my head..