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

Introduction to Slack App Development

Serhat Can
February 23, 2018

Introduction to Slack App Development

An introduction to Slack applications, chatbots, and chatops. Learn the basics of Slack application development including features like incoming webhooks, bot users, events API, slash commands, Slack APIs, RTM API, and some best practices.

Serhat Can

February 23, 2018
Tweet

More Decks by Serhat Can

Other Decks in Programming

Transcript

  1. About • Searchable Log of All Conversations and Knowledge •

    The fastest growing SaaS company. Of all time. • Over 6 million apps installed (2016 number)
  2. ChatOps is “Placing tools directly in the middle of the

    conversation”   — Jesse Newland, GitHub
  3. Outline • Terminology • App Development Lifecycle • Features •

    Slack APIs • Designing Slack Messages • Tips and Tricks
  4. Development Terminology Custom Integrations (Old) Incoming Webhooks Slash Commands Bot

    Users Outgoing Webhooks Web API Legacy Tokens Internal integrations (apps) Published apps Apps
  5. Internal integrations Only for your team Easy installation SSL is

    recommended but not required Published Apps For you and other workspaces Implement OAuth flow SSL is required
  6. App Development Lifecycle Void of features, uninstalled Has features but

    can only be installed by your workplace Open to installation by other workspaces Submitted to the Slack app directory
  7. Incoming Webhooks The simplest way to send messages into Slack.

    HTTP requests with a JSON payload curl -X POST -H 'Content-type: application/json' \ --data '{"text":"This is a line of text.\nAnd this is another one."}' \ https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXX XXXXXXXXX
  8. Interactive Messages - Menus Choose from a series of options

    Easy to fill up Slack users and channels
  9. Interactive Messages - Dialogs Triggered by clicking on buttons, selecting

    from menus, or invoking slash commands. Dialogs contain a variety of guided input types.
  10. Interactive Messages You send JSON payload as always Your registered

    action URL would receive a payload of JSON You receive: • the callback_id you set when creating the message • the specific name of the clicked button • and the corresponding value of that same clicked button
  11. Responding to a command You’ve got 3000 milliseconds to respond

    If it takes more than 3000 ms, return 200 OK Send your message ASYNC
  12. Bot Users • Profile photo, name, bio • Post message,

    upload file • Invite and kick Difference: • They can’t login
  13. Bot Users Bot users interact with people two ways: •

    Real Time Messaging API (RTM) ◦ Websocket connection ◦ Receive all messages and activity • Events API
  14. Event Subscriptions (Events API) Governed by OAuth permission scopes If

    you have files:read scope You can choose to subscribe to any or none of the file-related events like file_created and file_deleted
  15. RTM Websocket connection (Stay connected) Subscribe to everything Events API

    Call you with HTTPS requests (Push subscription) Subscribe to only what you want If the RTM API is a fire hose, the Events API is a watering can — easy to wield and useful
  16. Permissions OAuth permission scopes • Web API, • Events API,

    • RTM API, • Slash Commands, • Incoming Webhooks
  17. Scope Actions There are currently only three classes of action:

    • read: Reading the full information about a single resource. • write: Modifying the resource in any way e.g. creating, editing, or deleting. • history: Accessing the message archive of channels, DMs, or private channels.
  18. Slack API • Authenticate with OAuth 2.0 • HTTPS is

    a must • JSON response with failure info in the response body • HTTP RPC-style methods https://slack.com/api/METHOD
  19. Slack API • Web API • Events API • Real

    Time Messaging API • New Conversations API (Part of Web API) Public channels, private channels, DMs... They are all conversations! • SCIM API The Slack SCIM API is used by SSO partners to help provision and manage user accounts and groups. Only available on the Plus plan and Slack Enterprise Grid
  20. How to Send Messages • Incoming Webhooks • Web API

    • RTM API • Responding to slash commands • Responding to message button actions
  21. Guidelines for Building Messages • Stay in the flow •

    Keep formatting simple • Don’t get too attached
  22. In Channel means everyone in the channel can see the

    response “In Channel” vs “Ephemeral” responses Ephemeral means only the command issuer can see the response
  23. Delayed and Multiple Responses You have to respond to a

    command or button within 3000 milliseconds If your execution takes more time; • Return the 200 OK response immediately • Use response_url or Web API to send your response
  24. Slack Developer Kits • Slack Developer Kit for Node •

    Slack Developer Kit for Python • Slack Developer Kit for Hubot • Botkit • Microsoft Bot Framework • Widely-used open source libraries available for a lot of languages
  25. NLP for Bots Bot users should try to understand what

    you are saying. You can use services like; • Amazon Lex • Api.ai • Wit.ai
  26. And... • Read the “Best Practices” pages • Understand your

    audience • Check App blueprints to start quickly • Talk with Slack DevRel Team if necessary • Follow Slack’s Roadmap
  27. Demo Services AWS Lambda APIs Involved Events API OpsGenie API

    Web API https://github.com/serhatcan/serverless-opsgenie-slack-alert-unfurling