BotKit.ai + Wit.ai in action- 5 mins
A bot without artificial intelligence can be called a bot? Obviously not. In this tutorial I will try to explain how it is possible, in a few lines of code to add Wit.ai to the Botkit.ai framework.
What are Botkit.ai and Wit.ai?
Botkit.ai is described by its authors in this way:
The official website of the project is https://botkit.ai/
Simplifying, Botkit.ai is a framework that allows you to create bots, in nodejs, in a very simple, and supports virtually any existing chat platform: Web and Apps, Slack, Cisco Webex, Cisco Jabber, Microsoft Teams, Facebook Messenger, Twilio SMS, Twilio IPM, Microsoft Bot Framework, Google Hangouts Chat.
Wit.ai is a project made by Facebook, thanks to it the bot learns by itself, thanks to machine learning, how to respond to users, based on examples of conversation that are submitted to them.
The official website of the project is https://wit.ai/
Wit.ai is described by its authors in this way:
To better clarify the operation of Wit.ai we can refer to the screen below
A user’s phrase (in text or voice mode) is processed and structured. The service will give us back the intent and the values that will allow us to manage the conversation or the operation to be performed
Let’s analyze an example json of an answer received from Wit.ai
User says: “Turn off the lights”
The entity value indicates the calculated action, while value is the value received, in the previous case an on_off with off value was recognized, we can for example interpret it as the switching off of something.
First step, let’s create a Botkit.ai’s project
Let’s get to the heart of the action
Install Botkit Use npm to install Botkit. Use the “-g” flag to install it globally, which makes Botkit’s command line tool available.
Create your bot It’s time to create new Botkit app!
The command line tool will collect a few pieces of information from you, like the name of your bot. Then, it will create a pre-configured and ready-to-customize bot project for you.
Installation complete! To start your bot, type:
Boot it up and say Hello! Next, run the app from the project folder. It’ll boot up and you’ll be able to chat with the bot in your web browser!
I AM ONLINE! COME TALK TO ME: http://localhost:3000
Botkitwit-ts in action
Previously I said that we have to add Wit.ai to Botkit.ai. How you do it? Botkit.ai allows you to use middleware, objects that will intercept our questions, send them first to Wit.ai and forward the json with the reply to botkit.ai.
In this tutorial I will use the middleware developed by me, in typescript, botkitwit-ts (if you find it interesting, rate it :))
First of all we have to add middleware to the project
Once added we can move on to the actual action:
And finally we can test our bot by navigating to http://localhost:3000
This work is distributed under license Creative Commons Attribution 4.0 International.