How to Build a Chatbot on Forsta – Part 2

WELCOME TO PART TWO—AN INTRO TO ARTIFICIAL INTELLIGENCE

In part one, we showed how easy it is to set up a bot with Forsta, but as we’ve built it so far, the bot doesn’t exactly chat.

In Part Two, we’ll first examine some of the issues that surround adding AI to chatbots, and then, you’ll connect one to your ForstaBot.

In order to complete the steps here in Part Two, you will need to have already completed everything in Part One.

HAVE YOU HEARD OF THE TURING TEST?

First things first, language is hard. Parsing out nouns from verbs or commands from queries is not a simple task for computers to do. Then after a question or command is parsed, it is even more complicated to create an appropriate response. So, when computer programs are able to accomplish things like language, playing complicated games well, or do other nuanced tasks well—the programs are perceived as intelligent.

Are the programs truly intelligent, or are they just cleverly fooling us into thinking they are… and what is the difference!? The only way we could say that computers are intelligent is when one is able to exhibit intelligent behavior equivalent to, or indistinguishable from, that of a human. Have you heard of the Turing test? Computer science pioneer Alan Turing, posited that when an evaluator cannot reliably tell the machine from the human, the machine is said to have passed the test. The test does not check the ability to give correct answers to questions, only how closely answers resemble those a human would give.

Measuring the intelligence of a human or a computer is not binary—is or isn’t intelligent—but is instead a matter of scale—how intelligent is it? Intelligence whether artificial or not, is measured both on a scale and against a specific task; does it play chess well, how about the piano? So, we’re measuring whether an intelligence is better or worse at a specific skill or task, as compared to other entities performing the same task.

The philosophy of intelligence or epistemology is beyond the scope of this blog, but as we build our own chatbot, we need to think about which intelligences, or skills, we want it to excel in and how to achieve it (or the illusion of it).  We’re primarily concerned with its ability to appear intelligent enough that our customers, clients, and colleagues – are able to get the answers they need from it and not become annoyed or angry at a perceived lack of intelligence.

So, let’s try this out. Let’s connect a proven open-source AI to our code and see if we can tell if it is a bot… or not?

CLEVERBOT.IO
Pasted Image 0

MAKE SURE TO DO ALL STEPS IN PART ONE FIRST.

Replace ‘vim’ in these examples with your text-editor of choice

Make sure you’re inside the message-bot folder
$ cd message-bot/

Stash any changes you may have made to master and create a new branch named after the feature being added. We’re adding Cleverbot, so let’s call it that.
$ git status
$ git stash
$ git checkout -b ‘cleverbot’

Add Cleverbot the to package.json
$ npm install –save cleverbot.io

Get Cleverbot api keys -> https://cleverbot.io/

Add Cleverbot api keys to your path—replacing these keys with yours
$ export CBOT_API_USER=S8yOZUtt7IpSQwOu
$ export CBOT_API_KEY=MSHXgnxUg33eLBjr9j4p8DYo1nEOmwZ9

Add cleverbot.js to forsta_bot.js
$ vim server/forsta_bot.js

at the top of the page, add:

Test locally
$ make realclean
$ make
$ npm start

Go to http://localhost:4096

Test at http://app.forsta.io/@

Does it work? Awesome!

Push code to Github
$ git add package.json server/forsta_bot.js
$ git commit -m ‘wire in cleverbot’
$ git push origin cleverbot

Get your Heroku-app info
$ heroku apps
$ heroku info my-forstabot

Copy/Paste the ‘Git URL:’ address to your git remotes group
$ git remote add heroku

$ git remote -v

Add Cleverbot keys to Heroku—replacing these examples with yours
$ heroku config:set CBOT_API_USER=S8yOZUtt7IpSQwOu
$ heroku config:set CBOT_API_KEY=MSHXgnxUg33eLBjr9j4p8DYo1nEOmwZ9

Push code to Heroku
$ git push heroku cleverbot:master

Test again, does it work on Heroku? Awesome! Now, let’s merge the changes into your master branch.
$ git checkout master
$ git merge cleverbot

AWESOME!

Your new bot is definitely clever… but is it intelligent? Cleverbot participated in a Turing test in 2011 and was judged to be 59.3% human (compared to 63.3% human achieved by a control group of human participants). A score over 50% was considered to be a passing grade.

Artificial intelligence has experienced a leap forward recently due to two things – machine learning via neural networks and huge datasets available to them via almost everyone on the planet constantly talking and messaging to each other via the computers they all carry in their pockets all day.

There are a number of chatbot engines available for anyone to create their own bot with. Engines such as IBM’s Watson, Facebook’s Wit.ai, Amazon’s Lex, Microsoft’s Bot Framework, and Google’s Dialogflow –  all use their own proprietary Artificial Intelligence to parse the queries and responses they receive and return intelligent answers.

These are all very intelligent bots, but they’re not completely open source, so we don’t know exactly what they’re doing with the data we send them; and they are not easy to program custom dialog flows for. Outsourcing all of a  bot’s intelligence to a supercomputer in the cloud, we are forced into trusting them—which is not an option for industries that require regulated communication such as healthcare, and legal or financial institutions, or anyone concerned with maintaining the security of their intellectual property! And fundamentally, we all deserve privacy, no matter what we’re discussing.

However, these are amazing programs that are at the cutting edge of modern AI and we do want to have the ability to leverage them along with protections that our sensitive data isn’t being shared. So, in the next post, we will detail how to program DialogFlow, Google’s powerful AI chatbot builder.