Startertutorials Blog
Tutorials and articles related to programming, computer science, technology and others.
Subscribe to Startertutorials.com's YouTube channel for different tutorial and lecture videos.

Categories: Technology. 11 Comments on Microsoft Bot Framework on Ubuntu
0
(0)

In this article we will learn to implement Microsoft Bot Framework on Ubuntu. First we will learn to setup the Bot Framework and see a working example.

 

To run your first chat bot using Microsoft’s Bot Framework, we need to install the following:

  • Node JS
  • Bot Framework Emulator

 


Subscribe to our monthly newsletter. Get notified about latest articles, offers and contests.


Installing and Testing Node JS on Ubuntu (Linux)

Open terminal and type or copy-paste the following commands one by one:

sudo apt-get install python-software-properties
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install nodejs

 

That’s it! You have installed Node JS.

 

To check the version of node.js you can type the following command:

node -v

 

You will see 7.4.6 (This might change for you).

 

Now to test whether node.js is working or not, open a file named hello.js using an editor (like gedit) and type the following line:

console.log("Hello, World!")

 

Save the file.

 

In the terminal window, to execute the above .js file, type the following command:

node hello.js

 

If you see Hello, World! Node JS is running without any problems. 😀

 

Building Our Chat Bot

Create a folder called bot by typing the following command:

mkdir bot

 

Change the current directory to above bot directory by typing the following command:

cd bot

 

Type the following command:

npm init

 

Keeping hitting enter key until it asks you to type yes. Finally type yes and hit enter.

 

Now, we will install two node.js packages named botbuilder and restify by typing the following commands:

npm install --save botbuilder
npm install --save restify

 

Create a file app.js using any editor (like gedit) and copy-paste the following code in that file:

var restify = require('restify');
var builder = require('botbuilder');

//=========================================================
// Bot Setup
//=========================================================

// Setup 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 bot
var connector = new builder.ChatConnector({
    appId: '',
    appPassword: ''
});
var bot = new builder.UniversalBot(connector);
server.post('/api/messages', connector.listen());

//=========================================================
// Bots Dialogs
//=========================================================

bot.dialog('/', function (session) {
    session.send("Hello World");
});

 

You can run the above file to create a server (bot) which listens to clients by typing the following command:

node app.js

 

Now its time to test out our bot. To do that we will download and install Bot Framework Emulator.

 

Installing Bot Framework Emulator on Ubuntu (Linux)

Open the following Github URL in browser:

https://github.com/Microsoft/BotFramework-Emulator/releases

 

In terminal verify the architecture of your machine by typing the following command:

arch

 

Based on the architecture, download appropriate file from the Github page which was opened above. In my case I downloaded following file:

botframework-emulator-3.5.25-ia32.AppImage

 

After downloading right click the file, select properties, go to permissions tab and check the option Allow executing file as a program and close the dialog box.

 

Now double-click the file botframework-emulator-3.5.25-ia32.AppImage and click yes.

 

Now you can open the prompt and click the botframework emulator icon to open the emulator.

 

Select the URL (like http://localhost:3978….) at the top in the emulator.

 

Type hi in the emulator and click on send button. Server (bot) will send you the response Hello World.

 

That’s it. You have run your very own first chat bot using Microsoft Bot Framework and Node JS on Ubuntu (Linux). 🙂

How useful was this post?

Click on a star to rate it!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Suryateja Pericherla

Suryateja Pericherla, at present is a Research Scholar (full-time Ph.D.) in the Dept. of Computer Science & Systems Engineering at Andhra University, Visakhapatnam. Previously worked as an Associate Professor in the Dept. of CSE at Vishnu Institute of Technology, India.

He has 11+ years of teaching experience and is an individual researcher whose research interests are Cloud Computing, Internet of Things, Computer Security, Network Security and Blockchain.

He is a member of professional societies like IEEE, ACM, CSI and ISCA. He published several research papers which are indexed by SCIE, WoS, Scopus, Springer and others.

11 Comments

You can follow any responses to this entry through the RSS 2.0 feed.

I am getting a bad request error. What am I doing wrong?

    Can you tell at which step your are getting this error? More information can help.

Is asking Microsoft App ID, Microsoft App Password and Locale;
connect ECONNREFUSED 127.0.0.1:3978 => I am getting this error when I typed Hi.

    In the app.js file provide your Microsoft App ID and App Password on lines 16 and 17 and then try again.

This was one of the best tutorial i found working
Thank you!…

Thanks! I was having a trouble on how to convert the appimage into an executable, nice article!

Very useful stuff

Thanks, great tutorial! A very easy explanation on how to get started with node.js.

Leave a Reply

Your email address will not be published. Required fields are marked *