You are previewing Building Slack Bots.
O'Reilly logo
Building Slack Bots

Book Description

Create powerful, useful, fast, and fun chat bots that make Slack better

About This Book

  • This is the first developer's guide to programming for Slack

  • It covers everything you need to create chat bots for Slack’s conversational UI

  • It’s full of realistic examples, usable code, and lucid explanations on everything you need to know

  • Who This Book Is For

    This is a book for software developers who want to build Slack bots for their own company’s use or for customers. You need to know JavaScript.

    What You Will Learn

  • Receive and send messages sent in Slack

  • Respond to user commands

  • Process natural language

  • Perform useful tasks on commands such as fetching data from external sources

  • Use webhooks and slash commands

  • Create a Google Classroom and add customized information for each individual class

  • In Detail

    Slack promises that its users will "be less busy." Slack bots interact with users in Slack chatrooms, providing useful immediate information, and automating work. This book gives you everything you need to build powerful and useful Slack bots.

    You’ll see how to hook into the Slack API to create software that can read and post to chatrooms, respond to commands and hints given in natural conversational language, and build fun and useful bots for your own place of work, both as a front end to your own service and to distribute and share as apps. You can even sell your bots and build a business as a Slack bot developer.

    Throughout the book, you’ll build useful and fun example applications that you can modify for your own situations. These range from simple, fun applications to liven up discussions to useful, data-driven apps to help you make decisions quickly and manage work.

    Style and approach

    This is a friendly step-by-step guide to building powerful, friendly Slack bots.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

    Table of Contents

    1. Building Slack Bots
      1. Table of Contents
      2. Building Slack Bots
      3. Credits
      4. About the Author
      5. About the Reviewer
      6. www.PacktPub.com
        1. eBooks, discount offers, and more
          1. Why subscribe?
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Getting Started with Slack
        1. Introduction to Slack
        2. Slack as a platform
        3. The end goal
        4. Summary
      9. 2. Your First Bot
        1. Preparing your environment
          1. Installing Node.js
          2. Installing the development tools using NPM
          3. Creating a new project
          4. Creating a Slack API token
          5. Connecting a bot
          6. Joining a channel
          7. Sending a message to a channel
          8. The slack object
          9. Getting all the channels
          10. Getting all members in a channel
          11. Sending a message to a channel
        2. Basic responses
          1. The authenticated event
          2. Using the message event
          3. Avoiding spam
        3. Sending a direct message
        4. Restricting access
          1. Adding and removing admins
        5. Debugging a bot
        6. Summary
      10. 3. Adding Complexity
        1. Responding to keywords
          1. Using classes
          2. Reactive bots
        2. Bot commands
          1. Sanitizing inputs
        3. External API integration
          1. Error handling
        4. Summary
      11. 4. Using Data
        1. Introduction to Redis
          1. Installing Redis
            1. Mac OS X
            2. Windows
            3. Unix
        2. Connecting to Redis
        3. Saving and retrieving data
          1. Connecting bots
          2. Dynamic storage
          3. Hashes, lists, and sets
            1. Hashes
            2. Lists
            3. Sets
            4. Sorted sets
        4. Best practices
        5. Simple to-do example
        6. Summary
      12. 5. Understanding and Responding to Natural Language
        1. A brief introduction to natural language
        2. Fundamentals of NLP
        3. Tokenizers
        4. Stemmers
        5. String distance
        6. Inflection
        7. Displaying data in a natural way
        8. When to use NLP?
        9. Mentions
        10. Classifiers
        11. Using trained classifiers
        12. Natural language generation
        13. When should we use natural language generation?
        14. The uncanny valley
        15. Summary
      13. 6. Webhooks and Slash Commands
        1. Webhooks
          1. Incoming webhooks
          2. Outgoing webhooks
        2. Slash commands
        3. In-channel and ephemeral responses
        4. Using webhooks and slash commands
        5. Summary
      14. 7. Publishing Your App
        1. The Slack app directory
        2. Registering your app and obtaining tokens
        3. Understanding the OAuth process
        4. Scopes
        5. Submitting your app to the app directory
        6. Monetizing your bot
        7. Summary
          1. Further reading
      15. Index