Example #1
0
      messagingEvents.forEach((event) => {
        var sender = event.sender.id;

        var bot;
        if (botDict[sender]) {
          bot = botDict[sender];
        } else {
          bot = new builder.TextBot();
          bot.add('/', dialog);
          bot.on('reply', function (message) {
            if (siateczka) {
              siateczka = false
              sendImageMessage(sender, "https://upload.wikimedia.org/wikipedia/commons/4/4f/Dziewczynka_z_wazonem_z_kwiatami,1902.jpg");
              sendTextMessage(sender, "Obraz „Helenka z wazonem” został namalowany przez Stanisława Wyspiańskiego w 1902 roku. Obecnie można go podziwiać w Muzeum Narodowym w Krakowie.");
            } else if (message.elements) {
              sendGenericMessage(sender, message.elements);
            } else {
              sendTextMessage(sender, message.text);
            }
          });


          // 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) {
                getUserData(session, sender);
              },
              function (session, results) {
                  // We'll save the prompts result and return control to main through
                  // a call to replaceDialog(). We need to use replaceDialog() because
                  // we intercepted the original call to main and we want to remove the
                  // /firstRun dialog from the callstack. If we called endDialog() here
                  // the conversation would end since the /firstRun dialog is the only
                  // dialog on the stack.
                  session.userData.name = results.response;
                  session.replaceDialog('/');
              }
          ]);

          botDict[sender] = bot
        }
          if (event.postback) {
              //var text = JSON.stringify(event.postback).substring(0, 200);
              //console.log('Payback: ', text);
              popularItems.push(event.postback.payload)
              sendTextMessage(sender, "Świetnie! Przypomnę Ci o tym wydarzeniu dzień wcześniej.")
          } else if (event.message && event.message.text) {
              var text = event.message.text.trim().substring(0, 200);
              bot.processMessage({ text: text})
          }
      });
Example #2
0
 start: function() {
     var bot = new builder.TextBot();
     bot.add('/', dialog);
     bot.listenStdin();
     return bot;
 }
Example #3
0
//var restify = require('restify');
var builder = require('botbuilder');
var helloBot = new builder.TextBot();
var dialog = new builder.CommandDialog();
//var helloBot = new builder.BotConnectorBot();
//var server = new restify.createServer();

helloBot.add('/', dialog);

/* -------------------
English 101 -> Room 205
English 102 -> Room 309
Math 301 -> Room 705
Math 302 -> Room 704

And Timings:

English 101 -> Mon 8 AM, Tuesday 9 AM
English 102 -> Tues 8 Am, Wed 9 AM
Math 301 -> Wed 8 AM, Friday 9 AM
Math 302 -> Frday 8 AM, Thursday 1PM
--------------------------------- */
var dict = {'English 101?': 'Room 205', 'English 102?': 'Room 309',
 'Math 301': 'Room 705', 'Math 302': 'Room 704'};

var str = "";



dialog.matches('^When is English 101?', builder.DialogAction.send('At Mon 8 AM, Tuesday 9 AM'));
dialog.matches('^When is English 102?', builder.DialogAction.send('At Tues 8 Am, Wed 9 AM'));
Example #4
0
'use strict';

var restify = require('restify');
var BotBuilder = require('botbuilder');
try {
	var env = require('dotenv').config();
} catch(err) {
	
}

var model = 'https://api.projectoxford.ai/luis/v1/application?id=c413b2ef-382c-45bd-8ff0-f76d60e2a821&subscription-key=0a23f3010b154720875c6e213e1eebbd&q=';
var dialog = new BotBuilder.LuisDialog(model);

// Create a text bot that takes your name and responds using that name
var txtBot = new BotBuilder.TextBot();//new BotBuilder.BotConnectorBot();
txtBot.add('/', new BotBuilder.CommandDialog()
	.matches('^set name', BotBuilder.DialogAction.beginDialog('/profile'))
	.matches('^luis', '/luis')
	.matches('^quit', BotBuilder.DialogAction.endDialog())
	.onDefault(function(session) {
	if(!session.userData.name) {
		session.beginDialog('/profile');
	} else {
		session.send("I hear you %s, now tell me what'ya want!", session.userData.name);
	}
}));
txtBot.add('/profile', [
	function(session) {
		if(session.userData.name) {
			BotBuilder.Prompts.text(session, 'What would you like to change it to?');
		} else {
Example #5
0
/*-----------------------------------------------------------------------------
Lab 3 Add instructions to build the Node.js App

# RUN THE BOT:

    Run the bot from the command line using "node app.js" and then type 
    "hello" to wake the bot up.

-----------------------------------------------------------------------------*/
var builder = require('botbuilder');

var helloBot = new builder.TextBot();
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) {
Example #6
0
var builder = require('botbuilder');
var index = require('./dialogs/index')

var textBot = new builder.TextBot();
textBot.add('/', index);

textBot.listenStdin();
module.exports.runBot = function () {
    let textBot = new builder.TextBot();
    textBot.add('/', dialogHandlers);
    textBot.listenStdin();
}
Example #8
0
var http = require('http');
var builder = require('botbuilder');
var dialog = new builder.LuisDialog('https://api.projectoxford.ai/luis/v1/application?id=c5150c0f-10ce-47e3-b94a-630cf8f9ef89&subscription-key=d366dae09f4341598189fc1b8a52fcfd');

// Create bot and add dialogs
var bot = new builder.TextBot();
var s3URL = "http://s3.amazonaws.com/bot-poc";
var imagesPath = "/images";
var htmlPath = "/html";

bot.add('/', dialog);
// Handling un recognized conversations.
dialog.on('None', function (session, args) {
	console.log("In the None Intent")	;
	session.send("I am sorry! I am just a bot. Perhaps I am not programmed to respond to this command.");		
});

dialog.on('Greetings', function (session, args) {
	console.log("In the Greetings Intent")	;
	session.send("Hello! I am the warehouse bot. You can ask me about the sales report of any item.");		
});

dialog.on('Close', function (session, args) {
	console.log("In the Close Intent")	;
	session.send("Thank you very much! It was nice chatting with you.");		
});

dialog.on('ItemSale', 
[ 
	function(session, args){	
		session.userData.ITEM_NAME = undefined;
Example #9
0
var applicationId = "07c4c72e-d229-4c7b-96db-2034c036d30e";
var subscriptionKey = "c2ba4a70587642b7a4cada97a40584ed";
var model = process.env.model || `${luisBaseUrl}?id=${applicationId}&subscription-key=${subscriptionKey}&q=`;
var dialog = new builder.LuisDialog(model);
const botService = new skype.BotService({
    messaging: {
        botId: process.env.BOT_ID || "64509262-bbb5-468b-bbc3-9d48cf11791d",
        serverUrl: "https://apis.skype.com",
        requestTimeout: 15000,
        appId: process.env.APP_ID || "30a5ed7b-8880-4025-b765-50094b992afc",
        appSecret: process.env.APP_SECRET || "YtzrLy0VFiiYzSa4FQeucbu"
    }
});
// Create bot and add dialogs
var skypebot = new builder.SkypeBot(botService);
var textbot = new builder.TextBot(botService);
skypebot.add('/', dialog);
textbot.add('/', dialog);
// bot.onIncomingCall(function (call){
//     console.log(JSON.stringify(call));
//     bot.reply(JSON.stringify(call), true);
// })
skypebot.on('onIncomingCall', function (call) {
    console.log(JSON.stringify(call));
    skypebot.reply(JSON.stringify(call), true);
});
dialog.on("Greeting", function (session, args) {
    var greetings = [
        "Hi there!",
        "Hello ",
        "Hola",
Example #10
0
var http = require('http');
var restify = require('restify');
var builder = require('botbuilder');

var bot = new builder.TextBot();

var dialog = new builder.LuisDialog('https://api.projectoxford.ai/luis/v1/application?id=c5150c0f-10ce-47e3-b94a-630cf8f9ef89&subscription-key=d366dae09f4341598189fc1b8a52fcfd');

var s3URL = "http://s3.amazonaws.com/bot-poc";

bot.add('/', dialog);

bot.beginDialog({
     to: { address: "User1", channelId: "emulator" , id: "2c1c7fa3"},
     from: { address: "notificationbot", channelId: "emulator", id: "notificationbot"}
 }, '/');

// Handling un recognized conversations.
dialog.on('None', function (session, args) {
	console.log("In the None Intent");	
});


dialog.onDefault(function(session){
	session.send("I'm sending you a proactive message! DO you have some work for me?");
});



dialog.on('ItemSale', 
[ 
Example #11
0
var builder = require('botbuilder');

var helloBot = new builder.TextBot();



/*
helloBot.add('/', function (session) {
    if (!session.userData.name) {
        session.beginDialog('/profile');
    } else {
        session.send('Hello %s!', session.userData.name);
    }
});
helloBot.add('/profile', [
    function (session) {
        builder.Prompts.text(session, 'Hi! What is your name?');
    },
    function (session, results) {
        session.userData.name = results.response;
        session.endDialog();
    }
]);
*/

helloBot.add('/', [
    function (session, args, next) {
        if (!session.userData.name) {
            session.beginDialog('/profile');
        } else {
            next();
Example #12
0
File: app.js Project: eastuger/PAIA
//Import
var restify = require('restify');
var builder = require('botbuilder');
var request = require('request');

//Bootstrap 

var bot = new builder.TextBot();
var dialog = new builder.CommandDialog();

var server = restify.createServer();

var builder = require('botbuilder');

bot.add('/', lDialog);
lDialog.on('Greeting', function(session, args){
	var greeting = responseFactory().greeting;
	session.send(greeting());
})
lDialog.on('WorkQuestion', function(session, args){
	var workQuestion = responseFactory().workQuestion;
	session.send(workQuestion());
})
lDialog.on('Question', function(session, args){
	var Question = responseFactory().Question;
	session.send(Question());
})
lDialog.on('PersonalQuestion', function(session, args){
	var personalQuestion = responseFactory.PersonalQuestion;
	session.send(personalQuestion);
})
Example #13
0
'use strict';
var builder = require('botbuilder');

var bot = new builder.TextBot();
bot.add('/', function (session) {
   session.send('Hello World'); 
});

bot.listenStdin();