Streamlining Conversations and Information Exchange on Slack with Smart Chatbot

Chatbots are highly functional, handy, specifically programmed bots that seamlessly integrate with your app. They are triggered by commands that are easy for humans to understand and enter – such as a chat message – and then the bot delivers what you asked for. In other words, you can use them to run automated tasks on an app – such as retrieving specific information – without having to do it yourself again and again.

In fact, they are the next big thing in the app world – and have become integral components of some of the most popular apps such as Slack, Facebook Messenger, and Telegram—here are a few real-life examples of how chatbots bring highly useful functionality to Slack:

Optimizing Teamwork: let’s say you have to plan a new project and assign tasks to different team members. Without a bot, you will have to type it out and post the tasks to assigned persons in individual or group threads. Whereas chatbots associate with the Workstreams app on Slack can do it for you, in a matter of a few seconds.

Conversational Marketing: Another critical use of chatbots is in conversational marketing. Gone are the days when dedicated personnel sat in front of chat windows to answer the barrage of queries coming from customers visiting your website. Once you train a chatbot to answer the common questions that customers ask, it can automate that task for you.

How Do Slack Bots Differ from Human Users?

In fact, bot users on Slack are actually very similar to human users in many ways – for example, bot users have usernames, profile pictures, can send and receive messages, upload files, and can participate in Slack channels – some bots even have a good sense of humour! 

However, bots don’t access slack through a desktop or mobile Slack app. Instead, they use specifically programmed tokens that access targeted Slack APIs. In other words, they don’t ‘log-in’ to Slack using a user-name and password combination – instead they use Slack APIs to access threads and channels that humans can have access to.

How do Slack Bots Differ from Slash Commands?

As mentioned earlier, Slack effectively sees bots as users, a slash command, on the other hand, is an utility for Slack whose functionality can be triggered by a command line. It has a pre-defined syntax, and the program is only able to see the command line. Similarly, it can respond to that command only in a limited manner. Slash commands are great when you have a fixed set of interactions, and need to trigger a process on behalf of the user, or report structured data back to the user.

We will be deploying our bot on pythonanywhere.com which will give our bot the capability to interact over Slack via slash commands. Please follow this link to know more about how to deploy your service on pythonanywhere.com.

Registering Application on Slack

Creating Slack App is very easy. It requires user to add certain application level specifications and then you are good to go.

  1. Click here to see dashboard of all the application created by the user.
  2. Click on Create New App and you will see the below screen. Here, user needs to write application name and specify the development workspace.

3. Under Basic Information from settings navigate to Display Information, wherein, you can provide cosmetics to your application.

4. Slash Commands under Features let’s user define new specification to new slash commands. Here, the Request URL field has to point to your code that is deployed on the server.

Types of Bots on Slack

There are two types of Slack bots – custom bots and app bots.

  1. Custom bots are tailor-made to the needs of a given organization or group, and are not distributed to other workspaces.
  2. App bots are distributable bots with generic features, that are attachable to various Slack apps.

As a matter of fact, chatbots can be trained to answer questions on popular public topics like weather reports, current affairs, etc. as well as questions pertaining to a specific domain such as a  company’s frequently asked questions (FAQs).

In this blog, we will build a retrieval-based, narrow-domain, model that can answer queries such as FAQs about our organization – FORMCEPT. Since, FAQs have a limited number of questions with fairly standardized answers, we need not use  sophisticated techniques like RNN/LSTM. In fact, we have studied the working of a few popular language-agnostic, open-source chatbot projects. We have found that these work incredibly well for limited data and claim to improve with larger data. One of the projects that has caught our eye is the Chatterbot project.

How Does Chatterbot Work?

ChatterBot is an adapter-based utility which mimics a newborn baby when it comes to managing unknown instances. Just like a baby has no prior knowledge to communicate but builds its own knowledge repository slowly and gradually, Chatterbot does the same by organizing the questions and responses in a structured format.

Some of the adapter functions that Chatterbot supports are:

  1. Storage Adapters
  2. Logic Adapters
  3. Input / Output Adapters

Storage Adapter helps Chatterbot store the Knowledge it has learnt over a period of time. We have experimented with JSON and MongoDB and have found out that JSON is better when it comes to handling small data, whereas, MongoDB outperformed JSON and other possible sources when it comes to handling large data.

Logic Adapter is the heart of the Chatterbot. Using Logic adapter, you can define the string-matching metric that the bot should use, how should the bot react if it doesn’t know the response to a question or if the confidence is considerably less for a certain response. Also, we can tell the bot whether it can answer to time-based queries or even evaluative queries.

Input/Output Adapters lets you define the interface over which the bot will talk and respond to the questions. Chatterbot already contains packaged HipChat, Gitter, Mailgun, and other services for the creator. Also, you can define a service of your own if you want.

Please click here to know more.

Our Architecture: How Does it Work?

This is how the architecture would execute in real life: Let’s say a user wants to know about the products and services we offer. He enters the question at slack interface, possibly in the following syntax:

/mecbot what are formcept products?

Here, /mecbot is the signature command line that the user needs to write for Slack to know which service to send the question to. This happens through interactions of Slack with a database that has mappings embedded onto it. After getting the mapping, Slack sends the query to our server, where the main Chatbot code is.

When our server gets the question, it would first classify the question in one of the two classes, namely:

  1. Company Questions i.e. a query related to our organization, such as when was it founded, what are the products and services offered, where are the headquarters located, etc.
  2. Greeting Questions i.e. usual etiquette words such as hi, good morning, hello, etc.

After that we extract keywords from the query that user has entered. For example, in this case, ‘MECBOT’ and ‘Products’ are the keywords, and ‘what’ and ‘are’ are noise words that will not affect the answer in any way. This segregation happens at the pre-processing stage so that the data becomes ready for triggering answers from the database.

There are two ways in which answers can be triggered:

  1. Retrieval Method: The bot is trained to detect specific questions and retrieve the corresponding answers. This limits the bot’s response to pre-loaded answers.
  2. Generative Method: The bot feeds on the pre-loaded answers and can be trained to correlate related questions using keyword match, pattern match, verbal logic, etc. and can even answer unknown questions accurately to some extent.

Using the keywords the bot then searches our database, which has the possible question & answer pairs already stored in it. It then tries to find the closest question containing the existing keywords from the database and retrieves the response of the corresponding question from the Database to return it to Slack.

Concluding Note

Chatbots have become indispensable for practical applications of Slack and many other apps because of their functional value and high specificity. At FORMCEPT, we are constantly experimenting with cutting-edge technology to evolve with time and upgrade our solutions to the current trends. To know more about what we do and how we can help you, please visit www.formcept.com or write to us at contactus@formcept.com.

Leave a Reply