Chapter 3. Adding Complexity

With the first bot done, it's time to learn how to extend our bot with the use of other application program interfaces (APIs). This means teaching our bot how to listen for keywords, respond to commands, and deal with errors (human or otherwise). In this chapter, we will cover the following:

  • Responding to keywords
  • Bot commands
  • External API integration
  • Error handling

Responding to keywords

In the previous chapter, we used regular expressions to test the contents of the message against some predefined keywords. Once the keywords were confirmed, we could perform actions and return the results. This worked well; however, it can lead to a large if else block for more feature-rich bots. Instead, we will now look at refactoring ...

Get Building Slack Bots now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.