Developer's Introduction To Chatbots
Chatbots have been a trending topic for quite some time now and have got a lot of people excited about them. Some believe that bots are the next big thing and will soon replace apps, while others think they are just a fad, bound to fail.
In this article we will restrain ourselves from giving opinion on the future of chatbots. Instead, we will try to shine some light on how they work, what they can be used for, and how to get one up and running.
What Is A Chatbot?
A chatbot is a service or tool that you can communicate with via text messages. The chatbot understands what you are trying to say and replies with a coherent, relevant message or directly completes the desired task for you.
If you remember CleverBot, you know that the concept of chatbots isn't that new. What makes them so relevant right now is:
- The huge amount of time people spend texting in their messaging apps (Facebook Messenger, Slack, etc.), making messengers a fast-growing market where businesses can engage potential customers.
- The advancements in artificial intelligence, machine learning and natural language processing, allowing bots to converse more and more like real people.
Modern chatbots do not rely solely on text, and will often show useful cards, images, links, and forms, providing an app-like experience.
This allows them to be used for many different purposes such as shopping, customer service, news, games, and anything else you can think of. A good chatbot doesn't have to perform a huge variety of tasks - a bot that shows you the latest news doesn't need to be able to order Chinese food. It does one thing and does it well.
How Do Chatbots Work?
Most people won't build their chatbots from scratch as there are plenty frameworks and services that can help. However, in order to grasp how bots work, we have to go over some developer talk.
Backend: Chatbots can be built in basically any programming language that allows you to make a web API. For most people this will be either Node.js or PHP, but there are many bot libraries written for Java and Python as well. The backend receives messages, thinks of a response, and returns it to the user.
Frontend: This can be one of the popular messengers apps (Facebook Messenger, Slack, Telegram), or a simple chat interface like the Realtime Chat With Node.js we built some time ago. You are not limited to a single platform - the same bot can be implemented in more than one place.
Connecting the two: Your web server will then have to setup webhooks - URL-based connections between your bot and the chat platform. Webhooks will allow you to securely send and receive messages via simple HTTP requests. All of the mainstream messengers provide detailed guides on how to connect your bot to them.
The bot is now connected and can listen and respond to users. The only thing left to do is give it a brain.
Dumb Bots and Smart Bots
Depending on the way bots are programmed, we can separate them in two major categories: command-based (dumb bots) and learning (smart bots).
Command-based bots are structured around specific keywords that the bot recognizes. Each command has to be manually programmed by the developer using regular expressions or other forms of string analysis. If the user says something beyond the programmed scenarios, the bot cannot answer in any helpful way.
Although the capabilities of these "dumb" bots are limited, they are sufficient for the majority of bot designs, especially when combined with other types of UI like multiple choice questions.
Learning bots rely on some sort of artificial intelligence to converse with users. Instead of looking for a predefined answer, smart bots come up with adequate replies right on the spot. They also keep track of the context of the conversation and remember what has been previously said, just like a human would!
Working with natural language processing and machine learning is no easy task, especially for beginner developers. Thankfully, you don't have to all of the work on your own. There are a number of excellent libraries (ConvNetJS, nlp_compromise, TextBlob) and services (wit.ai, api.ai) that can help you with teaching your bot some conversational skills.
Getting Started With Chatbots
If we've managed to pump you up and you want to start building your first chatbot, here are some tips that will get you going. Depending on how much of the work you want to do on your own, you can go full DYI and build your bot from scratch, or you can just use a framework that will save you lots of time.
- BotKit - The most popular toolkit for building bots. Its open-source and very well documented.
- Claudia - Chatbot builder designed for deploying directly to AWS Lambda.
- Bottr - Super simple Node.js framework with built in app for testing. Awesome if you just want to play around for 10 minutes.
Once you've completed your bot, most of these frameworks allow you to easily connect it to the popular messaging platforms, which is a huge timesaver as all the major platforms have different setup processes.
If you want to skip the development process as a whole, you can trust one of the many available bot-building services:
- wit.ai - Service that receives raw text or voice data and uses NLP to help you manage responses.
- Chatfuel - A tool for Facebook Messenger or Telegram bots. No programming involved.
- motion.ai - Full bot building service with support for many texting platforms.
- api.ai - Natural language processing that allows you to make bots and define conversation scenarios.
Although chatbots seem very futuristic, they are already here and are freely available to the public. Below is a list of just a few interesting bots we've stumbled upon. Some of them don't even have to be installed, just find them in Facebook Messenger and say Hi!
- Services and tools - Poncho, FindoBot, Trim
- Retail - Uber, Bly, TacoBot
- Entertainment and News - Digg, CNN, 2048bot
- Customer Service - Oratio, Troops, Helpbot
The idea of chatbots has got developers, businesses and messenger apps all working together, building a totally new ecosystem. We will have to wait and see how well bots will be adopted by the general public, but whether they fail or become the next big thing, we will have some fun playing with AI in the meantime.
We hope this article has been helpful and we've introduced you properly to the world of chatbots. If you have any questions or opinions, feel free to leave a comment below :)