Example #1
0
function notify(mode, oid){
	console.log('begin dialog');
	orderid = oid;
	console.log(orderid +" orderid");
	
	var arr = ["8:live:officialdharam","8:growoncloud"];
	for(var i = 0 ; i < arr.length ; i++){
		if(mode == "skype"){
			console.log("skype");
			bot.beginDialog({
				to: { "address": arr[i], "channelId": "skype" , "id": "7JitRpa2At5", "isBot": false},
				from: { "address": "notfbot", "channelId": "skype", "id": "notfbot", "isBot": true},
				text: "Notify Usecase"
			}, '/');
		}else if(mode == "phone"){
			bot.beginDialog({
				to: { "address": "+16175383601", "channelId": "sms" , "id": "7JitRpa2At5", "isBot": false},
				from: { "address": "+12292990653", "channelId": "sms", "id": "notfbot", "isBot": true},
				text: "Notify Usecase"
			}, '/');
		}else if(mode == 'emulator'){
			bot.beginDialog({
				to: { "address": "User1", "channelId": "emulator" , "id": "7JitRpa2At5", "isBot": false},
				from: { "address": "testbot", "channelId": "emulator", "id": "testbot", "isBot": true},
				text: "Notify Usecase"
			}, '/');
		}
	}
}
Example #2
0
        , function (error, response, body) {

        if (!error && response.statusCode === 200) {
            var vacancy = body.list;
            
            //var strlist = '';
            // return befor commit (crash emulator)
            /*for (var i = 0; i < vacancy.length; i++) {  //
                //var strlist = '';
                strlist += '###' + vacancy[i].topic + '\n\n';              
                strlist += vacancy[i].description_short; 
                strlist += '\n\n';
                strlist += vacancy[i].url;  
                strlist += '\n\n\n\n';                          
            }     
            
            if (strlist != '') {
                bot.beginDialog({ from: userData.from, to: userData.to }, '/notify', , strlist);
            }*/

            //console.log('vacancy', vacancy.length);   
            if (vacancy && vacancy.length) {
                bot.beginDialog({ from: userData.from, to: userData.to }, '/notify', vacancy);
            }  
            else {
                 bot.beginDialog({ from: userData.from, to: userData.to }, '/notify', vacancy);
            }                  

            //console.log(strlist);            
            console.log('sendWork end');             
        }
    });
Example #3
0
setInterval(function () {
    var now = new Date().getTime();
    for (var key in alarms) {
        var alarm = alarms[key];
        if (now >= alarm.timestamp) {
            cortanaBot.beginDialog({ from: alarm.from, to: alarm.to }, '/notify', alarm);
            delete alarms[key];
        }
    }
}, 15000);
Example #4
0
var restify = require('restify');
var builder = require('botbuilder');

// Create bot and add dialogs
var bot = new builder.BotConnectorBot({ appId: process.env.BotAppId, appSecret: process.env.BotAppKey});

bot.add('/', function (session) {
    if (!session.userData.name) {
        session.beginDialog('/profile');
    } else {
        session.send('Merhaba %s!', session.userData.name);
        session.beginDialog('/menu');
    }
});
bot.add('/profile', [
    function (session) {
        builder.Prompts.text(session, 'Merhaba.Daha iyi yardımcı olabilmem için adını öğrenebilir miyim?');
    },
    function (session, results) {
        session.userData.name = results.response;
        session.userData.welcome=false;
        session.beginDialog('/menu');
    }
]);
bot.add('/menu', [
    function (session) {
        if(session.userData.welcome==false)
        {
            session.send('Tanıştığımıza memnun oldum %s!', session.userData.name);
            session.userData.welcome=true;
        }
Example #5
0
var restify = require('restify');
var builder = require('botbuilder');

// Create bot and add dialogs
var helloBot = new builder.BotConnectorBot({ appId: 'yourid', appSecret: 'bf738605a4ba4bda9d1bbeba3da00ae5' });
helloBot.add('/', new builder.CommandDialog()
    .matches('^set name', builder.DialogAction.beginDialog('/profile'))
    .matches('^quit', builder.DialogAction.endDialog())
    .onDefault(function (session) {
        if (!session.userData.name) {
            session.beginDialog('/profile');
        } else {
            session.send('Hello %s!', session.userData.name);
        }
    }));
helloBot.add('/profile',  [
    function (session) {
        if (session.userData.name) {
            builder.Prompts.text(session, 'What would you like to change it to?');
        } else {
            builder.Prompts.text(session, 'Hi! What is your name?');
        }
    },
    function (session, results) {
        session.userData.name = results.response;
        session.endDialog();
    }
]);


var server = restify.createServer();
Example #6
0
const builder = require('botbuilder');

const DialogAction = builder.DialogAction;
const Message = builder.Message;
const Prompts = builder.Prompts;
const prompts = require('./prompts');

const
    spawnSync = require( 'child_process' ).spawnSync

// Create bot
const appId = process.env.CHATFUELBOT_ID
const appSecret = process.env.CHATFUELBOT_SECRET


var bot = new builder.BotConnectorBot({ appId: appId, appSecret: appSecret });

// Install logging middleware
bot.use(function (session, next) {
    console.log('Message Received: ', session);
    console.log('Attachments received: ', session['message']['attachments']);
    next();
});

// routes
bot.add('/', function (session) {
    console.log('at /');
    var cmd = '$HOME/tensorflow/bazel-bin/tensorflow/examples/label_image/label_image --graph=$HOME/chatfuelhack/nets/flowers/output_graph.pb --labels=$HOME/chatfuelhack/nets/flowers/output_labels.txt --output_layer=final_result --image=$HOME/flower_photos/daisy/21652746_cc379e0eea_m.jpg';
    session.send(prompts.wait);

    // exec(cmd, function(error, stdout, stderr) {
Example #7
0
// Setup Restify Server.
var port = process.env.port || 3978;
var server = restify.createServer();
server.listen(port);

// Data enpoint.
var base_url = 'https://health.data.ny.gov'; 
// Base query path.
var query_path = '/resource/cnih-y5dw.json'; 
// Query parameters.
var query_params = '?county=Onondaga&$select=operation_name,%20nys_health_operation_id&$where=starts_with(operation_name,%20%27[name]%27)';
// URL for Eat Safe site.
var url = 'http://eatsafecny.org/'; 

// Create bot.
var bot = new builder.BotConnectorBot({ appId: 'YourAppId', appSecret: 'YourAppSecret' });

// Set up default server route.
server.post('/inspections', bot.verifyBotFramework(), bot.listen());

// Root dialog.
bot.add('/', new builder.CommandDialog()
	.matches('^help', builder.DialogAction.beginDialog('/help'))
	.onDefault(function (session, args) {
        session.beginDialog('/lookup');
    } 
));

// Dialog to lookup inspection results for location.
bot.add('/lookup', function (session) {
    	var client = restify.createJsonClient(base_url);
Example #8
0
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("You said 6/1-2" + 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); 
Example #9
0
const restify = require('restify');
const builder = require('botbuilder');
const moment = require('moment');

const bot = new builder.BotConnectorBot({ appId: 'YourAppId', appSecret: 'YourAppSecret' });

const dialog = new builder.CommandDialog();

bot.add('/', dialog);

// Install First Run middleware and dialog
bot.use(function (session, next) {
  if (!session.userData.firstRun) {
    session.userData.firstRun = true;
    session.beginDialog('/firstRun');
  } else {
    next();
  }
});

bot.add('/firstRun', [
  function (session) {
    session.send('Welcome the WeekBot!\n\nWrite week to get the current week number.\n\nWrite week <week number> to display another week.');
    session.replaceDialog('/');
  }
]);

function weekNumber (session, args) {
  if (args.matches.length >= 2 && parseInt(args.matches[1], 10)) {
    const weekNumber = parseInt(args.matches[1], 10);
    const startDate = moment().isoWeeks(weekNumber).startOf('isoweek');
Example #10
0
var restify = require('restify');
var builder = require('botbuilder');
var caniuse = require('caniuse-query')

// ************************************************

// 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);


// ************************************************

function result_format(session, query, obj) {

    var result_text = "Support information\n\n";

    // 結果テキストを作成
    for (var key in obj) {
        if (obj.hasOwnProperty(key)) {

            if( 'y' in obj[key] ){
                result_text += browser_name_from_key(key) + ": >= " + obj[key].y +"\n\n";
            }else if( 'a' in obj[key] ){
                result_text += browser_name_from_key(key) + ": " + obj[key].a +" (Partial support)\n\n";
            }
Example #11
0
 res.sendFile(__dirname + '/index.html');
});
io.on('connection', function(socket){
 socket.on('chat message', function(msg){
 io.emit('chat message', msg);
 });
});
/*http.listen(port, function(){
 console.log('listening on ' + port);
});*/

var restify = require('restify');
var builder = require('botbuilder');

// Create bot and add dialogs
var bot = new builder.BotConnectorBot({ appId: 'my_bot_1', appSecret: 'b213900f816542e0abf96d6a3d3a9d3b' });
bot.add('/', [
    function (session) {
        builder.Prompts.text(session, "Hello... What's your name?");
    },
    function (session, results) {
        session.userData.name = results.response;
        builder.Prompts.number(session, "Hi " + results.response + ", How many years have you been coding?"); 
    },
    function (session, results) {
        session.userData.coding = results.response;
        builder.Prompts.choice(session, "What language do you code Node using?", ["JavaScript", "CoffeeScript", "TypeScript"]);
    },
    function (session, results) {
        session.userData.language = results.response.entity;
        session.send("Got it... " + session.userData.name + 
Example #12
0
"use strict";

// Node modules
var restify = require('restify');
var builder = require('botbuilder');

// Application vars
var startIntentRegEx = /play\s+high\s+low/i
var endIntentRegEx = /end\s+game/i

// endpoints
var bot = new builder.BotConnectorBot({appId: 'highlowchatbot', appSecret: 'e417a887dc7143fa91f4469eb2177223'});
bot.add('/', function(session) {

	var text = session.message.text;

	if (startIntentRegEx.test(text))
		session.beginDialog('/max-num')
	else
		session.sendMessage(null)
});
bot.add('/max-num', [
	function (session) {
		builder.Prompts.number(session, "What's the max number?")
	},
	function (session, results) {
		var max = results.response;
		if (max == -1)
			session.endDialog("Game ended")

		session.userData.max = max;
Example #13
0
var restify = require('restify');
var builder = require('botbuilder');
const APP_ID = "d43f1f3a-a301-4678-9e67-bdba5aeb1a4a";
const APP_SECRET = "cac9d798565e4b6e9df1a84fa79b9024";

// Create SlackBot and add dialogs
var commands = new builder.CommandDialog();
var bot = new builder.BotConnectorBot({ appId: APP_ID, appSecret: APP_SECRET });
bot.add('/', commands);

// Add commands
commands.matches('pizzatime', [
    function (session) {
        builder.Prompts.choice(session, "What flavor of pizza do you want?", "Pepperoni|Meat Lovers|Hawaiian|Veggie");
    }, 
    function (session, results) {
        session.dialogData.flavor = results.response.entity;
        builder.Prompts.choice(session, "Awesome. What size do you want?", 'Small (10")|Medium (12")|Large (14")');
    },
    function (session, results) {
        session.dialogData.size = results.response.entity;
        session.beginDialog('/addressPrompt', { prompt: "Ok. So where do you want it delivered?" })
    },
    function (session, results) {
        session.dialogData.address = results.response;
        session.send("Ok. So we have a %(size)s %(flavor)s pizza going to %(address)s.", session.dialogData);
        builder.Prompts.confirm(session, "Is that correct?");
    },
    function (session, results) {
        if (results.response) {
            session.send("Great! Your pizza is on its way.");
Example #14
0
var restify = require('restify');
var builder = require('botbuilder');
var request = require('request');
var cheerio = require('cheerio');


var areaMap = {'downtown':'102', 'midtown':'119', 'upper west side':'135', 'upper east side':'139', 'upper manhattan':'144'};



// Create bot and add dialogs
var bot = new builder.BotConnectorBot({ appId: 'apartmentbot', appSecret: '00eed7d3f1404af89d9f9dad303453ee' });
// bot.add('/', function (session) {
//     session.send('Hello World');
// });

var stopMe = false;
var carlinNumber = '+12345679763';
var twilioNumber = '+12343086132';

var myFunction = function() {}

/*var callback = function(num, x) {
  console.log("HERE12:" + x);
  session.userData.apart1 = x;
  session.send(
}*/

var map0 = new Object();
map0['type_nabe'] = '';
map0['listing'] = '';
Example #15
0
var restify = require('restify');
var builder = require('botbuilder');

// Create bot and add dialogs
var bot = new builder.BotConnectorBot({ appId: 'apartmentbot', appSecret: '00eed7d3f1404af89d9f9dad303453ee' });
// bot.add('/', function (session) {
//     session.send('Hello World');
// });
bot.add('/', [
    function (session, args, next) {
        if (!session.userData.name) {
            session.beginDialog('/profile');
        } else {
            next();
        }
    },
    function (session, results) {
        session.send('Hello %s!', session.userData.name);
    }
]);
bot.add('/profile', [
    function (session) {
        builder.Prompts.text(session, 'Hi! What is your name?');
    },
    function (session, results) {
        session.userData.name = results.response;
        session.endDialog();
    }
]);

// Setup Restify Server
Example #16
0
@author: giriganapathy
@since: May 26, 2016 01:32 PM
-----------------------------------------------------------------------------*/
var restify = require("restify");
var builder = require("botbuilder");
var model = process.env.model || "https://api.projectoxford.ai/luis/v1/application?id=83b0d263-bcb7-4ded-b197-95b25ee68030&subscription-key=b27a7109bc1046fb9cc7cfa874e3f819&q=";

/*var helpInfo = {
    helpMessage: "Here's what you can check with me:\n\n" +
    "* Status of pnr <pnr-number>\n" +
    "* Status of train <train-number>\n"
};*/


var dialog = new builder.LuisDialog(model);
var bot = new builder.BotConnectorBot(); //new builder.TextBot();
bot.add("/", dialog);
/*bot.configure({
    userWelcomeMessage: helpInfo.helpMessage,
    goodbyeMessage: "Goodbye..."
});*/

//dialog.onDefault(builder.DialogAction.send("I'm sorry. I didn't understand."));

/*dialog.onBegin(function (session, args, next) {
    if (!session.userData.firstRun) {
        // Send the user through the first run experience
        session.userData.firstRun = true;
        session.send(helpInfo.helpMessage);
        session.beginDialog('/');        
    } else {
Example #17
0
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 LUIS Dialog that points at our model and add it as the root '/' dialog for our Cortana Bot.
var model = 'https://api.projectoxford.ai/luis/v1/application?id=c413b2ef-382c-45bd-8ff0-f76d60e2a821&subscription-key=7b6755bab3a145b39ed171e4fa7b29a1&q=';
var dialog = new builder.LuisDialog(model);
var cortanaBot = new builder.BotConnectorBot(botConnectorOptions);
cortanaBot.add('/', dialog);

// Add intent handlers
dialog.on('builtin.intent.alarm.set_alarm', [
    function (session, args, next) {
        // Resolve and store any entities passed from LUIS.
        var title = builder.EntityRecognizer.findEntity(args.entities, 'builtin.alarm.title');
        var time = builder.EntityRecognizer.resolveTime(args.entities);
        var alarm = session.dialogData.alarm = {
          title: title ? title.entity : null,
          timestamp: time ? time.getTime() : null
        };

        // Prompt for title
        if (!alarm.title) {
            builder.Prompts.text(session, 'What would you like to call your alarm?');
        } else {
            next();
Example #18
0
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 dialog = new builder.CommandDialog();

var bot = new builder.BotConnectorBot(botConnectorOptions);
bot.add('/', dialog);

dialog.matches('poll', [
    function(session) {
        builder.Prompts.text(session, 'What are you trying to decide?');
    },
    function(session, results) {
        session.userData.poll = {
            topic: results.response,
            options: [],
            votes: {},
        }
        session.send('Okay, starting your "'+results.response+'" poll.')
        session.endDialog();
    }
]);

dialog.matches('option', [
Example #19
0
var restify = require('restify');
var builder = require('botbuilder');
var request = require('request');
var morgan = require('morgan');

var server = restify.createServer();

var giphyBot = new builder.BotConnectorBot({ appId: process.env.APP_ID, appSecret: process.env.APP_SECRET });
giphyBot.add('/', function (session) {
    var matched = /\/giphy\s(.+)/.exec(session.message.text);
    if (matched && matched.length > 0) {
        request("http://api.giphy.com/v1/gifs/search?q="+matched[1]+"&api_key=dc6zaTOxFJmzC&limit=1", function (err, res, body) {
            if (err) {
                session.error(err);
            } else {
                var url = JSON.parse(body).data[0].url;
                var msg = session.createMessage(url);
                
                session.send(msg);
            }
        });
    } else {
        //TODO: uncomment if we stop listening on all input
        //session.error(new Error("invalid input"));
    }
});

server.use(morgan("combined"));
server.use(giphyBot.verifyBotFramework());
server.post('/v1/messages', giphyBot.listen);
Example #20
0
var builder = require('botbuilder'),
    restify = require('restify'),
    nconf = require('nconf');

var server = restify.createServer(),
    dinnerBot = new builder.BotConnectorBot();

// Create nconf environment to load keys and connections strings
// which should not end up on GitHub
    nconf 
        .file({ file: './config.json' }) 
        .env(); 

// Instantiate LUIS dialog        
var dialog = new builder.LuisDialog(nconf.get("LUIS_model_URL"));

dinnerBot.add('/', dialog)
dialog    
    .onBegin(builder.DialogAction.send("Hi, I'm DinnerBot!"))
    .on('ListMenu', '/listMenu')
    .on('ListGuests', '/listGuests')
    .on('Rude', '/respondToRude')
    .onDefault(builder.DialogAction.send("I'm sorry. I didn't understand."))

dinnerBot.add('/listMenu', function (session, args) {
    session.send("You asked what is on the menu.");
    session.endDialog();
});
dinnerBot.add('/listGuests', function (session, args) {
    session.send("I'll be there.");
    session.endDialog();
Example #21
0
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);

// Create Luis Dialog
var dialog = new builder.LuisDialog(process.env.LUIS_APIURL);

bot.add('/', dialog);

dialog.on('About',builder.DialogAction.send('I have a broad range of experience across diverse disciplines, including software development, solutions delivery, strategy consulting, project management, market analysis, technical pre-sales support, crafting compelling presentation material, and public speaking. As a result, I possess the ability to empathize, understand, and interface with both business audiences (customers, stakeholders, management) as well as technical staff (engineering, IT). In my current role as a Senior Software Engineer / Technical Evangelist for IBM I showcase IBM\'s superiority across a wide portfolio of products covering everything from IoT, mobile development, DevOps, social, and enterprise collaboration. I present at customer conferences worldwide  as well as advise internal product management on how to improve our products. '));
dialog.on('Strengths', builder.DialogAction.send('1.I absorb information quickly, I can take large quantities of information or complex topics and distill them down into simple concepts.2. I can quickly locate the answers to queries / resolve any questions 3. I drive projects to completion.4. I bring a broad range of experience across multiple disciplines, from programming, to solutions delivery, to strategy consulting, to competitive analysis and sales. I believe I can bring a wide perspective to the team across technologies and industries.5. I am equally comfortable working with technical as well as business audiences and can tailor my dialogue or approach depending on who I am interacting with. So on the one hand I am converse with the developers about development tools, approaches etc, but at the same time I am can work with the customers or business owners about their issues and empathize with them.6. I am comfortable presenting to large crowds/audiences'));
dialog.on('Weaknesses', builder.DialogAction.send('I intensely dislike confrontation, I find it hard to say no to tasks which means I get saddled doing things I don’t want to do sometimes. How do I fix this? I ask for some time to provide an answer. Then I can think about it and provide a measured response that I like to write down before I take a deep breath, bite the bullet and do it.'));
dialog.on('Education', builder.DialogAction.send('I have a B.Sc. in Computer Science from Bob Jones University'));
dialog.on('Certifications', builder.DialogAction.send('I am a Project Management Professional (PMP)'));
dialog.on('Title', builder.DialogAction.send('I am a senior software engineer as well as technial evangelist with IBM Analytics'));
dialog.on('WorkExperience', builder.DialogAction.send('I’m currently a senior software enigneer with the Competitive Project Office in IBM Analytics. I cover products in the mobile, DevOps, IoT, as well as Enterprise Social Solutions portfolio. That means I have to be familiar with both our products as well as those of the competition such as Microsoft and Google. My role is both internal as well as external facing. On the one hand I travel around the world delivering a series of roadshows to customers touting the competitive advantages of our products vis-à-vis the competition. This is a half-day session where 2 of us will deliver both presentations as well as technical demos to showcase our superiority. On the other hand I consult with the product development teams to keep them abreast of the competition and to make them aware of areas where we are falling behind. I do walkthroughs with PMs to make sure they understand the gravity of the situation. At the same time I also help our field sales folks close deals where there is a significant competitive threat, whether it’s a greenfield, head to head, or defend opportunity. Before this I was a strategy consulting with BCS. I worked mainly with financial service/insurance clients to help them align their business strategy with technology initiatives. I would come in, conduct interviews with the client to understand their goals, current infrastructure, and then apply a model such as heatmaps, component business modeling etc to help them prioritize. Finally I would create a roadmap for implementation. I started out in IBM as a solutions consultant where I worked with clients across APAC and the USA implementing software solutions built on IBM platforms. In the beginning this was primarily using Domino, but over time grew to include WebSphere and Commerce. For more detail please check my LinkedIn profile at [LinkedIn profile](http://www.linkedin.com/in/timchoo)'));
dialog.on('Patents', builder.DialogAction.send('Yes, United States US 20070276676 A1 Social Information System'));
dialog.on('Skills', builder.DialogAction.send('I have skills in Javascript, Java, Eclipse, Xcode, Swift/iOS, MobileFirst Platform, MobileFirst Quality Assurance, JQuery, Bootstrap, WordPress, Windows 10 IoT, Azure, Bluemix, SalesForce Chatter, Microsoft Office 365, Yammer, SharePoint, Exchange, Lync, InfoPath, Amazon WorkMail, Slack, Google Apps, Atlassian Confluence, Socialcast, Adobe Experience Manager, WebSphere Portal, Domino, IBM Connections, Sametime, JBoss, MyEclipse, Git, TeamForge, Subversion, JIRA, Good Technologies MDM, Xtify, Urban Airship, strategy consulting, conducting workshops/facilitating, project management, SCRUM, utilizing prioritization frameworks (heatmaps, BCD, Component business modeling)'));
dialog.onDefault(builder.DialogAction.send("Please ask me a question about my resume/CV. You can ask me about myself, my current role, my work history, my skills, experience, certifications, patents, etc."));

bot.configure({
    userWelcomeMessage: "Welcome to Tim's CV Bot",
    goodbyeMessage: "Goodbye"
Example #22
0
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("Here is a final thought: " + 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('/privacy/', restify.serveStatic({
	'directory': __dirname,
	'file': 'privacy.html'
}));

// Serve a static web page
server.get(/.*/, restify.serveStatic({
Example #23
0
var restify = require('restify');
var builder = require('botbuilder');

// Create bot and add dialogs
var bot = new builder.BotConnectorBot({ appId: 'YourAppId', appSecret: 'YourAppSecret' });
bot.add('/', new builder.CommandDialog()
    .matches('^game', builder.DialogAction.beginDialog('/gameSelection'))
    .matches('^playgame', builder.DialogAction.beginDialog('/gameSelection'))
	.matches('^changegame', builder.DialogAction.beginDialog('/gameSelection'))
    .matches('^quit', builder.DialogAction.endDialog())
    .onDefault(function (session) {
        if (!session.userData.currentSelectedGame) {
            session.beginDialog('/gameSelection');
        } else {
            session.beginDialog('/guessMyName');
        }
    }));


bot.add('/gameSelection',  [
    function (session) {
        if (session.userData.currentSelectedGame) {
            builder.Prompts.text(session, 'What would you like to change it to?');
        } else {
            builder.Prompts.text(session, 'Hi! Do you want to play guess my name?');
        }
    },
    function (session, results) {
		if(results.response)
		{
           session.userData.currentSelectedGame = 'guessmyname';
Example #24
0
var index = 0;

var drinks = ['tequila', 'whisky', 'vodka'];
var lastdrink = drinks[0];

// regex matches
var howManyRegExp = /how many/i;
var fuckMeUpRegExp = /f**k me up/i;
var fuckSomeoneUpRegExp = /f**k\s+@(.+) up/i;

function getNewDrink() {
	return lastdrink = drinks[Math.floor(Math.random() * drinks.length)];
}

// endpoints
var bot = new builder.BotConnectorBot({appId: 'Squad', appSecret: '91606fa3e08e456a9b22c244c2589cbf'});
bot.add('/', function(session) {
	console.log(session.message.text);

    var text = session.message.text;
    var drink = drinks[Math.floor(Math.random() * drinks.length)];

	if (howManyRegExp.test(text)) {
		var amount = Math.ceil(3 * Math.random());

		if (amount === 1)
			session.send("take " + amount + " shot of " + lastdrink);
		else
			session.send("take " + amount + " shots of " + lastdrink);

	} else if (fuckMeUpRegExp.test(text)) {
Example #25
0
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, args, next) {
        if (!session.userData.name || !session.userData.human) {
            session.beginDialog('/profile');
        }
        else {
            next();
        }
    },
    function (session, results) {
        session.send('Hello ' + session.userData.name +", it is " + session.userData.human + " that you are a human.");
    }
]);
bot.add('/profile', [
    function (session) {
        builder.Prompts.text(session, "Hi, what is your name?");
    },
    function (session, nameResults) {
        session.userData.name = nameResults.response;
        builder.Prompts.confirm(session, "You are a human, right " + session.userData.name + "?");
Example #26
0
     if (userData.user_professions) {
        session.send(messages.helloText);//session.gettext(messages.helloText,  { user: session.message.from.name }) );  
        session.send(messages.helpMessage);         
     } else {
       session.send(messages.helpMessage); 
       next();
    }

},
function (session, results) {   
    console.log('default 2', userData);        
}
]);


var bot = new builder.BotConnectorBot({ appId: 'xxxtestbot', appSecret: 'a32e7ce9d1b440a5a9f3af39361764af' });
bot.add('/', dcommand);

bot.add('/changew',  [
    function (session) { 
         console.log('changew 1');
         builder.Prompts.text(session, 'минутку');
        //session.send('секундочку');
        changeWork(session);                
    },
    function (session, results) {
        console.log('changew 2');

        var profIds = Array();
        if (results.response && profession_list)
        {
Example #27
0
var restify = require('restify');
var builder = require('botbuilder');

var bot = new builder.BotConnectorBot({ appId: process.env.appId, appSecret: process.env.appSecret});
var url = 'https://api.projectoxford.ai/luis/v1/application?id=' + process.env.luisId
    + '&subscription-key=' + process.env.luisSubscriptionKey
var dialog = new builder.LuisDialog(url);

bot.add('/', dialog);

// Intent="what_day"の場合の処理
dialog.on('what_day', function(session, args) {
    console.log('message:');
    console.log(session.message);

    var date = builder.EntityRecognizer.findEntity(args.entities, 'builtin.datetime.date');
    console.log('date:');
    console.log(date);

    if (date != undefined && date.resolution != undefined) {
        var d = new Date(date.resolution.date);
        var day = '日月火水木金土'[d.getDay()];
        session.send('その日は「' + day + '曜日」です。');
    } else {
        session.send('日付を取得できませんでした。');
    }
});

// Intent="WhenSubmit"の場合の処理
dialog.on('WhenSubmit', function(session, args) {
    console.log('message:');
Example #28
0
// setup restify server
var server = restify.createServer()
server.use(restify.queryParser())

// setup redis server
var client = require('redis').createClient(process.env.REDIS_URL)
// var client = require('redis').createClient('//localhost:6379')

// ranking system
var Leaderboard = require('leaderboard')
var rankings = new Leaderboard('rankings', null, client)

// create bot and add dialogs
var launchBot = new builder.BotConnectorBot({
	appId: process.env.BOTFRAMEWORK_APPID,
	appSecret: process.env.BOTFRAMEWORK_APPSECRET
	// appId: "launchbottest",
	// appSecret: "3979895f0c004678b344d0c5da3450cb"
})

index.addDialogs(launchBot)


// hello world
server.get('/', function(req, res) {
	rankings.total(function (err, totals) {
		if (err) console.log(err)

		client.scard("optin", function (err, optins) {
			var hello = `
				<html>
					<body>
Example #29
0
/**
 * Created by Sarat Chandra on 4/14/2016.
 */
var restify = require('restify');
var builder = require('botbuilder');

// Create bot and add dialogs
var bot = new builder.BotConnectorBot({ appId: 'Bot4357', appSecret: 'Crusader' });
bot.add('/', function (session) {
    session.send('Hello World');
});

// Setup Restify Server
var server = restify.createServer();
server.post('/api/messages', bot.verifyBotFramework(), bot.listen());
server.listen(process.env.port || 3978, function () {
    console.log('%s listening to %s', server.name, server.url);
});
Example #30
0
        return file;
    });

const dispatcherRegex = new RegExp(`^(${availableDispatchers.join('|')})$`);

program
    .version('0.0.1')
    .option('-s --service <service>',
            `Choose webservice (available: ${availableDispatchers.join(', ')})`,
            dispatcherRegex,
            DEFAULT_DISPATCHER)
    .parse(process.argv);

// Create bot and add dialogs
const bot = new builder.BotConnectorBot({ appId: 'bettercollectiveDemoday', appSecret: 'e725d4760e12476f9f89e8aebf5a4671' });

bot.add('/', session => {
    const q = encodeURIComponent(session.message.text);

    dispatchers[program.service](q)
        .then(res => {
            require(`./actions/${res.intent}`)(session, res.parameters, res.query);
        })
        .catch(err => {
            console.log(err);

            session.send('Failed to use bot');
        });
});