Hexabot icon indicating copy to clipboard operation
Hexabot copied to clipboard

Feature Request - Whatsapp channel

Open marrouchi opened this issue 4 months ago • 0 comments

Summary
Implement a new channel handler for WhatsApp to enable integration with Hexabot, similar to the existing Messenger Channel. This feature will allow Hexabot users to engage with their customers via WhatsApp, ensuring consistent messaging and expanding the chatbot's reach across popular communication channels.

Objectives

  • Develop a new WhatsApp channel handler for Hexabot, ensuring compatibility with existing core functionalities.
  • Utilize WhatsApp Business API to enable sending and receiving messages, managing subscribers, and handling interactions.

Guidelines

  1. Channel Handler Class

    • Create a new handler class for the WhatsApp channel, similar to the existing MessengerHandler.
    • Ensure it extends the ChannelHandler base class, implementing core methods such as sendMessage, getChannel, and handle.
  2. WhatsApp API Integration

    • Utilize the WhatsApp Business API for messaging and user management.
    • Implement functionality to initialize the handler with access tokens and necessary credentials.
    • Ensure to create utility functions for sending text, media, and interactive messages, as WhatsApp allows.
  3. Message Formats

    • Implement methods to handle and format different message types:
      • Text messages.
      • Media messages (e.g., images, videos).
      • Interactive messages (e.g., buttons, lists).
    • Ensure these methods align with the StdOutgoingEnvelope formats used across Hexabot channels.
  4. Webhook Setup

    • Develop a webhook endpoint to receive incoming messages and notifications from WhatsApp.
    • Include signature verification for incoming requests for security.
  5. Subscriber Management

    • Implement methods for syncing subscriber details with the WhatsApp channel, similar to onLabelCreate and onLabelDelete in the Messenger handler.
    • Handle subscriber updates and label assignments.
  6. Configuration Settings

    • Create default settings for the WhatsApp channel (e.g., access token, webhook verification token).
    • Use SettingService to manage these configurations.
  7. Logging and Error Handling

    • Integrate LoggerService for debug messages, errors, and other relevant log outputs throughout the handler.
    • Implement appropriate error handling, especially for message delivery and API interaction errors.
  8. Testing

    • Write unit tests to validate the WhatsApp channel handler's behavior.
    • Include tests for message formatting, API integration, subscriber synchronization, and webhook processing.

Additional Considerations

  • Consider rate limits and message template approvals that may be necessary when interacting with WhatsApp Business API.
  • Align the implementation with GDPR and privacy policies, given WhatsApp's data handling requirements.
  • Ensure compatibility with Hexabot's plugin system to extend functionality as needed.

Reference
The implementation should follow the design and patterns used in the MessengerHandler class to maintain consistency and reusability of components.

Milestones

  • [ ] Create initial WhatsApp channel handler class.
  • [ ] Integrate with WhatsApp Business API for core messaging.
  • [ ] Implement message formats and webhook handling.
  • [ ] Develop configuration settings and error handling.
  • [ ] Write unit tests.
  • [ ] Document the feature for end-users and developers.

Support Needed

  • Access to WhatsApp Business API credentials for development and testing.
  • Review of code structure and alignment with Hexabot standards.

marrouchi avatar Oct 09 '24 16:10 marrouchi