chainlit icon indicating copy to clipboard operation
chainlit copied to clipboard

[Add] Implement Slack Socket Mode support

Open JCMarques15 opened this issue 1 year ago • 4 comments
trafficstars

Description

This PR introduces support for Slack Socket Mode, enabling real-time message processing using websockets. This feature enhances the Slack integration by allowing for more efficient and responsive communication, and a way to bypass ingress restrictive networks.

Changes

  • Added Slack Socket Mode handler in server.py
  • Created start_socket_mode function in slack/app.py
  • Implemented conditional logic to use Socket Mode when SLACK_WEBSOCKET_TOKEN is set
  • Added an example script slack_websocket_test.py for testing the Slack websocket handler

How to Test

  1. Set the following environment variables:
    • SLACK_BOT_TOKEN
    • SLACK_SIGNING_SECRET
    • SLACK_WEBSOCKET_TOKEN
  2. Run the application and verify that the Slack integration connects using Socket Mode
  3. Test sending messages through Slack and ensure they are processed correctly

Additional Notes

  • The existing HTTP handler remains active when only SLACK_BOT_TOKEN and SLACK_SIGNING_SECRET are provided
  • When SLACK_WEBSOCKET_TOKEN is set, the application will prioritize Socket Mode over the HTTP handler

JCMarques15 avatar Oct 15 '24 11:10 JCMarques15