Hexabot icon indicating copy to clipboard operation
Hexabot copied to clipboard

Feature Request - Slack Channel

Open marrouchi opened this issue 4 months ago • 0 comments

Summary: Implement a new channel handler in Hexabot to support integration with Slack, allowing users to interact with Hexabot through Slack workspaces. This feature will enable Slack users to send and receive messages, as well as manage labels, attachments, and other functionalities that currently exist in other channels (e.g., Facebook Messenger).

Objective: Create a Slack Channel Handler to handle interactions between Slack users and Hexabot. The Slack integration should support sending messages, receiving events, and managing subscribers, labels, and attachments.

Technical Requirements:

  1. Channel Handler Implementation

    • Create a new SlackHandler class that extends ChannelHandler.
    • Implement the required methods to interact with Slack API, including:
      • Authentication: Handle OAuth 2.0 authorization flow to get access tokens from Slack.
      • Incoming Events Handling: Receive incoming events such as messages, mentions, or reactions using Slack Events API.
      • Outgoing Messages Handling: Implement methods to send messages to Slack channels or users, formatted based on the existing message formats (text, quickReplies, buttons, etc.).
    • Implement Slack-specific middleware for request validation and signature verification to ensure authenticity.
  2. Slack API Integration

    • Use the official Slack SDK or HTTP-based REST API calls to interact with Slack.
    • Ensure the following Slack events are supported:
      • Message Received: Handle message events from both channels and direct messages.
      • User Joined Channel: Handle events when a new user joins a channel where Hexabot is active.
      • Reactions Added/Removed: Optional - handle emoji reactions to messages for triggering certain actions.
  3. Configuration

    • Add support for configuring Slack channel settings in Hexabot's admin panel.
    • Required configuration options include:
      • Bot Token: The token required to authenticate with Slack's API.
      • Verification Token: Token used to validate request signatures from Slack.
      • Channel Name: Name to identify the Slack channel.
  4. Webhook and Event Subscription

    • Set up Slack webhooks to receive events and actions.
    • Create an endpoint within the SlackHandler to process incoming Slack requests and validate them using the Slack Signing Secret.
  5. Subscriber Management

    • Implement subscriber creation and management based on Slack user data.
    • Sync user profiles and labels, similar to how it's done in the Messenger channel.
  6. Error Handling and Logging

    • Ensure error handling mechanisms are in place for Slack API requests, with retry logic for failed requests.
    • Use the LoggerService to add meaningful logs for debugging purposes, similar to existing channel handlers.
  7. Unit Testing

    • Create unit tests to verify the behavior of the SlackHandler.
    • Mock Slack API responses to simulate different event flows and error scenarios.

Acceptance Criteria:

  • A new Slack Channel is added to Hexabot, similar in functionality to the existing Messenger Channel.
  • Slack users can send and receive messages through Hexabot seamlessly.
  • Slack-specific events (e.g., mentions, direct messages) are processed by Hexabot and trigger corresponding actions.
  • Appropriate unit tests are written, and all tests are passing.

Additional Notes:

  • Refer to the implementation of the Messenger Channel for design patterns and structure that can be reused.
  • Consider adding documentation for setting up the Slack integration in the Hexabot user guide.

marrouchi avatar Oct 09 '24 16:10 marrouchi