SlideShare a Scribd company logo
Writing a Slack
ChatBot
by Jesus Manuel Olivas / weKnow
● WHO AM I?
Jesus Manuel Olivas
jmolivas@weknowinc.com
jmolivas
jmolivas
drupal.org/u/jmolivas
jmolivas.weknowinc.com
Writing a slack chatbot mxlos
WeGive
WeAre
WeKnow
What is a ChatBot
A computer program designed to
mimic conversations with people
via audio or text.
What is this session about.
> How to write a chatbot
> Enable support for Slack
> Integrate with an external API
> Integrate with Natural Language Processing service platform
But why a ChatBot?
Some of the things we do in our
every day lives, especially at our
jobs, can be automated.
Whenever a human is involved in a
repetitive task … there is a chance
for an error.
Let the Robots do the work. 
Do You Want to Build a
ChatBot?
Installation
# Installing  Botkit
npm install -g botkit
# Creating new project
botkit new —platform slack
Start the application
# Start Server
node bot.js
# Start server
clientId=CLIENT_ID clientSecret=CLIENT_SECRET PORT=3000
node bot.js
Start the application
# Create .env file
clientId=CLIENT_ID

clientSecret=CLIENT_SECRET 

PORT=3000
# Exposer port using ngrok
ngrok http 3000
Minimum configuration
var Botkit = require('botkit');
var request = require('request');
var bot_options = {
clientId: process.env.clientId,
clientSecret: process.env.clientSecret,
scopes: ['bot']
};
Hear for messages
// Create the Botkit controller, which controls instances of the bot.
var controller = Botkit.slackbot(bot_options);


controller.hears(['Hi'], 'ambient', function(bot, message) {
bot.reply(message, 'Hi ... I heard a message.’)
});
Hear for messages
// Create the Botkit controller, which controls instances of the bot.
var controller = Botkit.slackbot(bot_options);


controller.hears(['hola', 'que tal'], 'ambient', function(bot, message) {
bot.reply(message, 'Hola que tal.')
});
Return an attachment
bot.reply(message, {
attachments:[
{
"title": “Lorem ipsum.",
"image_url": "https://imgs.xkcd.com/comics/twitter_bot_2x.png",
"color": "#ff0000"
}
]
});
Integrate API … REST/GraphQL
API calls
controller.hears(['show crypto prices'], incomingEvent, function(bot, message) {
bot.reply(message, 'fetching information ...');
request({ method: ‘get', uri: 'https://api.bitso.com/v3/ticker', json: true, }, function (err, response, json) {
let colors = [ 'good', 'warning', 'danger'];
for(var i = 0; i < json.payload.length; i++) {
bot.reply(message, {
attachments: [{
"title": json.payload[i].book,
"text": JSON.stringify(json.payload[i], undefined, 2),
"color": colors[Math.floor(Math.random()*colors.length)]
}]
});
}
});
});
Natural Language Processing
Natural language processing (NLP) can be
defined as the ability of a machine to
analyze, understand, and generate human
speech.
The goal of NLP is to make interactions
between computers and humans feel
exactly like interactions between humans
and humans.
Easily create text or voice based bots that humans
can chat with on their preferred messaging platform.
https://wit.ai/
Wit.AI
botkit-witai
# Require dependency
npm install --save botkit-witai
# Start server
clientId=CLIENT_ID clientSecret=CLIENT_SECRET PORT=3000
wit_ai_token=WIT_AI_TOKEN node bot.js
botkit-witai
# Usage
var wit = require('botkit-witai')({
accessToken: process.env.wit_ai_token,
minConfidence: 0.6
});
# Register middleware
controller.middleware.receive.use(wit.receive);
botkit-witai
controller.hears(['.*'], incomingEvent, function (bot, message) {
controller.log( JSON.stringify(message) );
var intent = message.entities.intent[0].value;
var intent_type = intent + '_type';
var type = message.entities[intent_type][0].value;
bot.reply(message, 'intent: ' + intent + ', type: ' + type);
});
DEMO TIME
● .

More Related Content

What's hot (20)

PDF
How to actually use promises - Jakob Mattsson, FishBrain
Codemotion Tel Aviv
 
PPTX
Getting classy with ES6
Andy Sharman
 
PDF
Web Crawling with NodeJS
Sylvain Zimmer
 
PDF
ExtJS勉強会@名古屋
Tsuyoshi Yamamoto
 
PDF
JavaScript APIs - The Web is the Platform - MozCamp, Buenos Aires
Robert Nyman
 
PDF
JavaScript APIs - The Web is the Platform - MDN Hack Day, Santiago, Chile
Robert Nyman
 
ZIP
Web+GISという視点から見たGISの方向性
Hidenori Fujimura
 
PPTX
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)
Dotan Dimet
 
PDF
JavaScript APIs - The Web is the Platform - MDN Hack Day, Montevideo
Robert Nyman
 
PDF
History of jQuery
jeresig
 
PDF
Absolute Beginners Guide to Puppet Through Types - PuppetConf 2014
Puppet
 
PDF
Introducere in web
Alex Eftimie
 
PDF
De 0 a 100 con Bash Shell Scripting y AWK
Adolfo Sanz De Diego
 
PDF
Python para web - Utilizando micro-framework Flask - PUG-MA
Herson Leite
 
PDF
Trimming The Cruft
Peter Higgins
 
PDF
JavaScript APIs - The Web is the Platform - MDN Hack Day - Buenos Aires
Robert Nyman
 
ODP
Mojolicious on Steroids
Tudor Constantin
 
PDF
Introduction of ES2015
Nakajima Shigeru
 
PDF
Mojolicious: what works and what doesn't
Cosimo Streppone
 
PDF
Intro to jquery
Dan Pickett
 
How to actually use promises - Jakob Mattsson, FishBrain
Codemotion Tel Aviv
 
Getting classy with ES6
Andy Sharman
 
Web Crawling with NodeJS
Sylvain Zimmer
 
ExtJS勉強会@名古屋
Tsuyoshi Yamamoto
 
JavaScript APIs - The Web is the Platform - MozCamp, Buenos Aires
Robert Nyman
 
JavaScript APIs - The Web is the Platform - MDN Hack Day, Santiago, Chile
Robert Nyman
 
Web+GISという視点から見たGISの方向性
Hidenori Fujimura
 
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)
Dotan Dimet
 
JavaScript APIs - The Web is the Platform - MDN Hack Day, Montevideo
Robert Nyman
 
History of jQuery
jeresig
 
Absolute Beginners Guide to Puppet Through Types - PuppetConf 2014
Puppet
 
Introducere in web
Alex Eftimie
 
De 0 a 100 con Bash Shell Scripting y AWK
Adolfo Sanz De Diego
 
Python para web - Utilizando micro-framework Flask - PUG-MA
Herson Leite
 
Trimming The Cruft
Peter Higgins
 
JavaScript APIs - The Web is the Platform - MDN Hack Day - Buenos Aires
Robert Nyman
 
Mojolicious on Steroids
Tudor Constantin
 
Introduction of ES2015
Nakajima Shigeru
 
Mojolicious: what works and what doesn't
Cosimo Streppone
 
Intro to jquery
Dan Pickett
 

Similar to Writing a slack chatbot mxlos (20)

PDF
How to Build a Serverless Chatbot for $0?
Mobile Monday Srbija
 
PDF
Real-Time Chat with Node.js & Socket.io
Naresh IT
 
PDF
Api
randyhoyt
 
PDF
How to build twitter bot using golang from scratch
Katy Slemon
 
PDF
Having fun with jabber bots
Victor Hugo Germano
 
PDF
Adopting F# at SBTech
Antya Dev
 
PPTX
CyberArk Impact 2017 - REST for the Rest of Us
Joe Garcia
 
PDF
soft-shake.ch - Hands on Node.js
soft-shake.ch
 
PPTX
How to Leverage APIs for SEO #TTTLive2019
Paul Shapiro
 
PDF
[2019 Serverless Summit] Building Serverless Slack Chatbot on IBM Cloud Func...
Tomomi Imura
 
PDF
mobl
zefhemel
 
PPT
Google Wave 20/20: Product, Protocol, Platform
Pamela Fox
 
PDF
TADHack 2015 Webinar Oracle Comms & Optare
Alan Quayle
 
PDF
TADHack 2015 webinar Oracle Comms & Optare
antonry
 
PPTX
Building with Watson - Serverless Chatbots with PubNub and Conversation
IBM Watson
 
DOCX
Getting Started.docx - Unreal Tournament 3 Bots for .NET
butest
 
PPTX
Microsoft Bot Framework (Node.js Edition)
Jens Siebert
 
PDF
Bacon.js — Gérer efficacement les flux de données en Javascript
Rodolphe Belouin
 
PDF
Asynchronous Programming at Netflix
C4Media
 
PDF
김영욱 - Microsoft Bot Framework [WSConf. Seoul 2017]
WSConf.
 
How to Build a Serverless Chatbot for $0?
Mobile Monday Srbija
 
Real-Time Chat with Node.js & Socket.io
Naresh IT
 
How to build twitter bot using golang from scratch
Katy Slemon
 
Having fun with jabber bots
Victor Hugo Germano
 
Adopting F# at SBTech
Antya Dev
 
CyberArk Impact 2017 - REST for the Rest of Us
Joe Garcia
 
soft-shake.ch - Hands on Node.js
soft-shake.ch
 
How to Leverage APIs for SEO #TTTLive2019
Paul Shapiro
 
[2019 Serverless Summit] Building Serverless Slack Chatbot on IBM Cloud Func...
Tomomi Imura
 
mobl
zefhemel
 
Google Wave 20/20: Product, Protocol, Platform
Pamela Fox
 
TADHack 2015 Webinar Oracle Comms & Optare
Alan Quayle
 
TADHack 2015 webinar Oracle Comms & Optare
antonry
 
Building with Watson - Serverless Chatbots with PubNub and Conversation
IBM Watson
 
Getting Started.docx - Unreal Tournament 3 Bots for .NET
butest
 
Microsoft Bot Framework (Node.js Edition)
Jens Siebert
 
Bacon.js — Gérer efficacement les flux de données en Javascript
Rodolphe Belouin
 
Asynchronous Programming at Netflix
C4Media
 
김영욱 - Microsoft Bot Framework [WSConf. Seoul 2017]
WSConf.
 
Ad

More from Jesus Manuel Olivas (20)

PDF
Remix & GraphQL: A match made in heaven with type-safety DX
Jesus Manuel Olivas
 
PDF
Drupal 10 Party GraphQL
Jesus Manuel Olivas
 
PDF
How to use Drupal to create editorial experiences your content creators will...
Jesus Manuel Olivas
 
PDF
Beyond Static: Building a Dynamic Application with Gatsby
Jesus Manuel Olivas
 
PDF
Drupal, GraphQL, Views, View Modes and Gatsby for a US Gov site CMS Philly
Jesus Manuel Olivas
 
PDF
Embracing the modern web using a Headless CMS with GatsbyJS CMS Philly
Jesus Manuel Olivas
 
PDF
Embracing the modern web using a Headless CMS with GatsbyJS Stanford
Jesus Manuel Olivas
 
PDF
Building a modern application using Symfony API Platform and GatsbyJS PHP QRO
Jesus Manuel Olivas
 
PDF
Building a dynamic application with GatsbyJS-Tec-Mexicali
Jesus Manuel Olivas
 
PDF
Building a modern web application in the cloud partnercon
Jesus Manuel Olivas
 
PDF
Embracing the modern web using Drupal as a Headless CMS with Gatsby BADCamp
Jesus Manuel Olivas
 
PDF
Blazing fast sites using Blaze, Hybrid CMS NYC
Jesus Manuel Olivas
 
PDF
Embracing the modern web using Drupal as Headless CMS with GatsbyJS NYC
Jesus Manuel Olivas
 
PDF
Building a Modern Web Application in the Cloud TecNerd
Jesus Manuel Olivas
 
PDF
How to keep Drupal relevant in the Git-based and API-driven CMS era Florida
Jesus Manuel Olivas
 
PDF
How to keep Drupal relevant in the Git-based and API-driven CMS era DrupalCampNJ
Jesus Manuel Olivas
 
PDF
Tools and Projects Dec 2018 Edition
Jesus Manuel Olivas
 
PDF
Creating a modern web application using Symfony API Platform Atlanta
Jesus Manuel Olivas
 
PDF
How to keep Drupal relevant in the Git-based and API-driven CMS era - BADCamp
Jesus Manuel Olivas
 
PDF
Battle of the CMS DrupalCampLA
Jesus Manuel Olivas
 
Remix & GraphQL: A match made in heaven with type-safety DX
Jesus Manuel Olivas
 
Drupal 10 Party GraphQL
Jesus Manuel Olivas
 
How to use Drupal to create editorial experiences your content creators will...
Jesus Manuel Olivas
 
Beyond Static: Building a Dynamic Application with Gatsby
Jesus Manuel Olivas
 
Drupal, GraphQL, Views, View Modes and Gatsby for a US Gov site CMS Philly
Jesus Manuel Olivas
 
Embracing the modern web using a Headless CMS with GatsbyJS CMS Philly
Jesus Manuel Olivas
 
Embracing the modern web using a Headless CMS with GatsbyJS Stanford
Jesus Manuel Olivas
 
Building a modern application using Symfony API Platform and GatsbyJS PHP QRO
Jesus Manuel Olivas
 
Building a dynamic application with GatsbyJS-Tec-Mexicali
Jesus Manuel Olivas
 
Building a modern web application in the cloud partnercon
Jesus Manuel Olivas
 
Embracing the modern web using Drupal as a Headless CMS with Gatsby BADCamp
Jesus Manuel Olivas
 
Blazing fast sites using Blaze, Hybrid CMS NYC
Jesus Manuel Olivas
 
Embracing the modern web using Drupal as Headless CMS with GatsbyJS NYC
Jesus Manuel Olivas
 
Building a Modern Web Application in the Cloud TecNerd
Jesus Manuel Olivas
 
How to keep Drupal relevant in the Git-based and API-driven CMS era Florida
Jesus Manuel Olivas
 
How to keep Drupal relevant in the Git-based and API-driven CMS era DrupalCampNJ
Jesus Manuel Olivas
 
Tools and Projects Dec 2018 Edition
Jesus Manuel Olivas
 
Creating a modern web application using Symfony API Platform Atlanta
Jesus Manuel Olivas
 
How to keep Drupal relevant in the Git-based and API-driven CMS era - BADCamp
Jesus Manuel Olivas
 
Battle of the CMS DrupalCampLA
Jesus Manuel Olivas
 
Ad

Recently uploaded (20)

PPTX
Agentic AI in Healthcare Driving the Next Wave of Digital Transformation
danielle hunter
 
PDF
TrustArc Webinar - Navigating Data Privacy in LATAM: Laws, Trends, and Compli...
TrustArc
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PDF
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PDF
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PDF
Build with AI and GDG Cloud Bydgoszcz- ADK .pdf
jaroslawgajewski1
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PPTX
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
PDF
Market Insight : ETH Dominance Returns
CIFDAQ
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PDF
Generative AI vs Predictive AI-The Ultimate Comparison Guide
Lily Clark
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PPTX
AVL ( audio, visuals or led ), technology.
Rajeshwri Panchal
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
Agentic AI in Healthcare Driving the Next Wave of Digital Transformation
danielle hunter
 
TrustArc Webinar - Navigating Data Privacy in LATAM: Laws, Trends, and Compli...
TrustArc
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
Build with AI and GDG Cloud Bydgoszcz- ADK .pdf
jaroslawgajewski1
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
Market Insight : ETH Dominance Returns
CIFDAQ
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
Generative AI vs Predictive AI-The Ultimate Comparison Guide
Lily Clark
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
AVL ( audio, visuals or led ), technology.
Rajeshwri Panchal
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 

Writing a slack chatbot mxlos

  • 1. Writing a Slack ChatBot by Jesus Manuel Olivas / weKnow
  • 2. ● WHO AM I? Jesus Manuel Olivas [email protected] jmolivas jmolivas drupal.org/u/jmolivas jmolivas.weknowinc.com
  • 7. What is a ChatBot A computer program designed to mimic conversations with people via audio or text.
  • 8. What is this session about. > How to write a chatbot > Enable support for Slack > Integrate with an external API > Integrate with Natural Language Processing service platform
  • 9. But why a ChatBot?
  • 10. Some of the things we do in our every day lives, especially at our jobs, can be automated.
  • 11. Whenever a human is involved in a repetitive task … there is a chance for an error.
  • 13. Do You Want to Build a ChatBot?
  • 14. Installation # Installing  Botkit npm install -g botkit # Creating new project botkit new —platform slack
  • 15. Start the application # Start Server node bot.js # Start server clientId=CLIENT_ID clientSecret=CLIENT_SECRET PORT=3000 node bot.js
  • 16. Start the application # Create .env file clientId=CLIENT_ID
 clientSecret=CLIENT_SECRET 
 PORT=3000 # Exposer port using ngrok ngrok http 3000
  • 17. Minimum configuration var Botkit = require('botkit'); var request = require('request'); var bot_options = { clientId: process.env.clientId, clientSecret: process.env.clientSecret, scopes: ['bot'] };
  • 18. Hear for messages // Create the Botkit controller, which controls instances of the bot. var controller = Botkit.slackbot(bot_options); 
 controller.hears(['Hi'], 'ambient', function(bot, message) { bot.reply(message, 'Hi ... I heard a message.’) });
  • 19. Hear for messages // Create the Botkit controller, which controls instances of the bot. var controller = Botkit.slackbot(bot_options); 
 controller.hears(['hola', 'que tal'], 'ambient', function(bot, message) { bot.reply(message, 'Hola que tal.') });
  • 20. Return an attachment bot.reply(message, { attachments:[ { "title": “Lorem ipsum.", "image_url": "https://imgs.xkcd.com/comics/twitter_bot_2x.png", "color": "#ff0000" } ] });
  • 21. Integrate API … REST/GraphQL
  • 22. API calls controller.hears(['show crypto prices'], incomingEvent, function(bot, message) { bot.reply(message, 'fetching information ...'); request({ method: ‘get', uri: 'https://api.bitso.com/v3/ticker', json: true, }, function (err, response, json) { let colors = [ 'good', 'warning', 'danger']; for(var i = 0; i < json.payload.length; i++) { bot.reply(message, { attachments: [{ "title": json.payload[i].book, "text": JSON.stringify(json.payload[i], undefined, 2), "color": colors[Math.floor(Math.random()*colors.length)] }] }); } }); });
  • 24. Natural language processing (NLP) can be defined as the ability of a machine to analyze, understand, and generate human speech.
  • 25. The goal of NLP is to make interactions between computers and humans feel exactly like interactions between humans and humans.
  • 26. Easily create text or voice based bots that humans can chat with on their preferred messaging platform. https://wit.ai/ Wit.AI
  • 27. botkit-witai # Require dependency npm install --save botkit-witai # Start server clientId=CLIENT_ID clientSecret=CLIENT_SECRET PORT=3000 wit_ai_token=WIT_AI_TOKEN node bot.js
  • 28. botkit-witai # Usage var wit = require('botkit-witai')({ accessToken: process.env.wit_ai_token, minConfidence: 0.6 }); # Register middleware controller.middleware.receive.use(wit.receive);
  • 29. botkit-witai controller.hears(['.*'], incomingEvent, function (bot, message) { controller.log( JSON.stringify(message) ); var intent = message.entities.intent[0].value; var intent_type = intent + '_type'; var type = message.entities[intent_type][0].value; bot.reply(message, 'intent: ' + intent + ', type: ' + type); });
  • 31. ● .