Hartley Brody

Building Facebook Messenger Bots That Don't Suck: 9 Anti-Patterns and Best Practices

A few days ago, the Facebook Messenger team launched version 1.4 of their platform. The most prominent changes for most bot developers are the enhancements to the persistent menu options.

A lot of commentators noticed that the updates seem to steer bot developers away from building conversational, chat based interfaces. Indeed, there is now the ability for bot developers to completely disable the text composer for users, and requiring them to tap or click on buttons for every interaction.

Many people are already heralding this as the beginning of the end for chat botsif Facebook seems to be discouraging bot developers from using the primary chat interface, maybe chat bots aren’t really living up to the hype!

The truth is… right now, they’ve got a point.

Not all Facebook Messenger Bots are that great right now.

Here’s Why a Lot of Chat Bots Suck: Some Anti-Patterns

Have you tried interacting with a chat bot recently? A lot of them… aren’t so great. Even the allegedly “good” ones.

Here are some of the most common anti-patterns and sources of frustration I’ve noticed when interacting with dozens of bots.

Trying Too Hard to be Conversational

Users aren’t looking to actually “chat” with your bot like they would with their friends. They’re engaging with the the bot for a specific purpose – they’re trying to get something done.

One of the most widely shared Facebook Chat Bots “success stories” is Poncho – a cheeky chat bot that sends you weather forecasts and horoscopes. Trying to see what all the hype was about, I discovered they’re actually really terrible about this.

When I started chatting with it, the bot told me one of the commands I could send it was “Black History Month”. Obviously, that’s a rich, complex topic that is deeply meaningful and personal to a lot of people. I was curious what a weather bot would want to say about Black History Month, so I asked.

Poncho bot wanting to have a "chat" about Black History Month

I got back some messages about what Black History Month meant to the bot, how the bot loved to celebrate its idols, and how it had seen one of them live, making a joke how it had been nude.

Except, none of this was actually true.

This was obviously the work of some faceless product manager who thought this would be a relevant topic for users given that it was February. But I wasn’t actually having a conversation with that product manager.

I’m just getting some pre-canned sentences spouted to me by some software that are designed to make me think the company running this bot must be pretty woke.

This feels super disingenuous and fake. It feels like an abuse of the conversational interface to conduct one-sided conversations about a topic that bot isn’t actually capable of “chatting” about. The only responses I was able to give were clicking buttons that said “Cool thx” and “Who else?”

Sure, sometimes a cheeky message can help set a casual tone. But don’t insult your users’ intelligence by trying so hard to convince them they’re talking to a person. That’s disingenuous and taints the whole interaction.

Not Setting Expectations Properly

A surprising number of the bots I’ve chatted with don’t really tell you what they do, or what sort of commands they understand.

It seems that their creators expect users to “discover the interface” through lots of frustrating trial and error. “Just chat with us and you’ll figure it out,” they offer – while grossly over stating their bot’s abilities.

On the web, a site can easily render a page that presents forms, buttons and links. As a user, most of the time it’s pretty clear to me what I can do on a given page, and how I would do it using the interface elements provided.

In a chat situation, there aren’t nearly as many interface elements at your disposal. That’s why it’s extremely important that you set a user’s expectations and tell them what they can ask you to do early on in the conversation.

If you’re going to use the persistent context menu – which you should – make sure you direct the users there and tell them what they can expect to find.

Within the first message or two, a user should have a sense of what they can do with your bot, and what commands they’d need to use in order to do that.

Lack of Error Handling and Conversation Management

On the web, users have generally learned about two kinds of errors, and how to deal with them:

  • a 404 error, where a user can simply “go back” 👈
  • a 500 error, where they can manically refresh the page until it works 🤞

In a chat interface, there is no graceful way to handle miscues unless you anticipate and build them in. It’s easy for bots to get stuck in a loop, sending the same message over and over if they don’t understand the user’s response.

Lingio translates the word "undefined" for some reason...

The other issue I’ve run into is where a bot takes a long time to respond to a message, and the user sends a follow up message asking for something different.

This happens sometimes when I’m chatting with a human as well – we end up having two syncopated conversations in the same thread. While humans have brains to handle the two separate conversations, bots often struggle to cope with this situation.

Some Emerging Best Practices: How to Build Bots that Don’t Suck

The Facebook Messenger ecosystem is new and still in its early stages. At this point, there aren’t a lot of great case studies we can look to for best practices.

Across my interactions with dozens of Facebook Messenger bots, here are a few things I’ve noticed that make bots feel much more intelligent and valuable.

Leave a comment if there are other patterns you’ve noticed as well.

Your Bot Should Ask All the Questions

Parsing questions to understand the user’s subject and intent is really really hard, even with modern NLP and AI. Bot that do it well usually can “cheat” since they expect users to ask questions about very narrow topics, like what the weather is in a certain city.

There’s lots of ambiguity around language. Here’s a great example:

Bot: What can I help you with?

User: Where can I find the nearest hot dog?

Depending on the context, there are several valid, semantically correct interpretations of this request. The user might be asking about:

  • Where to find a nearby ‘hot dog’ cart or vendor 🌭
  • Where to find a dog that is on fire 🔥
  • Where to find a dog that is especially good looking 😻

As humans, we can read the situation and the asker to figure out their intent, but it’s tough for a machine to use these sorts of “context clues.”

Even with lots of data and complex models, you’re still not going to get it right 100% of the time, which is jarring for users in a chat interface.

Instead, your bot should ask users questions about their query, so it knows what to expect their response to be.

Bot: What are you looking for (food, movies, animals)?

User: Food

Bot: Okay, what sort of food are you in the mood for?

User: Hot Dogs

Much clearer and less ambiguous.

Your Bot Should Expose Its Interface

The Facebook Messenger Platform only gives bot developers a few interface elements to use, aside from the obvious text/chat message. You’d do well to try to use as many of them as you can.

You should absolutely be using the persistent menu as well as quick replies and postback buttons.

Getting input from users through buttons rather than interpreting text may feel like “cheating” to an AI purist, but it gives you two awesome benefits:

  1. It makes your bot much simpler to build. There’s nothing shameful about using simple if-else statements on structured inputs.
  2. It makes your bots interface unambiguous to the user. They know what’s expected and what their options are.

When users have buttons, they know that they’re not just firing off message into the ether hoping they’ll be interpreted correctly by some AI system. They know they’re playing by the rules and have a much high confidence in their interactions with your bot.

Using buttons allows you to expose your interface in a way that is clear and concise. Users know what they can do and how to do it. Maybe facebook it on to something by encouraging the use of buttons?

If You Want to Add Cutesy Features, Don’t Overdo It

Don’t take my knock on Poncho that bots need to be all business and no fun. Sassy responses and easter egg features can be a great way to drive more engagement and keep users entertained.

Emojis and gifs in responses are common – even expected – when used in moderation. They help establish a bot’s personality and make the conversational interface feel more natural.

Just make sure you don’t over promise and under deliver, or masquerade as something you’re not.

Use Synonymous Phrases Instead of Static Replies

No matter how much effort you put into your bot, if you send the user the exact same message multiple times in a row, it will make the experience feel cheap.

Instead of hard-coding response strings into your chat bot application, come up with 3-5 ways you can express the exact same ideas. Then choose a random message from your bank of synonymous phrases and send that.

Coming up with synonymous phrases usually isn’t hard, especially for things like greetings, confirmations and error messages.

This is also important if you have to prompt the user for the same piece of information again, in case they sent a response you didn’t understand.

While you might be able to ask the user for something casually the first time, if the response you get doesn’t make sense, you might have to be more explicit in your next message about exactly what you’re looking for. Don’t just repeat the same question over again until they figure out what you’re looking for.

This is also an important point for bots that send regular notifications, like a daily reminder to do something. Make sure you switch up your reminder text so you’re not bombarding the user with the exact same string over and over each day.

Give the User Options When Something Goes Wrong

Despite your best efforts, your bot is almost guaranteed to completely misunderstand a user at some point.

Maybe the user wants to go back midway through one of your conversation flows and change one of their answers, or they sent a command without understanding what it would do and now they want to cancel.

You should build in bail out points and listen for the presence of certain keywords, indicating that the user is telling you something is wrong:

  • reset
  • restart
  • start over
  • Get Started (in an attempt to restart the conversation after the initial welcome)
  • abort
  • cancel
  • stop

I’d also add that the presence of pretty much any swear word usually indicates your user is frustrated and needs help.

In you see any of these keywords in a message – regardless of what you were expecting from the user – you have to switch gears into helping them understand your bot’s interface and what they can do to get things back on track.

It’s also a good idea to mark these conversations for manual human review to see if you can figure out what went wrong and how to prevent it in the future.

Run a Beta Test

While the Facebook Messenger platform has a well-defined, documented API, humans have really inconsistent interfaces.

The best thing you can do to make your bot better is to let a few dozen people chat with it and watch how the conversations go.

You’ll likely cringe at the places your bot doesn’t understand something seemingly obvious that you didn’t anticipate when you were building it out.

As a personal example from when I was building StockBot:

I assumed that if a user sent a “thumbs up” sticker, it was because they were thanking my bot for performing a job well done. I had the bot respond with a message saying it was happy to help, and asked if they’d share it with friends.

During beta testing, I noticed that when I asked users yes/no questions and sent them buttons, sometimes they’d ignore the buttons and send a thumbs up instead of a “yes”.

The bot would pat itself on the back and ask them to share, right after it had just misinterpreted a pretty obvious (in hindsight) response to a question it had just asked. I didn’t think of this until I saw it happening with my own eyes, and quickly updated some of the logic to fix the glaring oversight.

Facebook Messenger is still a young chat bot platform, and there’s a lot that people will get wrong before common standards and best practices become more widespread.

If there are other sucky anti-patterns (or best practices) that you’ve noticed, let me know in the comments!