Planet of the Bots: Part #1 – Intro to Bots

Karim Alibhai
Hello, JavaScript
Published in
5 min readSep 4, 2016

THE BOTS ARE COMING, THE BOTS ARE COMING.

That’s right, the bots are coming. They’re not only coming, but they’re here to stay. So this would be an incredible time to dive into the world of bots and start making our own.

Welcome to Planet of the Bots. This is going to be a series of blog posts explaining the ins and outs of developing bots. I will cover everything from choosing the right platform to diving into some of the interesting algorithms. The purpose of this post is to introduce you to the idea of a bot and have a look at the considerations we need to remember when building bots.

Considerations:

  • The language of choice for this series is JavaScript but I will try my best to incorporate the considerations for other languages.
  • Experience-level: I am assuming that you have basic knowledge of a programming language and of programming constructs.

Let’s get started.

So what’s a “bot”?

This is a very important question to answer when getting into the world of bots, specifically because it helps us understand the way that bots are being defined by the community.

The best way to think of a bot is as a natural language interface between the user and some service(s). It is not enough for us to define bots as an interface because there are lots of interfaces (i.e. stdin+stdout) that are not feature-full enough to be considered bots. The role of the interface as an input and output system can be considered the bot’s platform.

Outside of the bot’s platform, the bot needs some sort of toolset or framework that will take care of its natural language processing. This framework’s job is essentially to provide simple translation between user-recognizable information and machine-recognizable information. The way this is done is by providing algorithms that allow for programs to extract data from user input. For instance, a pizza ordering bot may extract data such as: the number of pizzas, a common name for a frequent order, the delivery address, etc.

A Look at Bot Platforms

The big new thing that many social media sites are providing now is a full featured API for you to use their service as a platform. For instance, the Messenger Platform allows you to utilize Facebook Messenger as the i/o of your bot. A key point to note here is that not all platforms contain the natural language interface that your bot requires. This does not mean that some platforms are not usable, it simply empowers bot developers to abstract away the platform from the rest of the interface.

This is very similar to the way that we tend to abstract away unit testing frameworks from assertion libraries: both are necessary to write proper automated tests, but the developer can pick and choose his/her favourite combination.

The similarities between these platforms is that they all take an existing medium of communication that many users take advantage of on a daily basis, and they add the ability for your bot to seamlessly interact with the user with the appearance of a user.

Sample conversations with M, a bot utilizing the Messenger Platform as its bot platform.

Choosing the right platform depends entirely on your bot’s requirements. For instance:

  • Does your bot need to cater more to social needs or to business needs (i.e. Messenger vs. Office 365)?
  • Would your bot benefit from a more traditional method of communication? (i.e. SMS/Calling via Twilio)

Bot Frameworks

The frameworks that power bots are a far more interesting part of the bot infrastructure than platforms. Some of the popular frameworks out there that include vital NLP algorithms are: Stanford Core NLP, indico.io, Microsoft Cognitive Services, and IBM Watson Services.

Future posts in this series will include a thorough rundown of each of these tools/services and how they play into the development of bots. For now, what you need to understand is why they exist. The following is a list of some of the popular services provided by these frameworks and their use:

  • Sentiment analysis. Calculates an index between 0 and 1 that describes the amount of positivity contained in a block of text. For instance, the sentence “Bots are so cool!” would be given an index of 0.99 while the sentence “To hell with bots.” would receive 0.32 (analysis done by indico.io).
  • Named entity recognition. Extracts named entities from a block of text. For instance, within the sentence “The Beatles were much better than Kanye West”, we have the entities: The Beatles and Kanye West.
  • Facial detection: Detects the precise location of all the faces within an image.
  • Facial recognition: Extracts the identity of a person based on their facial features.
  • Object Recognition: Classifies recognized objects within a photo. For instance, for the following photo, it may output: bread.

Some Examples

The following is a short list of example bots that you can play with to get a feel for the concepts of bots:

  • Caption Bot — generates a caption for a given photo (via MS Cognitive Services).
  • Thumbprint — visualizes the topics that you like to tweet about (via indico.io).
  • Murphy Bot — brings your “what if” scenarios to life (via Messenger, Skype, and many more)
  • Poncho — displays the weather forecast (via Messenger).
  • Polly — automates the process of polling (via Slack).
  • StatsBot — collects and displays statistics from services like Google Analytics (via Slack).

That’s all, folks. Happy JavaScripting!

Click here to see the full publication where this article is included.

Help me keep things free by using flattr.

--

--