Building a personal chatbot: Currents
‘Currents’ are attributes representing actual meatspace activities, which change over time, and (for now) must be manually input as chatbot AI variables. When building a virtual avatar, having these values at hand provide much-needed personality and credibility to your bot.
Here are a few I’ve used over the years on stephthegeek.com:
- Listening to
Back then, they were hand-edited HTML, in an include file, and later, a fancy PHP-based form version! I would update them every day or so, to give a visitors a super quick snapshot of my personality and interests.
Now over in chatbot land, we are looking for results like this:
<bob> what are you eating?
<stephthebot> I’m eating sushi!
Here’s how I’ve implemented this in AIML (Artificial Intelligence Markup Language) on the Pandorabots platform.
This post jumps ahead a bit and assumes you have a bot set up on Pandorabots. I am using Rosie for my base content, or you could do this with an empty bot.
Without getting into much bot syntax, we’re going to write the variables in a stephthebot.properties file, like this:
Whenever these variables on the left are referenced, your bot will substitute the value on the right.
Now we’re going to write the responses to make that happen.
Create a currents.aiml file and populate it with something like:
This file looks for patterns typed to the bot, which are written in all caps for legibility. The ^ character tells it to match zero or more characters. For example, ARE YOU ^ HUNGRY ^ matches “are you hungry?” and “are you very hungry right now?”
Within the <template> response tags, reference the name of your variable and it will be substituted when the bot responds to the user.
You’ll notice I varied the language to seem more natural, and you can decide whether you want to use full sentences or simple noun responses and format accordingly.
Your conversation should look something like this:
Next I would like to:
- Test and expand patterns for better input detection
- Create variations on response sentences to randomly select from
- Create web interface for easily updating values throughout the day
- Automate response values (e.g. detecting current song in Spotify)