14. # 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.
15. {
"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"
18. //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'
19. // 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());
24. Hello, world!
Hello, world!
Hello, world!
Use a replacement symbol to create text
var grammar = tracery.createGrammar({
'noun': ['world'],
'origin': ['Hello, #noun#!']
})
25. hello, world!
hello, world!
hello, world!
Use replacement for additional output components
var grammar = tracery.createGrammar({
'noun': ['world'],
'verb': ['hello'],
'origin': ['#verb#, #noun#!']
})
26. 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);
29. //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 ()
30. 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.
Git uses it to determine which files and directories to ignore, before you make a commit. A .gitignore file should be committed into your repository, in order to share the ignore rules with any other users that clone the repository.
A readme (or read me) file contains information about other files in a directory or archive and is commonly distributed with computer software, forming part of its documentation.
A package.json file contains meta data about your app. Most importantly, it includes the list of dependencies to install from npm when running npm install.
‘origin’ : ‘Hello, world’
Contains the symbol ‘origin’ that is used to represent the grammar that follows, in this case plain text.
Console.log(grammar.flatten(‘#origin#));
Applies grammar rules and applies symbol substitution to
The main grammar text generator code producing static output
Using a replacement symbol to replace part of the output
Replacing addition output with symbols.
Mention that letter case matches replacement
Mention that modifier is changing case
Explain modifiers
Explain modifiers
Capitalize the works
Make word plural
Prefix with “a” or “an” as appropriate
Add additional replacement values for each symbol
Add complexity to sentence structure.
Add more replacement options for symbols
Etc.
If you want to learn more about chat bots using Tracery, clone my GitHub repository at the URL above!