+ All Categories
Home > Engineering > Chat Bots and how to build a Slack bot

Chat Bots and how to build a Slack bot

Date post: 20-Jan-2017
Category:
Upload: vasu-jain
View: 75 times
Download: 2 times
Share this document with a friend
12
Chat Bots and how to build a SlackBot!! Vasu Jain Sr. Software Engineer @ PayPal Tweets at @vasujain
Transcript
Page 1: Chat Bots and how to build a Slack bot

Chat Bots and how to build a SlackBot!!

Vasu JainSr. Software Engineer @ PayPal

Tweets at @vasujain

Page 2: Chat Bots and how to build a Slack bot

What is a Chatbot, Slack, SlackBot ..

A Chatbot is a computer program which conducts a conversation via audio or textual methods. E.g. Alexa, automated text based chat bots for Slack, Facebook etc.

Slack is a cloud-based messaging app for team collaboration. Got very popular due to app integrations. Slack teams consist of channels, users (humans and bots)

SlackBot ??

Page 3: Chat Bots and how to build a Slack bot

TacoBot within the Slack

Domino’s Pizza Twitter Bot Facebook Bot for Flowers, eBay etc.

Page 4: Chat Bots and how to build a Slack bot

What can a Slackbot do Slack Bot interact with a user on a Slack team by

1. Connecting to Slack’s RTM API and opening a web-socket connection with Slack. • Bot user will Monitor and process channel activity• Post messages and react to users• Web API to post formatted messages, attachments, emoji• Make messages interactive with buttons

2. Listening to Slack Events via HTTP based Events API aka Slack Webhooks . Configure events at https://api.slack.com/events

Page 5: Chat Bots and how to build a Slack bot

Developing a SlackBot …

Two Kinds of Slack bot you can develop :

1. Custom Bots - Custom for a team’s requirements- Can be used for company’s process automation etc.

2. Bot Users attached to Slack App - For distribution to other teams - Governed by OAuth permission scopes- Distributed via Slack Button or Slack Appstore

Page 6: Chat Bots and how to build a Slack bot

Programming a Slack bot ….

1. Make authenticated API calls and consume Slack RTM API

2. Use existing library (such as node-slack-client) https://github.com/slackhq/node-slack-client

3. Botkit Framework : Does heavy lifting for Slack API interactionOpen source bot builder platform for Node.jsTargets Slack, Facebook, Twilio currentlyhttp://howdy.ai/botkit

Using Botkit to develop a custom Bot using Slack RTM API.

Page 7: Chat Bots and how to build a Slack bot

Project Structure …• node_modules contain botkit module – generated by npm install• package.json specifies your project details and dependencies• index.js is the main entry point file.• Util.js for utility functions• Config.json for string sensitive data • Npm-debug.log created by default for error logging• lib directory containing slack libraries

Clone : https://github.com/vasujain/slack-bot-github

Page 8: Chat Bots and how to build a Slack bot

Developing a Custom SlackBot …1. Install Botkit• From NPM• npm install --save botkit

• From Github• git clone [email protected]:howdyai/botkit.git• npm install

2. Create a new bot user integration and customize ithttps://my.slack.com/services/new/bot

3. Capture token generated in #1, to be used to connect to Slack API4. Run a sample bot• npm start token=YOUR_TOKEN

5. Invite Bot to your team 6. Say Hello to your Bot

Page 9: Chat Bots and how to build a Slack bot

Lets Integrate an API in our bot ….

1. API to integrate – Github2. Get tokens and make first successful API call3. Convert REST Call into Node Code4. Write a controller using Intents from Slack input and

parsing them for API call5. Integrate Node code6. Parse API Response and construct Slack Response7. Happy Bot-ing !!

Page 10: Chat Bots and how to build a Slack bot

Demo for GitBit !!&

Questions

Page 11: Chat Bots and how to build a Slack bot

Thank You !!

Page 12: Chat Bots and how to build a Slack bot

Image Credits: • http://www.greenmellenmedia.com/wp-content/uploads/slack-chat.png• https://tctechcrunch2011.files.wordpress.com/2016/05/robot-customer-service.png• https://blog.zipfworks.com/content/images/2016/06/1-6J2T-ftDoHNGEvuMQiuWLA.jpeg• https://www.wired.com/wp-content/uploads/2015/08/SlackBot-featured1.jpg• https://cdn-images-1.medium.com/max/800/1*SRq8BmUQl1YWXTCbO859kw.png• https://robotsandpencils.com/wp-content/uploads/2016/03/[email protected]• https://beepboophq.storage.googleapis.com/_web/en_US/grande.edeb24.png• https://beepboophq.storage.googleapis.com/_web/en_US/venti.dba620.png


Recommended