This guide provides a complete walkthrough for developing a Slack Bot plugin, covering project initialization, configuration form editing, feature implementation, debugging, endpoint setup, verification, and packaging. You’ll need the Dify plugin scaffolding tool and a pre-created Slack App to build an AI-powered chatbot on Slack.
To avoid confusion, the following concepts are explained:How It Works (A Simple Overview):
- Slack Bot A chatbot on the Slack platform, acting as a virtual user you can interact with in real-time.
- Slack Bot Plugin A plugin in the Dify Marketplace that connects a Dify application with Slack. This guide focuses on how to develop that plugin.
extension
template, and grant both Apps
and Endpoints
permissions.
For additional details on reverse-invoking Dify services within a plugin, see Reverse Invocation: App.
group/slack.yaml
. The form’s filename is determined by the info you provided when creating the plugin, so adjust it accordingly.
Sample Code:
slack.yaml
endpoints/slack.yaml
file, change the request method to POST to handle incoming Slack messages properly.
Sample Code:
endpoints/slack.yaml
endpoints/slack.py
file and add the following code:
.env.example
file and rename it to .env
.
python -m main
to start the plugin. You should now see your plugin installed in the Workspace on Dify’s plugin management page. Other team members will also be able to access it.
self.session.app.chat.invoke
is used to call the Dify application, passing in parameters such as app_id
and query
. The response is then returned to the Slack Bot. Run python -m main
again to restart your plugin for debugging, and check whether Slack correctly displays the Dify App’s reply:
slack_bot.difypkg
file in the current directory—your final plugin package. For detailed packaging steps, refer to Package as a Local File and Share.