Building a bot
Let us now look at the steps to build a chatbot. Here we will use the botbuilder library and create a bot using Node.js:
- Create a Node.js project called
foodie-bot
:
> npm init
- Install the two libraries that we need to use:
> npm install botbuilder --save > npm install restify --save
- Create a file named
app.js
. - In
app.js
, paste the following code (from the Bot Framework tutorials):
var restify = require('restify'); var builder = require('botbuilder'); // Lets setup the Restify Server var server = restify.createServer(); server.listen(process.env.port || process.env.PORT || 3978, function () { console.log('%s listening to %s', server.name, server.url); }); // Create chat connector for communicating with the Bot Framework Service var connector = new builder.ChatConnector({ appId: process.env.MICROSOFT_APP_ID, appPassword: process.env.MICROSOFT_APP_PASSWORD }); // Listen for messages from users server.post('/foodiebot', connector.listen()); // Echo their...