This article was originally published on Botpublication.com. Many of the "smart" chatbots with Natural Language Processing and Artificial Intelligence still have a hard time keepin…
6 things I learned creating my own Messenger chatbot
The modern messaging tools that chatbots run on offer much more ways to interact compared to what previous incarnations of chatbots had, such as those used on IRC or AIM. Much advise on building chatbots that’s out there quietly assumes that all chatbots are just text-in-text-out, which doesn’t match with the platforms they are on. I recently built a chatbot for Facebook Messenger, and these are six things I learned from using other bots in research, building the bot and watching people interact with it.
A Messenger Adventure is a text adventure similar (albeit much smaller) to Zork and Adventure, two classic text adventures that take place in fantasy realms. It’s a small campaign that you can finish in 15 minutes or so. You can read more about it here.
Most of these are specifically for Facebook Messenger, though there are general points to be found too.
1. People send a like/sticker as a conversation starter
My bot initially only responded to text inputs, but it turns out that quite a few people actually send a like as the first message. If you don’t want to lose those people in the first message (like me!) be sure to respond to non-text input such as likes, stickers or even photos.
In Facebook Messenger, a Like is sent as a ‘sticker’. This means you will receive a message object with a sticker_id in it (an it will not contain a text value). The sticker_id of a like is “
369239263222822“. Be sure to send something nice back. I went with “I like you too!”
Small update: A like can actually be three separate stickers: depending on how long you press it, the image becomes larger. These are the possible values: “
369239263222822“, and “
369239343222814“. Thanks to Stuard Dunkeld for mentioning this on Twitter.
Don’t assume your users will just send text your way.
2. If your bot asks a rhetorical question, people will answer it
Once or twice in my chatbot text adventure, I asked a rhetorical question such as “There are strange markings here. What could they mean?”. Unfortunately, people thought the bot was asking for input and started answering the question. Which in turn confused my bot, because it wasn’t expecting any input.
Because your bot lives in a messaging app, people are conditioned to respond to questions using the interface at hand. If you don’t want them to answer, don’t ask a question. To avoid this problem, I rewrote my rhetorical questions into observations. For example, the above question turned into “You wonder what they mean.”.
Rewrite rhetorical questions into observations or people will send you answers.
3. Add a natural delay between messages to keep your chatbot from feeling mechanical
This is just a gut feeling thing, but if your chatbot dumps all messages at once, or if there’s always the same amount of time between messages, it starts to feel a little…robotic. I found this off-putting and it also does not fit with the way we expect messages to come at us in chat interfaces. People take some time to write, rewrite or ponder a sentence before sending it, and it differs per sentence and per person.
The benefit of being a chatbot is that “typing” is done instantly, but it feels much nicer when there is some natural-feeling delay between messages.
The flip side is that, because people are interacting with a bot, They expect it to be fast. If your bot takes multiple seconds to answer, it becomes tedious to wait and that’s also not good. To keep my bot from feeling both fast and natural, I have an artificial delay of 30ms per letter, with an added random delay between 0 to 500 ms. This is about three times faster than a fast typing human at 120WPM. Because the delay is per letter, long messages take longer than short messages, so it feels very natural. Depending on the bot and actions, yours might feel better if it’s a little faster, or a little slower. Experiment with it!
Update: someone on Hacker News posted that the delay in his bot is based on the length of the previous message, which means that it’s actually a delay based on the time it takes to read the text, rather than write it. I think that’s really smart and a much better fit for chatbots, so I also implemented it in A Messenger Adventure. This way the delivery of messages still feels natural, but the pacing is adapted to the reading time of a user.
Try out various timings for your chatbots messages to find out what works best.
4. Quickreplies rock
Pretty early in the development of my chatbot I chose to deliver all options as quickreplies. Historically text adventures are played, sometimes frustratingly so, by typing in commands and getting “I DON’T KNOW THAT WORD.” back until you didn’t. Having all the options available immediately takes away some of the discovery, but arguably just the most annoying part of discovery.
By offering quick replies for all actions, all users have to do is tap or click the quickreply they want to send. This takes much less effort than typing out options, let alone thinking up actions. Especially on mobile this really drives usage. I have seen other chatbots that force me to type a 1 through 8 to pick from a “menu”, and it feels almost insulting. Don’t do that!
If your bot has limited options, Help your users by showing them as quickreplies.
5. Get a second chatbot for development
Next to the A Messenger Adventure Facebook Messenger bot, I also have
Kilianbot is an unpublished Facebook page and app that I can hook up to any chatbot backend and use for development. Combine it with ngrok to easily tunnel your localhost over HTTPS (a requirement for Facebook Messenger) and local development becomes very easy.
Use an unpublished page and app for development.
6. Get the Facebook pages app
The Facebook pages app is mostly a marketing tool for pages, but it recently got updated and has a great view in which you can see all the conversations people are having with your bot. This is a great way to figure out how people are interacting with your bot, and you could even help them if they get stuck.
See how people interact with your bot in real-time using the Facebook Pages app.
These are some of my findings and tips after developing and launching a chatbot. If you’re looking for more resources, Designing conversational interfaces by Alper Çugun is a nice introduction into chatbots in general, and the ChatBots: How to Make a Facebook Messenger Chat Bot in 1hr course on Udemy is an excellent way to get started (But short. If you can do without the videos, you can follow the tutorial for free at chatbotslife.com.) Lastly, if you’re going to write specifically for Facebook Messenger, I highly recommend (and use) FacebookMessengerBot.js.
After you have made your awesome new Messenger bot, it's time to demo it. If you made a bot for a professional client you don't really want to give a demo with the always-present M…
For quite a while now I've had the idea to create a chatbot that works like one of those old-style text adventures like Zork. Recently I bumped into a free course on beginning a Fa…