-
-
Notifications
You must be signed in to change notification settings - Fork 8
feat: add Folo webhook support #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This commit introduces two key enhancements: 1. **Folo Webhook Integration:** The webhook middleware has been updated to support Folo (https://app.follow.is). This integration allows users to leverage Folo as a trigger source. For instance, Folo can monitor RSS feeds and, upon receiving new content, automatically initiate Dify workflows such as translation or summarization. This enables automated generation of personalized reports, marketing copy, or even promotional posters. 2. **Dependency Update:** The `requirements.txt` file has been updated to reflect new Dify plugin version requirements. These changes enhance the plugin's capabilities by adding a powerful new trigger source and ensuring compatibility with the latest Dify plugin versions.
- Encapsulated Folo webhook logic into middlewares/folo_middleware.py. - Refined apply_middleware in helpers.py for clearer Folo integration and more robust DefaultMiddleware handling. - Ensures code structure aligns with existing project patterns.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @LogicOber,
Thank you for your contribution!
This PR needs a few adjustments, primarily the addition of missing tests. I'd also like to discuss the middleware features. Currently, it's designed for chatflows, but it might be more beneficial to integrate it with workflows.
I noticed that it only passes a few fields from the Folo webhook request body. It would be more effective to pass all the data to Dify, given that we’re providing middleware for it.
However, we might not need a custom middleware for Folo. We can use the webhook as it is with the json_string
setting. Just enable the toggle for "Transform req.body to req.body.json_string as JSON string." This way, you receive the entire request body as a JSON string, which can be parsed within the workflow using a Code block or the JSON Process plugin. You can define multiple fields as inputs to be passed to Dify. It would be beneficial to offer a Dify workflow with this plugin, allowing users who want to use this webhook plugin with Folo to avoid starting from scratch. If we do this, we could also share a basic workflow that handles the JSON parsing for them.
I'm considering maintaining a list of Dify Webhook integrations and providing a Plugin-Config along with an example Chatflow/Workflow. Could this be an alternative to your PR? Instead of adding this middleware, we could write a short guide and provide an example workflow. What do you think?
@@ -1,9 +1,13 @@ | |||
import json | |||
import logging # Ensure logging is imported |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove unnecessary comments like # Ensure logging is imported
|
||
logger = logging.getLogger(__name__) | ||
|
||
class FoloMiddleware: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please create a test for this middleware like in tests/middlewares/test_discord_middleware.py
@@ -1,4 +1,4 @@ | |||
version: 0.5.1 | |||
version: 0.5.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a new feature, so new version should be 0.6.0
This Pull Request introduces Folo webhook integration as a new trigger source and refactors the middleware handling logic for improved modularity, maintainability, and adherence to project conventions.
Key Features and Enhancements:
Folo Webhook Integration (Original Commit):
Dependency Update (Original Commit):
requirements.txt
has been updated to reflect new Dify plugin version requirements, ensuring compatibility.Modular Folo Middleware (Refactoring Commit):
FoloMiddleware
class withinmiddlewares/folo_middleware.py
.