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
WeGive
2,572,697
WeAre
WeKnow
What is this session about.
> What is a ChatBot?
> How to write a chatbot
> Enable support for Slack
> Integrate with an external API
> Integrate with Natural Language Processing service platform
What is a ChatBot?
What is a ChatBot
A computer program designed to
mimic conversations with people
via audio or text.
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
A key feature for a bot is its ability to
understand the intentions of humans and
the extraction of relevant information from
that intention
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.
Writing a slack chatbot DrupalCampLA
Writing a slack chatbot DrupalCampLA
Writing a slack chatbot DrupalCampLA
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)
{
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);
});
Thank you … Questions?

More Related Content

PDF
Writing a slack chatbot mxlos
PDF
Writing a slack chatbot seattle
KEY
Java & Script ─ 清羽
PDF
Javascript is your (Auto)mate
PDF
ExtJS勉強会@名古屋
PPT
Riki Fridrich - Grunt, Gulp a spol. - Automatizáciou k maximalizácii lenivosti
PDF
Trimming The Cruft
ZIP
Web+GISという視点から見たGISの方向性
Writing a slack chatbot mxlos
Writing a slack chatbot seattle
Java & Script ─ 清羽
Javascript is your (Auto)mate
ExtJS勉強会@名古屋
Riki Fridrich - Grunt, Gulp a spol. - Automatizáciou k maximalizácii lenivosti
Trimming The Cruft
Web+GISという視点から見たGISの方向性

What's hot (12)

PDF
Absolute Beginners Guide to Puppet Through Types - PuppetConf 2014
PDF
Ruby ile tanışma!
PDF
Mojolicious
PPT
CoffeeScript: A beginner's presentation for beginners copy
PPTX
Mongoose and MongoDB 101
PDF
神に近づくx/net/context (Finding God with x/net/context)
PDF
ASP.NET SignalR によるクイズWebアプリ 「みんなで同時プレイするWebアプリでCodeQuizに挑戦!」
PDF
Gitkata fish shell
PPTX
Alexander Mostovenko "Modern approach to localization in javascript with the ...
PDF
Web APIs you (probably) didn't know existed
PDF
CGI.pm - 3ло?!
PPT
Jquery Best Practices
Absolute Beginners Guide to Puppet Through Types - PuppetConf 2014
Ruby ile tanışma!
Mojolicious
CoffeeScript: A beginner's presentation for beginners copy
Mongoose and MongoDB 101
神に近づくx/net/context (Finding God with x/net/context)
ASP.NET SignalR によるクイズWebアプリ 「みんなで同時プレイするWebアプリでCodeQuizに挑戦!」
Gitkata fish shell
Alexander Mostovenko "Modern approach to localization in javascript with the ...
Web APIs you (probably) didn't know existed
CGI.pm - 3ло?!
Jquery Best Practices
Ad

Similar to Writing a slack chatbot DrupalCampLA (20)

PDF
Chat Bots and how to build a Slack bot
PDF
Building Enterprise Chat Bots
PPTX
How to build a slack bot
PDF
Identifying and solving enterprise problems
PPTX
Building a slack bot
PPTX
Création facile de chatbots - Créez votre chatbot en 20 minutes avec une plat...
PPTX
#OSSPARIS19 - Création facile de chatbots - Créez votre chatbot en 20 minutes...
PDF
[2019 Serverless Summit] Building Serverless Slack Chatbot on IBM Cloud Func...
PDF
ATX Bot Talk - Hello PyBot
PDF
Hello PyBot
PDF
Build a bot with Botkit
PPTX
Ai chatbot
PDF
Future of the Web with Conversational Interface
PPTX
Slack and ChatGPT Integration using MuleSoft | MuleSoft Mysore Meetup #30
PDF
Bots and News
PDF
Building a slackbot
PDF
How to Build a Serverless Chatbot for $0?
PDF
Chat apps v02
PDF
Chat bots101 - practical insights on the business of bots
 
PDF
Chat bots101 - practical insights on the business of bots
Chat Bots and how to build a Slack bot
Building Enterprise Chat Bots
How to build a slack bot
Identifying and solving enterprise problems
Building a slack bot
Création facile de chatbots - Créez votre chatbot en 20 minutes avec une plat...
#OSSPARIS19 - Création facile de chatbots - Créez votre chatbot en 20 minutes...
[2019 Serverless Summit] Building Serverless Slack Chatbot on IBM Cloud Func...
ATX Bot Talk - Hello PyBot
Hello PyBot
Build a bot with Botkit
Ai chatbot
Future of the Web with Conversational Interface
Slack and ChatGPT Integration using MuleSoft | MuleSoft Mysore Meetup #30
Bots and News
Building a slackbot
How to Build a Serverless Chatbot for $0?
Chat apps v02
Chat bots101 - practical insights on the business of bots
 
Chat bots101 - practical insights on the business of bots
Ad

More from Jesus Manuel Olivas (20)

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

Recently uploaded (20)

PPTX
Big Data Technologies - Introduction.pptx
PPTX
1. Introduction to Computer Programming.pptx
PPTX
A Presentation on Artificial Intelligence
PPTX
Spectroscopy.pptx food analysis technology
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
Tartificialntelligence_presentation.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Electronic commerce courselecture one. Pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
Big Data Technologies - Introduction.pptx
1. Introduction to Computer Programming.pptx
A Presentation on Artificial Intelligence
Spectroscopy.pptx food analysis technology
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Group 1 Presentation -Planning and Decision Making .pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Programs and apps: productivity, graphics, security and other tools
Tartificialntelligence_presentation.pptx
Network Security Unit 5.pdf for BCA BBA.
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Dropbox Q2 2025 Financial Results & Investor Presentation
Assigned Numbers - 2025 - Bluetooth® Document
“AI and Expert System Decision Support & Business Intelligence Systems”
Electronic commerce courselecture one. Pdf
20250228 LYD VKU AI Blended-Learning.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Digital-Transformation-Roadmap-for-Companies.pptx

Writing a slack chatbot DrupalCampLA

  • 1. Writing a Slack ChatBot by Jesus Manuel Olivas / weKnow
  • 2. ● WHO AM I? Jesus Manuel Olivas jmolivas@weknowinc.com jmolivas jmolivas drupal.org/u/jmolivas jmolivas.weknowinc.com
  • 6. What is this session about. > What is a ChatBot? > How to write a chatbot > Enable support for Slack > Integrate with an external API > Integrate with Natural Language Processing service platform
  • 7. What is a ChatBot?
  • 8. What is a ChatBot A computer program designed to mimic conversations with people via audio or text.
  • 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. A key feature for a bot is its ability to understand the intentions of humans and the extraction of relevant information from that intention
  • 25. Natural language processing (NLP) can be defined as the ability of a machine to analyze, understand, and generate human speech.
  • 26. The goal of NLP is to make interactions between computers and humans feel exactly like interactions between humans and humans.
  • 30. Easily create text or voice based bots that humans can chat with on their preferred messaging platform. https://wit.ai/ Wit.AI
  • 31. 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
  • 32. 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);
  • 33. botkit-witai controller.hears(['.*'], incomingEvent, function (bot, 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); });
  • 34. Thank you … Questions?