Skip to content

Commit

Permalink
initial checkin
Browse files Browse the repository at this point in the history
  • Loading branch information
danmarshall committed Apr 5, 2016
1 parent 2412d8e commit 3b93518
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
# echobot
A sample bot for getting started with Bot Framework

This repo is an example of using Node.js to build a bot, which is hosted on Azure and uses continuous deployment from Github.

Here's how to use this bot as a starter template for your own Node.js based bot:

1. Fork this repo.
2. Create an Azure web app.
3. Set up continuous deployment to Azure from your Github repo.
4. Register your bot with the Bot Framework.
5. Enter your Bot Framework App ID and App Secret into Azure settings.
6. Chat with your bot.

8 changes: 8 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<html>
<head>
<title>EchoBot</title>
</head>
<body>
Hello world! This is the EchoBot home page :)
</body>
</html>
26 changes: 26 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "echobot",
"version": "1.0.0",
"description": "A sample bot for getting started with Bot Framework",
"main": "server.js",
"scripts": {
"test": ""
},
"repository": {
"type": "git",
"url": "git+https://github.com/fuselabs/echobot.git"
},
"keywords": [
"botframework"
],
"author": "Fuse Labs",
"license": "MIT",
"bugs": {
"url": "https://github.com/fuselabs/echobot/issues"
},
"homepage": "https://github.com/fuselabs/echobot#readme",
"dependencies": {
"botbuilder": "^0.6.5",
"restify": "^4.0.4"
}
}
32 changes: 32 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
var restify = require('restify');
var builder = require('botbuilder');

// Get secrets from server environment
var botConnectorOptions = {
appId: process.env.BOTFRAMEWORK_APPID,
appSecret: process.env.BOTFRAMEWORK_APPSECRET
};

// Create bot
var bot = new builder.BotConnectorBot(botConnectorOptions);
bot.add('/', function (session) {

//respond with user's message
session.send(session.message.text);
});

// Setup Restify Server
var server = restify.createServer();

// Handle Bot Framework messages
server.post('/api/messages', bot.verifyBotFramework(), bot.listen());

// Serve a static web page
server.get(/.*/, restify.serveStatic({
'directory': '.',
'default': 'index.html'
}));

server.listen(process.env.port || 3978, function () {
console.log('%s listening to %s', server.name, server.url);
});

0 comments on commit 3b93518

Please sign in to comment.