Tech talk for MVP Reconnect Events. This talk starts with why the idea for this talk came, followed by an example of one of the bots I built to increase productivity at my workplace.
15. Early disruptors in bots domain
Bot Platform to order from
marketplaces(2016)
TacoBot within the
Slack (2016)
Twitter Bot to order Pizza by
Tweeting Pizza Emoji (2015)
16. Slackbot capabilities
Slack Bot interact with a user on a Slack team by
1. Connecting to Slack’s Real time Messaging (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
17. Types of Slack bot you can develop :
Slack Bot interact with a user on a Slack team by
Custom Bots
1. Custom for a team’s requirements
2. Can be used for company’s process automation etc.
Bot Users attached to Slack App
1. For distribution to other teams
2. Governed by OAuth permission scopes
3. Distributed via Slack Button or Slack Appstore
Apps generally start as custom bots and evolve into a Slack App.
18. Ways to create a Slack bot
1. Make authenticated API calls and consume Slack RTM API
2. Use existing library or SDKs (such as node-slack-client)
https://github.com/slackhq/node-slack-client
3. Botkit Framework :
• Does heavy lifting for Slack API interaction
• Open source bot builder platform for Node.js
• Works for Slack, Facebook, Twilio, Microsoft Teams, Cisco
Spark/Jabber currently
• Write once run anywhere style
• http://howdy.ai/botkit
19.
20. Project Structure
Clone: https://github.com/vasujain/slack-bot-github
• node_modules/ contain botkit module – generated by npm install
• package.json specifies your project details and dependencies
• index.js is the entry point
• 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
21. Developing a Custom Slack Bot - Setup
1. Install Botkit
• From NPM
• npm install --save botkit
• From Github
• git clone git@github.com:howdyai/botkit.git
• npm install
2. Create a new bot user integration and customize it
https://my.slack.com/services/new/bot
22. Developing a Custom Slack Bot - Setup
3. Capture token generated in #1, to be used to connect
to Slack API
4. Constructs base 64 encoded value and add it to
config.json (not mandatory for regular bots)
5. Run a sample bot
• npm start index.js
6. Invite Bot to your team
7. Say Hello to your Bot
23. Lets Integrate an API in our bot
1. API to integrate – Github
2. Get tokens and make first successful API call
3. Convert REST Call into Node Code
4. Write a controller using Intents from Slack input and parsing
them for API call
5. Integrate Node code
6. Parse API Response and construct Slack Response
7. Happy Bot-ing !!