Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building Bots in Js

Building Bots in Js

A lighting talk to help solve the national epidemic of Atrocious Tie Length using the technology of a bot.

Summarizes how to get started building bots with Botkit.

Jamie Wright

May 08, 2017
Tweet

More Decks by Jamie Wright

Other Decks in Programming

Transcript

  1. // bot.js var Botkit = require('botkit'); var controller = Botkit.slackbot({

    clientId: process.env.clientId, clientSecret: process.env.cSecret, scopes: ['bot'] });
  2. // bot.js var Botkit = require('botkit'); var controller = Botkit.slackbot({

    clientId: process.env.clientId, clientSecret: process.env.cSecret, scopes: ['bot'] });
  3. // bot.js var Botkit = require('botkit'); var controller = Botkit.slackbot({

    clientId: process.env.clientId, clientSecret: process.env.cSecret, scopes: ['bot'] });
  4. // bot.js var Botkit = require('botkit'); var controller = Botkit.slackbot({

    clientId: process.env.clientId, clientSecret: process.env.cSecret, scopes: ['bot'] });
  5. // bot.js var Botkit = require('botkit'); var controller = Botkit.slackbot({

    clientId: process.env.clientId, clientSecret: process.env.cSecret, scopes: ['bot'] });
  6. // bot.js // .. controller.hears(['I want a tie'], ['direct_message'], function(bot,

    message) { bot.startConversation(message, askColor); }); askColor = function(response, convo) { convo.ask('What color do you want?', function(response, convo) { storeColor(response.text); convo.say('Got it. Tremendous color.'); askDelivery(response, convo); convo.next(); }); } askDelivery = function(response, convo) { convo.ask('Where do you want this shipped?', function(response, convo) { ensureNotMexico(response.text, function() { convo.say('Consider it done'); convo.next(); }); }); }
  7. I need a neck tie NlP [{ "intent": "buy", }]

    "entities": [ "action": "need", "item": "tie" ],
  8. I need a neck tie NlP [{ "intent": "buy", }]

    "entities": [ "action": "need", "item": "tie" ], "confidence": "0.82"
  9. // bot.js apiai.action('buy', function(message, response, bot) { var responseText =

    response.result.fulfillment.speech; bot.reply(message, responseText); bot.startConversation(message, askColor); }); ApI.Ai
  10. // bot.js apiai.action('buy', function(message, response, bot) { var responseText =

    response.result.fulfillment.speech; bot.reply(message, responseText); bot.startConversation(message, askColor); }); ApI.Ai