Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Getting Started with Microsoft Bot Framework

963 views

Published on

Get started with Microsoft Bot Framework and learn how to build a chat bot with these tools.

Published in: Technology
  • Be the first to comment

Getting Started with Microsoft Bot Framework

  1. 1.        
  2. 2.  
  3. 3.
  4. 4. http://tracerybot.azurewebsites.net
  5. 5. # Logs logs *.log npm-debug.log* .vscode # Runtime data pids *.pid *.seed # Directory for instrumented libs generated by jscoverage/JSCover lib-cov
  6. 6. # TraceryBot Your personal GitHub code repository README contents You can add any content that you would like to be displayed on your Github code repository page.
  7. 7. { "name": "tracerybot", "version": "1.0.0", "description": "Build a bot in Node.js on Microsoft Bot Framework usin "main": "app.js", "dependencies": { "botbuilder": "^3.3.0", "express": "^4.14.0", "https": "^1.0.0", "restify": "^4.1.1", "tracery-grammar": "^2.7.2" }, "devDependencies": {}, "scripts": { "test": "echo "Error: no test specified" && exit 1"
  8. 8. <!doctype html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1 <title>TraceryBot</title> </head> <body> <iframe src="https://webchat.botframework.com/embed/TraceryBot?s=d style="height: 502px; max-height: 502px;"></iframe> </body> </html>
  9. 9. //Add your requirements (as seen in package.json). var restify = require('restify'); var builder = require('botbuilder'); var tracery = require('tracery-grammar'); // 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); }); //Direct to index.html web page server.get('/', restify.serveStatic({ directory: __dirname, default: '/index.html'
  10. 10. // Create chat bot //Generate your appId and appPassword by registering a bot: // dev.botframework.com var connector = new builder.ChatConnector({ appId: process.env.MY_APP_ID, appPassword: process.env.MY_APP_PASSWORD }); var bot = new builder.UniversalBot(connector); server.post('/api/messages', connector.listen());
  11. 11. ( 'origin': 'Hello, world' console.log(grammar.flatten('#origin#')); //========================================================= // Bots Dialog //========================================================= bot.dialog('/', function (session) { session.send(grammar.flatten('#origin#')); });
  12. 12. Dialogs = Routing All bots will have at least one root '/' dialog • Dialog Handlers • Waterfall • Closure • Dialog Object • SimpleDialog
  13. 13. Dialogs = Routing
  14. 14. Hello, world! Hello, world! Hello, world! Create text output var grammar = tracery.createGrammar({ 'origin': ['Hello, world'] })
  15. 15. Hello, world! Hello, world! Hello, world! Use a replacement symbol to create text var grammar = tracery.createGrammar({ 'noun': ['world'], 'origin': ['Hello, #noun#!'] })
  16. 16. hello, world! hello, world! hello, world! Use replacement for additional output components var grammar = tracery.createGrammar({ 'noun': ['world'], 'verb': ['hello'], 'origin': ['#verb#, #noun#!'] })
  17. 17. Hello, world! Hello, world! Hello, world! Add modifiers to grammatically change capitalization prepend a/an, etc. var grammar = tracery.createGrammar({ 'noun': ['world'], 'verb': ['hello'], 'origin': ['#verb.capitalize#, #noun#!'] }) grammar.addModifiers(tracery.baseEngModifiers);
  18. 18. Aloha, planet! Hello, universe! Hello, world! Goodbye, world! Add additional replacement values for var grammar = tracery.createGrammar({ 'noun': ['world', 'planet', 'universe'], 'verb': ['hello', 'goodbye', 'aloha'], 'origin': ['#verb.capitalize#, #noun#!'] }) grammar.addModifiers(tracery.baseEngModifiers);
  19. 19. //Get Started with Microsoft Bot Framework in Node.js code at docs.botf //Add your requirements (as seen in package.json). //These dependencies are installed through Node.js command prompt with //npm install --save tracery-grammar var restify = require('restify'); var builder = require('botbuilder'); var tracery = require('tracery-grammar'); // Setup Restify Server //"npm install --save restify" sets up a server to host your bot online var server = restify.createServer(); server.listen(process.env.port || process.env.PORT || 3978, function ()
  20. 20. Seamlessly provide disruptive growth strategies with agile scenarios. Completely bring disruptive cloud solutions from self-sustaining metrics. Efficiently administrate cutting-edge apps within extensible growth strategies. Seamlessly administrate robust metrics of cross-platform metrics.
  21. 21. • steps: http://aka.ms/SarahSexton • GitHub.com/SarahSexton/TraceryBot • TraceryBot.azurewebsites.net • slides: http://aka.ms/BotFramework • http://dev.botframework.com

×