What is a chatbot? A chatbot is a software that can chat naturally with you and get stuff done for you. It can be built on top of an existing chat platform – like Facebook Messenger or Slack. Or it can be displayed on a dedicated website or mobile app. You can think of it as an interface – instead of building a graphical interface with buttons and sliders, you build a chatbot that just talks with your users.

Chatbot structure

Usually, a chatbot is composed of 4 different components:

  1. Natural language processing
  2. Dialog manager
  3. Content
  4. Custom integrations / external data

The first, Natural Language Processing, is the module that is in charge of analyzing the user requests. It basically takes an unstructured phrase sent by the user and turns it into structured data. For example, this component will turn this phrase:

I would like a pizza tonight

Into an object that can be manipulated by the chatbot codebase. Something like:

{
  "intent":"delivery",
  "object":"pizza",
  "time":"12/02/2017 8:00pm"
}

You can build such component in-house. I find it more interesting to use a third-party service. There are a lot of moving parts in order to get this right, and it is a task that does not change much from one chatbot to another. There are lots of tools out there that allows your development team to tackle this challenge. I personally like Dialogflow and wit.ai a lot, since they are easy to use and free. If you want to host such a solution into your data center, I would suggest taking a look at Rasa.

The second, the Dialog Manager, is the component that kicks in next. It is in charge to decide what to say to the user, given its input, the user past interactions, and other data which may be pulled from other sources (more on this later). The dialog manager may be as simple as a series of IF statements – if the user says pizza, ask him which kind of pizza he would like. It may get very big and complicated fast. A more complex example may be:

IF the user is asking me "when",
AND our last interaction was about a pizza delivery,
AND the user has ordered a pizza in the last 3 hours,
THEN tell him when his pizza is on his way

As with the Natural Processing Module, you may build this in-house or use an off-the-shelf solution. Dialogflow can help you again. If you need to host such a solution into your data center, you can take a look at BotPress. I personally prefer to build my own custom code for this task: I like to have as much flexibility as possible, as this part can change a lot depending on what I’m building. Also, it’s not so expensive to build, given that is basically a flow manager.

The third component is the content, which is basically the template of what your bot is going to say once it decided what to say. This component is of course very custom as it changes completely based on your project. The way this content is structured will impact how the user will perceive the chatbot, both from a UX and marketing point of view. Following the previous example, the content may be something like:

Hi {NAME}! Your pizza will be there at {DELIVERY_TIME}

The Dialog Manager will replace the variables with the appropriate values retrieved in the previous steps. This component can be built in-house or you can use third-party tools. I like to use third-party for this component as it allows me to iterate on the content and previewing it before building the chatbot. This way, I can be sure that the interaction that we are going to build is the best user experience possible given the business objective. The best third-party tools are Botsociety (disclosure: I’m the co-founder), Botpress and more.

The fourth component is the Custom Integrations. You may or may not need this component. Usually, more powerful and meaningful bots do. This component pulls data from your web service or databases, runs conditions and informs the DialogManager. So following the previous example, our custom integration would be used to check if the user has previously ordered a pizza by querying our database. In order to get this done, you can use the ‘Webhook’ feature of your dialog manager, and maybe build a dedicated endpoint for that to work. Although this is definitely a possible solution, I find it clunky as you need to condensate all the logic in the endpoint that you are going to create, since you cannot add custom logic to your dialog manager. So you end up calling your endpoint from the dialog manager with a bunch of parameters; the endpoint needs not only to run queries but also run conditions based on the parameters. So I personally like to keep both this component and the dialog manager as custom parts of my codebase.

Please note that this component anatomy is very opinionated, as some may not agree that this is the correct way of describing what is a chatbot and how it is designed and built. On the other hand, I think this framework is very useful when you approach this space.

Other common questions about what is a chatbot

Why do we have the content component? Can’t we generate answers automatically with the A.I.?

You may decide to go down this road, but it may be very risky. Microsoft tried it, and it had to shut down its Twitter bot shortly after as it started to insult users with racial slurs. You are advised

Why would want to build a chatbot in my custom website or app instead of using an existing platform?

To keep full control of your data and experience. This approach is very common in the financial and health sector.

What is a chatbot that uses voice commands?

I usually refer to those as voice bots or virtual assistants. Examples may be Alexa, Siri, and the Google Assistant

What is a chatbot that cannot process anything said by users, but just buttons? Is it a chatbot anyway?

Short answer, yes. You can build a chatbot that shows buttons and multiple choices and avoid the whole the Natural Language Processing altogether. This is actually a pretty valid design decision. The most famous chatbot of this type is Swelly, which we recently redesigned. In my personal opinion, a mix of both approaches brings the best results.

If you want to start designing your own chatbot free today, you can signup for Botsociety here.

Comments


Vittorio Banfi

Co-founder at botsociety.io