Blog by Daniel Hauck. Sysadmin, Developer, Blogger.

Hell yeah, I am a little bit hyped I have to say. And who knows me, that doesn’t happen too often. Not even by a broken exhaust pipe, that makes my little Opel sound like a sports car ;).

On an event by a media university in stuttgart I talked to some students, that had built a chatbot with the Facebook Chatbot API. If that wouldn’t be cool enough that thing was learning and could understand a lot of questions. I was aware, that they couldn’t have built a machine learning system in that short time, so I found out, it was built on wit.ai, so on the same evening I headed to https://wit.ai to learn more about it. And now I am thrilled, to show you how easy it is, to work with their AI.

Get started

“Turn input into action – in less than 5 minutes” – yes, and it’s really that easy.

If you head over to Getting started you get an easy introduction on how to setup and use their API.

After a short explanation you can either sing up with GitHub or Facebook and start creating your own app.

After finishing you have an app called MyFirstApp. I know how creative 😉

But let’s keep it for now, to understand the very basics of wit.ai.

You get a warm welcome, by a (can I say this) fat cat and can now check, how the app understands your sentence.

So let’s feed the AI a bit. Before that I need to give you the idea of the app which I want to build. It will be a very simple bot, that makes it easier for you, to stay up to date with my content. So blog posts, videos, instagram, twitter and so on.

The first question that you would probably ask is “What is the latest blog post?”. Ok, let’s try it.

As you can see, Wit starts guessing, what the sentence could mean. In this example it guesses, that could be message body. That not exactly what we need, so let’s train it and create a new entity, let’s call it blog and give the value latest. Click Validate.

Basically that’s how you let wit learn new stuff. When you now type latest blog post it already guesses right, that we want the entity blog, with the value latest.

Let’s add another one, for videos.

Ok, so we have something, we can work with. For testing purposes, let’s create a command line client in python.

CLI-Chatbot

To check what’s already working, I will write a really quick and dirty python script, to talk to wit.ai. So don’t use this code in production, really 😉

First things first, let’s install the python lib with pip

pip install wit

And bam, here is the quick and dirty script, to query your chatbot with python:

So copy it, and just change the token and you are ready to go!

Now you can ask questions on the command line, awesome! It’s time to ask questions and tune the AI behaviour. If you want to adjust the data or add more training data, you can easily go to the Understanding tab and change the data or add new.

One hour later, probably less

Ok, so I took some time and hammered in a few questions and adjusted the results. So I am quite happy now, with the outcome.

In the next part, I want to show you how to use the results from the api and get them into action by querying my wordpress blog.

Until then, subscribe to my social networks, to stay up to date and don’t forget to check my youtube channel!


There are no comments.

Leave a Reply