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.

Image for post
Image for post in 2002
Image for post
Image for post
in 2004
Image for post
Image for post
in 2006

Here are a few I’ve used over the years on :

  • Eating
  • Reading
  • Listening to
  • Craving

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 platform.

Adding properties

This post jumps ahead a bit and assumes you have a bot set up on Pandorabots. I am using 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 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.

Writing AIML

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:

Image for post
Image for post


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)

the project
First published in 2000, StephTheGeek is an online presence with a giant case of scope creep. StephTheBot is an attempt to bring disparate sources of personal data together in friendly, timely, chatbot form. You can and (work in progress).

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store