Example #1
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 #2
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 #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
]);
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;
        }
        builder.Prompts.text(session, 'Nasıl yardımcı olabilirim?');
    },
    function (session, results) {
        session.beginDialog('/menucommand');
    }
]);

var dialog = new builder.CommandDialog();
dialog.onDefault(builder.DialogAction.send("Özür dilerim anlamadım."));
bot.add('/menucommand', dialog);

dialog.matches('^isteğim', [
    function (session) {
        builder.Prompts.text(session, "Tabi ki, ne istiyorsun?");
    },
    function (session, results) {
        session.send("Tabi ki, hemen ilgili işlemleri başlatıyorum", results.response);
        session.endDialog();
    }
]);

dialog.matches('^problem', [
    function (session) {
Example #5
0
    shutdownMessage: "Хорошо, умолкаю."
};

// userData
/*{ 
    to
,   from   
,   user_professions
,   time
}*/

var userData = {};
var profession_list = new Array();

// dialog command
var dcommand = new builder.CommandDialog();

dcommand.matches('^(работа|сменить работу)', builder.DialogAction.beginDialog('/changew'))
//dcommand.matches('^(время спама|время)', builder.DialogAction.beginDialog('/timer'))
dcommand.matches('^старт|начать', builder.DialogAction.beginDialog('/start'))
dcommand.matches('^стоп|прекратить', builder.DialogAction.beginDialog('/stop'))
dcommand.matches('^(отменить|потом)', builder.DialogAction.endDialog(messages.cancel)) // do not working!!!!

dcommand.onBegin
(
function (session, args, next) {
    
    console.log('begin 1'); 
    userData.to = session.message.from;
    userData.from = session.message.to;
    if (!userData.user_professions) {   
Example #6
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 #7
0
const Botkit = require('botkit');
const builder = require('botbuilder');
const request = require('request');
const sprintf = require('sprintf-js').sprintf;
const prompts = require('./prompts');

var controller = Botkit.slackbot();
var bot = controller.spawn({
    token: process.env.token
});

var slackBot = new builder.SlackBot(controller, bot);
var dialog = new builder.CommandDialog();

slackBot.add('/', dialog);

dialog.onDefault( function(session) {
    request({
        url: 'https://slack.com/api/users.info',
        qs: { token: process.env.token, user: session.userData.id },
        method: 'GET'
    }, function(error, response, body) {
        if(error) {
            console.log(error);
        } else {
            var result = JSON.parse(body)
            if(!result.ok) {
                session.send(prompts.greeting, 'stranger');
            } else {
                session.send(prompts.greeting, result.user.profile.first_name);
            }