Chatbots

I’ve been working on chatbots on and off for a while now. The other day, I received a question about how I built the latest Chatbot.

“I love the Chatbot, and it has been something I’ve been trying to replicate. There is so much noise. I’m finding it hard to find a good solution. I’d be grateful if you could point me in any direction, tools or what to search for.” 

I had always intended to write about it. The scope may have expanded a little since then into a short series. This post covers some background on chatbots, a few principles for conversational interfaces and building a basic chatbot.

The text adventures were some of the earliest games I saw on microcomputers. It is not the type of game I played often, but they were a fascinating subject. What got me hooked on interaction design was the Fighting Fantasy books. When we had to produce our own for an English project, that was perfect; creating that adventure was my first serious attempt at game design. Which years later would lead me to work as a game developer.  

The documentary Hyperland by Douglas Adams was my other formative experience in the chatbot space. Watching the film years before I saw my first web browser was eye-opening and foreshadowed how we interact with Siri, Alexa and ChatGPT today. 

Hyperland by Douglas Adams

Even in the days before ChatGPT, a more conversational approach was becoming more commonsome principles I’ve found useful.

  • The Chatbot isn’t human and should not pretend to be one. Avoid the uncanny valley.
  • Buttons and suggested replies work well to guide the user. Users should always know what the next step is.
  • Chat-based interfaces are better for novice or casual users. Guiding them to a successful outcome. They slow down power users. Think about how you can support power users so they don’t become frustrated.

Now, we have covered some background and rules of thumb. We move our focus to more practical matters and building a basic chatbot. The example code is a simple command line tool to interact with the Chatbot. Others have covered integration with WhatsApp and Telegram.

Read Input
Preprocess input
Match rules
Post process response
Output response

The example utilises Artificial Intelligence Markup Language (AIML) for a rule-based approach. JavaScript is the glue, with most of the work handled by the AIML rules. Tutorialspoint has a decent post on creating AIML Pandorabots provide free AIML rules.