Misc-small-projects/dodsorfas/Skypebot/app.js
Daniel Løvbrøtte Olsen 248ee63072 Made a few more commands
2016-08-13 14:35:16 +02:00

40 lines
1.1 KiB
JavaScript

var restify = require('restify');
var builder = require('botbuilder');
// Bot setup
// restify setup
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());
// Bot Dialogs
var texts = {};
texts.help = "Hey there! My available commands are:\n\n\
about - Gives you information about the bot\n\n\
ping - pong!\n\n\
";
bot.dialog('/', new builder.IntentDialog()
.matches(/^ping/i, function(session) {
session.send("pong");
})
.matches(/^about/i, function(session) {
session.send("I am a general purpose bot created by Daniel, ");
})
.matches(/^help/i, function(session) {
session.send(texts.help);
})
.onDefault(function(session) {
session.send("I didn't understand. Say 'help' to get a list of commands!");
}));