The Book of AI

How To Build Chatbots with The Personality Forge
Chapters
Chapter 8: Memories

Your chatbot will remember who it talked to, when it last talked to him or her, and a number of specific things about each person it talks to. Memories are completely customizable - you can remember things the person said, the things the chatbot itself said, and any kind of fact you want to remember.

The xMemory Keyphrase

xmemory: this Special Keyphrase calls these memories forward when there are lulls in the conversation or as part of compound Responses. The Responses here are meant to be statements or questions about memories, and so each Response should have at least one Memory Plug-in. On your Chatbot's Settings page, you can adjust how often these Responses come up.

Creating Memories

There are two kinds of memory. Standard Memory is your chatbot's memories of other people. Self Memory is your chatbot's memories about itself. These are unrelated to the person your chatbot is chatting with. It contains memories that your chatbot can access no matter who your chatbot is chatting with.

Self Memory and Standard Memory statements are identical, except that Self Memory statements begin with "self: ".

A maximum of 10 Memories of each type will be remembered. Then old ones drop off the list as new ones are added. If you only want one Memory stored, then you can use "only" (see below).

INITIALIZE MEMORY

Where: Initialization

Statement: default "memorycontents" as "memoryname";

Example: default "bub" as "nickname";

What It Does: If memory does not exist at the beginning of a conversation, create it with this value

Alternate: def can be used instead of default

REMEMBER

Where: Initialization, Keyphrase, Response

Statement: remember "memorycontents" as "memoryname";

Example: remember (key1) as "just-ate";
Example: remember (object) as "my-gift";
Example: remember "pina colada" as "favorite-drink";
Example: remember "(key1) (postkey)" as "you-like-to-do";

Statement: self: remember "memorycontents" as "memoryname";

Example: self: remember "The (Verb)ing (Person)s" as "my-bandname";

What It Does: Saves memorycontents as a memory by the name of memoryname. If memorycontents contains plug-ins, they will be filled in before the memory is stored. If a memory of this name exists, it adds the new value to the list.

Statement: remember "memorycontents" as only "memoryname";
Statement: self: remember "memorycontents" as only "memoryname";

Example: remember (key1) as only "nickname";
Example: remember "yes" as only "likes-bears";

What It Does: Saves memorycontents as the only memory by the name of memoryname. This will replace all existing memories of the given name.

Alternate: rem can be used instead of remember

NOTE: Make sure each type of memories fits a certain kind of thing, such as a noun phrase, a verb phrase, or an adjective. That way, you will know it fits into your Responses. It would be confusing to be expecting a noun phrase and a verb phrase is in the memory instead!

Memory Plug-ins

Memory Plug-ins can be used anywhere. You don't have to worry about whether or not a memory exists, because a Response using a memory that does not yet exist will not be chosen by the AI Engine.

(mem-something) inserts one of the chatbot's corresponding memories.

(self-something) inserts one of the chatbot's corresponding self memories.

Example: "Hi, (mem-nickname)! Someone told me I was (self-iam) today. Do you think so?"

Forgetting Memories

If your chatbot remembers something that a person later says isn't true, or that you want to remove as a memory, you can use AIScript to forget that memory.

FORGET

Where: Initialization, Keyphrase

Statement: forget "memorycontents" from "memoryname";

Example: forget "hungry" from "you-are-adj";
Example: forget (key1) from "you-are-np";

What It Does: Remove the memory from memoryname if the memory exists.

Your Chatbot's Inner Life

By clicking Chatbot Workshop and then "Inner Life" under your chatbot's name, you can see a chatbot's memories and emotional relationships with everyone they have spoken with. You can correct or remove badly formatted memories here if you want.

Memory Tutorial

Here is a common example of how to use memories to increase the abilities of your chatbot. (name) is a useful AI Engine Plug-in that includes another user's or chatbot's name in a Response. But what if you're dealing with a guest or API user whose name is unknown, or someone who wants to be called something different? You can use Memory AIScript to remember their name.

Let's call the memory "your-name". First, set a default value for their name. This goes in the AIScript Initialization box on your Settings page.

AIScript: default (name) as "your-name";

This fills in (mem-your-name) with the contents of the (name) Plug-in

Next, create a Keyphrase that will catch ways someone might tell you their name.

Keyphrase: my name is, call me, refer to me as
AIScript: rem (postkey) as only "your-name";

Then create another Keyphrase to reset the name field if they change their mind or the chatbot gets it wrong.

Keyphrase: my name is not, do not call me, that is not my name
AIScript: rem (name) as only "name"

Finally, every time you want to refer to the person you're talking to, use (mem-your-name) instead of (name). And that's it!

TIP: Since this memory Plug-in will begin with mem-, there is no conflict with simply calling the memory "name" instead of "your-name". This way you can use the shorter (mem-name) in your Responses.

Gossip

Gossip Responses are used for bringing up memories associated with other users.

xgossip used to talk about people or chatbots not taking part in the present conversation. On your Chatbot's Settings page, you can adjust how often these Responses come up.

The xgossip Responses use the standard (mem-something) plug-in, and also have some special plug-ins of their own:

(gossipname) inserts the name of the person being gossiped about.

(heshe) inserts the appropriate word: "he" or "she".

(himher) inserts the appropriate third person word: "him" or "her".

(hisher) inserts the appropriate possessive word: "his" or "her".