Created
February 8, 2017 17:07
-
-
Save rcolepeterson/f0dd8e5561fd440ff787846b7f63f72d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('dotenv-extended').load(); | |
var builder = require('botbuilder'); | |
var restify = require('restify'); | |
// 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: process.env.MICROSOFT_APP_ID, | |
appPassword: process.env.MICROSOFT_APP_PASSWORD | |
}); | |
var bot = new builder.UniversalBot(connector); | |
server.post('/api/messages', connector.listen()); | |
// You can provide your own model by specifing the 'LUIS_MODEL_URL' environment variable | |
// This Url can be obtained by uploading or creating your model from the LUIS portal: https://www.luis.ai/ | |
const LuisModelUrl = process.env.LUIS_MODEL_URL; | |
// Main dialog with LUIS | |
var recognizer = new builder.LuisRecognizer(LuisModelUrl); | |
bot.dialog('/', new builder.IntentDialog({ recognizers: [recognizer] }) | |
.matches('Help', builder.DialogAction.send('Hi! Try asking me things like \'who is cole\', \'how sunny is it?\' or \'show me the reviews of The Bot Resort\'')) | |
.onDefault((session) => { | |
session.send('Sorry, I did not understand \'%s\'. Type \'help\' if you need assistance.', session.message.text); | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment