You don’t even remember already when you have seen the first article on the chatbots-related topic. For around half a year you have been coming across a lot of them. You would just glance over some of them and read the rest ones.

Your enthusiasm about the topic is still with you and you want to put into the work. So you feel ready to put your hands on development of your own chatbot.

The first question that you may want to ask yourself is where I want my chatbot to live. We all know that chatbots common live space is the place where people are chatting, or in other words – messengers (to explore more about existing messengers and conversational apps jump here). Therefore, answering this questions means deciding on the particular messenger

Therefore, answering this questions means deciding on the particular messenger
building-your-bot-or-where-real-difficulties-come-up-first bot

Picking the right messenger shouldn’t be on occasion, especially if you want to monetize your future bot. In different messenger audience also differs. So you need to think carefully where your targeted audience chats to drive their attention in the appropriate place.

Chatbots for business: how to make money with bots?

In this article, we will focus on the particular case of building chatbot for the Facebook messenger. If your chatbot is considered to be entertainment-related or you suggest the audience would rather interact with it in their free time, FM is a better choice.

However, you will also learn a lot after you track the interactions with your bot. And if you find out that another messenger is a better fit, you would connect your bot to another messenger (no big deal, really).

Building chatbot for Facebook messenger

Let’s consider that your targeted audience lives on Facebook or for some reason you have decided to pick it as the messenger for primary deployment of your future chatbot. First where you go is Facebook documentation for developers. You need to sign in under your Facebook developer account. If you haven’t developed anything for Facebook so far, you may not have this account.

So don’t be surprised – you can quickly fix it by making one. It’s very easy. On the Facebook’s developer platform, you will find the blue button “Register” (in the upper right corner). Click it and agree to the Facebook platform policies. Then you will be proposed to create a new app id by giving it a name, choosing the proper category, and filling out your email address. That’s it.

Now you need to create a Facebook page to attach your future chatbot. So you’re back to Facebook. After creating a Facebook business page you’re looking through Facebook documentation and finds out that you need to create your Facebook application.

You’re adding messenger platform to your application and subscribing webhooks to your Facebook business page. You get an access token. Feels quite simple so far, right? Further, you need to write down some code to program basic bot knowledge and test it.

If the word “webook” sounded somewhat extraneous for you, here I am to explain it. If you know what it is, just skip this paragraph. In fact using webhooks means that you can subscribe to the updates of certain data of the application and receive them in real time. When data changes POST call is sent.

Therefore, you can raise the efficiency of the application as you don’t need to send the calls when there is no change in data. Instead, calls are sent only when needed.

So you might have carefully read the documentation and gotten Facebook SDK for your programming language (on the Facebook for developers you can find the variety of options). You understand that the first what you need to write down is code that handles listening to POST calls made to your webhooks (which are subscribed to the Facebook page).

So every time when your page receives a message, you (in this case – your bot) can get it and immediately answer.

For this you’re writing something like following:

building-first-bot-1

Then you’re writing another snippet to make sure that whatever happens (such events like sending or receiving a message by a user or receiving a message on a page) it has been handled appropriately in your code.

building-first-bot-2

To test it you may want to enable chatbot to echo received messages. That’s what most of us start with writing logic and testing it.

building-first-bot-

Now you understand that information received by the page can be different. And so is the information sent by the page. Facebook makes possible to send complicated messages with text, images, and buttons. You need to handle in your code these scenarios as well:

building-first-bot

You describe the data for the request

building-first-bot

and post it to the Facebook API Graph

building-first-bot

Also, there are templates for making rich messages (you can always turn to it on Facebook for developers) but the main logic is already here in your code.

Here I feel the need to say few words about Facebook Graph. In fact, it’s a tool for uploading and accessing data on Facebook. It has low-level HTTP structure so you talk to it by means of POST and GET calls (just as we did in this tutorial). Its name is related to the social graph, which is a complicated graph structure of relations between users.

Facebook calls it “the global mapping of everybody and how they’re related”.

Now you may want to test your chatbot. And, surprisingly, it works. You think it has to be the main stuff and you’ve made it. But you’re wrong.

Instead, it’s the time for your disappointment because you’re starting to see challenges you couldn’t predict in the beginning.

Now, you have echoing bot which you can easily turn into the one that can respond with something meaningful. Some of the bots are made stateless, however, for most of the purposes, you need to program step-by-step logic of different scenarios to enable effective dialogue flow.

building-your-bot-or-where-real-difficulties-come-up

So you need to make your bot remember user’s inputs and save information and quickly retrieve it when it’s needed. So you may need to learn more about the ways of storing data (in case if you’re not knowledgeable so far). Further, you may face the need to optimize the way you picked up in the beginning.

To get familiarized with the chatbot architecture check this article.

You face a problem trying to teach your bot on given amount of data. Suddenly you realizing that users almost never say something perfect like:

“I want to buy two-way flight tickets from Kiev to Frankfurt on 24th of October and from Frankfurt to Kiev on 29th of October for the price lower than 200$”.

We would rather write:

“I need to go to Frankfurt on 24th and back on 29th for the cheapest”.

There can be a bunch of examples from different sides yet with the same underlying idea. We’re talking with the chatbot the way we are used to talking to people.

If we can’t do that, why would we ever talk to bot? So you need to feed your bot with a lot of examples and carry on training it with further acquisitions of data. Only real world conversations matter.

Next possible frustration for you is about messaging platforms. You have read so far a lot of articles stating that you can easily deploy your bot on the variety of messengers. But all of a sudden for yourself you understand that each platform has its own intricacies in development and character of the audience.

Now you need to get focused on the target audience and from their develop your decision about platforms. Then you need to learn carefully documentation for developers of those platforms.

Finally, you’re over with development process. After deploying your bot, you’re now sitting and waiting for breath-taking success. But it seems like nothing is changing. Results won’t be observable instantly. You need to be patient. Besides, old friend A/B testing may help.

building-your-bot

Nowadays chatbot development isn’t the most straightforward stuff in the world. Requirements to chatbots become higher. Today you cannot impress anyone with the simple hard-coded app that pretends to be a conversational agent.

Those chatbots are already far behind. And if you don’t want to stay behind as well you need to learn how to make your chatbot smarter. There’s a bunch of useful tools for such tasks but you need to learn how to properly leverage them.

Here are more resources for you to build interesting chatbots.

Apparently, development of your own chatbot isn’t as easy as you can conclude relying on the pile of super-optimistic articles all over the Internet.

If you want to do it right and use it as one of the innovative tools for growing your business, you need to work on it. Not even once but you will need to improve it constantly.

 

Growth Hacker and Sales Hacker, MVP builder, love to run technology companies.