Skip to content

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

LogicOber
Copy link

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:

  1. Folo Webhook Integration (Original Commit):

    • The webhook now supports Folo (https://app.follow.is) as a middleware option.
    • This allows users to trigger Dify workflows (e.g., translation, summarization) based on events from Folo, such as new content from monitored RSS feeds.
    • Enables automated generation of reports, marketing copy, promotional materials, etc.
  2. Dependency Update (Original Commit):

    • requirements.txt has been updated to reflect new Dify plugin version requirements, ensuring compatibility.
  3. Modular Folo Middleware (Refactoring Commit):

    • The Folo-specific webhook processing logic has been encapsulated into a dedicated FoloMiddleware class within middlewares/folo_middleware.py.
    • This promotes better separation of concerns and aligns with the project's structure for individual middleware components.

CleanShot 2025-05-24 at 19 05 04@2x

LogicOber added 4 commits May 24, 2025 18:45
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.
@perzeuss perzeuss changed the title feat: Integrate Folo Webhook and Refactor Middleware Handling feat: add Folo webhook support May 29, 2025
Copy link
Owner

@perzeuss perzeuss left a 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
Copy link
Owner

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:
Copy link
Owner

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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants