chainlit
chainlit copied to clipboard
[Add] Implement Slack Socket Mode support
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_modefunction inslack/app.py - Implemented conditional logic to use Socket Mode when
SLACK_WEBSOCKET_TOKENis set - Added an example script
slack_websocket_test.pyfor testing the Slack websocket handler
How to Test
- Set the following environment variables:
SLACK_BOT_TOKENSLACK_SIGNING_SECRETSLACK_WEBSOCKET_TOKEN
- Run the application and verify that the Slack integration connects using Socket Mode
- Test sending messages through Slack and ensure they are processed correctly
Additional Notes
- The existing HTTP handler remains active when only
SLACK_BOT_TOKENandSLACK_SIGNING_SECRETare provided - When
SLACK_WEBSOCKET_TOKENis set, the application will prioritize Socket Mode over the HTTP handler