From 3b93518c140b1de1fc2bacc709757cfca6f2c0fd Mon Sep 17 00:00:00 2001 From: Dan Marshall Date: Tue, 5 Apr 2016 16:03:12 -0700 Subject: [PATCH] initial checkin --- README.md | 12 ++++++++++++ index.html | 8 ++++++++ package.json | 26 ++++++++++++++++++++++++++ server.js | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+) create mode 100644 index.html create mode 100644 package.json create mode 100644 server.js diff --git a/README.md b/README.md index d030877d..53210e89 100644 --- a/README.md +++ b/README.md @@ -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. + \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 00000000..58a8d1d3 --- /dev/null +++ b/index.html @@ -0,0 +1,8 @@ + + + EchoBot + + + Hello world! This is the EchoBot home page :) + + diff --git a/package.json b/package.json new file mode 100644 index 00000000..ace397d2 --- /dev/null +++ b/package.json @@ -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" + } +} diff --git a/server.js b/server.js new file mode 100644 index 00000000..a3cb22e1 --- /dev/null +++ b/server.js @@ -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); +});