Give Your Product AI-Powered Chatbot

Google Assistant works on Natural Language Processing

As a part of my exploration about AI, I set my goal to share the best tech that I learn.

In this blog post, I will build a bot from scratch that will help you enable Natural Language Processing just by using an Excel Sheet and a Cloud Service by IBM Watson; Natural Language Classifier. I’ll explain how I did it, so you can build your own.

Natural language Processing is a way for computers to analyze, understand, and derive meaning from human language in a smart and useful way. In simple words, NLP minimizes the language barrier between humans and machines exponentially.

It’s not as complicated as it might sound, this tutorial will make things way easier. We’ll build a “Coffee Bot”. Topic too lame right? The fact, this topic is so generic that even a newbie can ramp up quick. Rest assured, it can be used over any topic of your choice.

To start, open an excel sheet. Focus on column A. Now, think from a users perspective (Your end users) and write one question they are bound to ask to your bot.

For Eg: “how are you doing”

Now, assign a Class Name “doing_well” in column B to that respective question. Class Name can be assigned in whatever way you want.

There are many different ways in which a user can ask this same question. In order to make your bot understand the variation in each question and still have the power of figuring out the meaning, we need to train the bot. So, replicate “how are you doing” to atleast 5 or more similar meaning questions. The more, the better.

The question “how are you doing” is replicated to more than 5 similar questions. Note: all these questions belong to the same Class “doing_well”

In this Microsoft Excel Sheet, Column A represent the questions and Column B represent Classes. That’s all that we need.

Bingo! We have reached our first checkpoint. I know that sounds silly but here’s the fact, this Excel Sheet will serve as our “actual” database.

This is just a part of Coffee Bot Corpus (database) to get a basic idea.

As we know, this sheet is our Database, we further need to expand the capabilities of the bot and make it smarter by adding more features to it. I’ll repeat the same steps and create more classes. Each class will represent a feature and it’s unique in it’s own way. For better understanding, I have a few listed down.

Don’t forget, you can always enhance the quality of the Corpus (Database) by adding more classes (Features) to the existing database. Make sure you strictly keep them unique to not confuse the bot.

Once you have your Excel sheet ready with enough classes and questions to support the needs of your bot/product, next step is to train it. To train the database that you created, it strictly has to be saved in .csv format. IBM Watson NLC (Natural Language Classifier) doesn't support any other format.

Checkpoint 2 cleared!

Follow these 10 steps to train the database that you created and bring it to life.

Step: 1 “IBM Natural Language Classifier”

Step: 2 Click “Get started free”

Step: 3 Create a free account

Step: 4 Choose a name for your classifier and click create.

Step 5: Keep your service credentials confidential. This username/password helps you keep your Classifier unique.

Step: 6

Access the beta toolkitClick sign inClick confirm authorization

Step: 7

Add training dataClick upload training dataSelect the .csv fileCreate Classifier

Step: 8 Wait until it gets trained.

Step: 9 This is the final product with a unique classifier ID. Bot ALIVE!

Click the blue arrow to access the classifier.

Step: 10 Ask Questions.

This questions isn’t at all in the database but it still responded with 0.72 (72%) confidence level.

Confidence level above 90% for questions that didn't exist in the database.

Source

Keep testing and adding more questions and classes to the database. Make your bot smarter!

You can integrate this NLP bot with Google Home/Assistant, Alexa, Facebook Messenger, Siri, Stride, Slack or any other smart device/software.

Use the IBM Watson API Endpoint and the Classifier Credentials to connect it with your already existing product and you’re good to go!