7 Mins
back to main menu

Build a Bot: Your Guide to Build Your Own Chatbot

back to main menu

Build a Bot: Your Guide to Build Your Own Chatbot


Are you here to learn how to build a bot? Then you’re on the right track to digital development

As a product of the good old days, I fondly reminisce about the times when people said companies didn’t need a website, or that a Facebook page was for try-hards and that apps would never catch on.

Gartner estimates that in the next five years, that is, by 2027, chatbots will become the #1 medium of supporting customers.

Customer attention is a zero-sum game, anything that your rival does to hold your target market’s attention is the attention they aren’t paying to you. And while it may seem like no one’s really focusing on digital assistants like Alexa or Google Home at the moment, those who do will have a massive leg up on their competition.

But we’re getting ahead of ourselves.

To understand how you can build a bot, we first need to understand why it is you’re building that bot.

The Verloop.io school of thought stipulates that there are 5 major categories of bots.

  1. Simple Use Case bots- Bots that are built with an easily attainable end goal in mind, like bots that tell you the weather.
  2. Ease of Use bots — Bots designed to reduce the number of steps a specific process takes, and that focus on an “ease of experience”.
  3. Troubleshooting bots- Bots made to help us out when we have a problem, most famously the bot that helps fight parking pickets.
  4. Open Ended bots– Bots that just want to talk, sometimes as your therapist other times as your friend. Bots that more than anything want to beat the Turing Test.
  5. Virtual Assistant bots-Meet your Siri’s, Cortana’s, Google Assistants. Hyper smart, and always at your service.

The categories are assorted by the level of difficulty, from easiest to hardest.

The idea is simple. By the end of this post, you should have a better idea of how to build a bot, regardless of your requirement, from building a simple drag-and-drop bot using an API (think of your application programming interface as a waiter, that’s responsible for ferrying information from your table to a kitchen, and your food from the kitchen back to your table), to something that breaks out of the limitations of linguistic processing platforms to perform complex interactions in user sessions that can last days.

Verloop.io uses its own in-house API, which has an understanding and response rate of 94%, the code for which we can’t publish for fairly obvious reasons. So for the intents and purposes for this article, we’ll plug another free-to-use product, called API.AI

API.AI is a linguistic processing interface. It can receive text, or speech converted to text, and perform much of the comprehension for you. It essentially, it takes the phrase “My name is John and I want pizza today” and splits it up into components like:

Intent: food_request

Action: process_food

Name: John

Food: Pizza

Time: today

This setup means you have some hope of responding to the hundreds of thousands of ways your users could find to say the same thing.

Now, to the tricky stuff.

Build a Bot

Map out your ideal conversation

An oversimplified architecture diagram for Verloop.io

For the first step of the process, you need to create a flowchart for the ideal conversation that a person will have with your bot. Account for salutations, doubts and tangents, while creating a story with a beginning, middle and end. In case you’re planning to build a bot that sells orange juice, it’ll probably go something like this.

Person: Hi.

Bot: Hello. How may I help you today?

Person: I’d like 1 litre of Tropicana 100% Orange Juice.

Bot: Certainly, do you want it delivered to your registered address?

Person: Yes.

Bot: We’ll now direct you to your payment gateway, thanking you for shopping with us.

Map out the million other ways that conversation could go

Now, by experience, I can tell you that the aforementioned is not the way 98% of conversations that people have with bots go. They usually go something like this.

Chaos is underrated.

Person: Hi.

Bot: Hello. How may I help you today?

Person: I’d like some juice.

Bot: Certainly, what juice do you want?

Person: Orange.

Bot: We have Tropicana, Minute Maid, Real and Del Monte.

Person: What’s the cheapest?

Bot: Tropicana 100% Orange Juice.

Person: Alright. I’d like Tropicana 100% Orange Juice.

Bot: Certainly, what quanity?

Person: 1 litre.

Bot: Certainly, do you want it delivered to your registered address?

Person: No, I live somewhere else now.

Bot: Certainly, you can change your address in the next step. We’ll now direct you to your payment gateway, thanking you for shopping with us.

An untrained, unprepared bot is one of the most frustrating things in the world. Account for spelling mistakes, grammatical imperfections and self-professed Turing Test experts and you’ll understand the enormity of the challenge that even the most basic of bots face.

Embody the different kinds of people your bot will interact with, from a 14-year-old goth kid who tlks laik dis to the 80-year-old grandmom who wants to buy her 14-year-old socially awkward grandson a book about why grammar is important. You’re a customer furious about bad service, a middle age mom drunk out of her mind or a millennial just looking.

At every point, document your responses and integrate them into your conversational flow.

Most importantly, set expectations early. Don’t sell your bot as an all-powerful entity that’ll fulfil their every need. Facebook in all its infinite wisdom and funds tried that, and they failed terribly. Let anyone who interacts with your bots know what it can do, and get them started on the right foot.

Suggested Reading: Best Chatbot Examples For Better Customer Service

Create that conversation in api.ai 

Now, if you wanted you could build your own intent classifier system to build a contextual chatbot with TensorFlow, it’d take you a couple of hours.

There are some great articles available on how to go about it, like this guy who built a bot in two hours and this guy who’ll teach you how to build a context driven chatbot.

words = []
classes = []
documents = []
ignore_words = [‘?’]
# loop through each sentence in our intents patterns

for intent in intents[‘intents’]:
for pattern in intent[‘patterns’]:
# tokenize each word in the sentence
w = nltk.word_tokenize(pattern)
# add to our words list
# add to documents in our corpus
documents.append((w, intent[‘tag’]))
# add to our classes list
if intent[‘tag’] not in classes:

# stem and lower each word and remove duplicates
words = [stemmer.stem(w.lower()) for w in words if w not in ignore_words]
words = sorted(list(set(words)))

# remove duplicates
classes = sorted(list(set(classes)))

print (len(documents), “documents”)
print (len(classes), “classes”, classes)
print (len(words), “unique stemmed words”, words)

Microsoft has its own tools as well. The Bot Builder provides an SDK, libraries, samples, and tools to help you build and debug bots.

Your bot should be able to take language as input, understand what the user requires, execute the needful and return with an appropriate response. If you’re wondering why this is so important, it’s because it is absolutely imperative that your bot sounds like a human, otherwise it comes off as massively unappealing.

As with everything that’s involved with Google, Api.ai has a great support system. They have an endless supply of material to help with how to plugin your conversation into the system, which you can read here.

The process is roughly this,

Welcome -> Invocation -> Request -> Intent -> User Says -> Entities -> Fulfilment -> Fulfilment Request -> Response.

Test it out a million times, before, during and after launch to find more alternatives

Practice makes perfect, and that holds especially true with bots. Try different words that mean the same thing, rationalize cultural differences and its translation into word choices.

  • Don’t use Direct Line to load test your bot
  • Create traffic that’s more realistic for bot users
  • Default State API is a frequent choke/bottleneck

{“intents”: [
{“tag”: “greeting”,
“patterns”: [“Hi”, “How are you”, “Is anyone there?”, “Hello”, “Good day”],
“responses”: [“Hello, thanks for visiting”, “Good to see you again”, “Hi there, how can I help?”],
“context_set”: “”

{“tag”: “goodbye”,
“patterns”: [“Bye”, “See you later”, “Goodbye”],
“responses”: [“See you later, thanks for visiting”, “Have a nice day”, “Bye! Come back again soon.”]

{“tag”: “thanks”,
“patterns”: [“Thanks”, “Thank you”, “That’s helpful”],
“responses”: [“Happy to help!”, “Any time!”, “My pleasure”]

As QArea puts it.

The best way to ensure your bot will be launched ready to serve is to beta test it before the start. Once you are done with the basic QA and the chatbot works just as planned, you need to open it to a wider audience. That must be a closed group of users, which literally would try to break your pretty botty and then give you an account of what comes of this.

Saying more scientifically, the beta tester would examine the chatbot with unexpected inputs. These usually include mentioned slang, jargon, colloquial language, also British, Australian, and other English variants. Moreover, the chatbot would be most probably treated like entertainment and besieged with completely irrelevant inputs like the above-mentioned flirting.

Alpha and beta test the absolute crap out of your creation. There are great communities to beta test your bot, like Reddit, Beta Family, TestBirds, Upwork, and HackerNews. We all have certain biases and blocks we can’t get over mentally, that are immediately apparent to our friends and family.

Integrate with slack

What your apps do is up to you — maybe it performs one distinct task incredibly well or perhaps it orchestrates a technological concert between individual Slack features and your internal accounting service.

First-timer or a seasoned veteran? Often it’s best to just get started and learn along the way.

From API.AI’s Slack integration page.

While integrating with Slack isn’t the only tool at your disposal, it’s probably the first third-party integration you’ll undertake to release your bot.

From API.AI’s Slack integration page.

Since by default, newly built Slack apps can only be installed on the workspace they belong to, you’ll also have to run Open Authorization. OAuth (oh-auth) is an open standard for access delegation, commonly used as a way for Internet users to grant websites or applications access to their information on other websites but without giving them the passwords.

Your final product.

Slack underlines the four major steps in the integration process as follows.

  1. Your app begins void of features
  2. Your app has features but can only be installed in your workspace
  3. Your app is open to installation by other workspaces (optional)
  4. Your app is submitted to and/or part of the Slack app directory (optional)

God above knows I couldn’t have done this by lonesome. I’ve tried to attach links to everyone’s work, but special love to Robin Lord, Shival Gupta and gk_ (from whom the code for the article came, here’s his Github profile for more, thank you so much.)

Of course, building a chatbot from scratch is a tedious activity. It takes time, effort and lots of trial-and-error. Hit us up at below mentioned Twitter handle if you have doubts or if you’d like to try our bots out.

Sign up to test our chatbot or if you’re looking for an enterprise-ready chatbot. You can also sign up to have a free demo bot created for your business by Verloop.io.


Notify of
Inline Feedbacks
View all comments
See how Verloop.io helps 200+ businesses scale their support.
Schedule a Demo
Would love your thoughts, please comment.x