app icon
Webhook
0.5.1

Trigger a dify app from webhook.

perzeuss/webhook11097 installs

Dify Plugin: Webhook

🔍 Description

This project is a Dify Plugin that enables seamless triggering of Dify applications using webhooks. With this plugin, you can effortlessly initiate both chatflows and workflows through HTTP requests from any third-party system. 🚀

⭐ GitHub Repository

Star and watch our GitHub repository at https://github.com/perzeuss/dify-plugin-webhook to be notified about new releases! The project is open source, feel free to fork and modify it!

✨ Key Features & Benefits

FeatureWebhook PluginStandard Dify APIBenefit
Flexible API Key LocationSupports header, URL param, or noneOnly Authorization headerCompatible with more third-party systems
Custom EndpointsCreate multiple endpoints with different configsLimited to standard endpointsSupport different third-party integrations simultaneously
Request Body HandlingFull body or inputs object onlyFixed schema requiredWorks with systems that can't match Dify's schema
Raw Data OutputOptional removal of Dify metadataAlways includes metadataClean responses for third-party integrations
Middleware SupportExtensible with custom middlewareNot availableAdd custom validation, or transformations
Discord IntegrationBuilt-in Discord webhook supportRequires custom implementationEffortless Discord bot creation
Authentication OptionsThree authentication methodsFixed authorizationFlexible security model

🚀 Getting Started

📦 Installation

Visit the Dify Plugin marketplace, search for the "Webhook" plugin and click the install button. After installation, click on the "Webhook" plugin on the plugins page.

  1. Create Endpoint:
    In the Endpoints section, click the "+" icon to create a unique webhook domain. You can choose any name you want. Each endpoint can have its own configuration, such as individualized credentials and request handling.

  2. Configure API Key:
    After installing the plugin, ensure you have set up an API key in your settings, unless using the option for the API key location. For other configurations, this key is necessary for authenticating requests.

  3. Configure API Key Location:
    The API key can be utilized in various ways for compatibility with 3rd party systems:

    • header
    • URL query parameter
    • (no API key required)
  4. Middleware Support:
    The plugin supports the use of custom middlewares for request validation, transformations, and more. Built-in support for Discord webhooks is included, and you can add more middleware for other integrations. Please open a GitHub issue before working on custom middlewares - at the moment there is no dedicated middleware api and you might need to modify the main plugin code to support additional middleware features.

  5. Specify Input Handling:
    You have the option to specify whether to use or the entire for input variables. This flexibility enhances integration with third-party systems that don't support defining the request payload structure required by Dify.

  6. JSON String Input:
    Enable this option to automatically convert the entire request body to a JSON string. This is particularly useful when you want to pass a complex payload through a single input variable in Dify and parse it within your application logic.

  7. Specify Output Handling:
    Configure the output data from workflows. The webhook can send res.body.data (Output of the End node) as the response body without Dify metadata. By default the response contains metada which could conflict with the requirements of your integration.

  8. Available Endpoints:
    You have access to the following endpoint URLs:

    • Dynamic endpoints, exposes all apps in the workspace
      • Chatflow Endpoint:
      • Workflow Endpoint:
    • Single app endpoints, exposes only the selected app
      • Chatflow Endpoint:
      • Workflow Endpoint:

📘 Usage Guide

🔊 Chatflow Endpoint

Trigger a chatflow by sending a POST request to the chatflow endpoint:

  • URL Without App:
  • URL With App:
  • Method:
  • Headers:
    • If using an API key:
  • Body (JSON):

For endpoints configured with a specific Dify app, use the route. A successful response will include the chatflow output.

🔄 Workflow Endpoint

To initiate a workflow, send a POST request to the workflow endpoint:

  • URL Without App:
  • URL With App:
  • Method:
  • Headers:
    • If using an API key:
  • Body (JSON):

For endpoints configured with a specific Dify app, use the route. The response will contain results from the workflow execution.

🧩 Customization with Middlewares

The plugin supports middleware for extended functionality:

  1. Discord Webhook Integration:
    Built-in support for Discord interaction verification and response handling.

  2. Default Middleware:
    Provides JSON string conversion functionality.

  3. Custom Middlewares:
    You can develop additional middlewares to:

    • Verify signatures from other platforms
    • Transform request and response data
    • Implement custom authentication methods
    • Handle special payload formats

⚙️ Advanced Configuration Examples

Multiple Endpoints Configuration

You can create multiple endpoints with different configurations. For example:

  • Discord Bot Endpoint: With Discord middleware and public key for signature verification
  • Zapier Integration: With request payload in json_string variable and res.body.data as output
  • Internal Systems: With full response data including metadata for token usage tracking

Custom Response Formatting

For workflows that need to integrate with systems expecting specific response formats:

  1. Enable the toggle for:
  2. In your Dify workflow, ensure the End node provides exactly the format expected

🔍 Troubleshooting

  • Use valid JSON for request bodies to avoid parsing errors.
  • Successful requests return a 200 status code. Unauthorized access returns a 403 status code unless API key location is set to .
  • Proper error messages are given for input validation failures, returning a 400 status code.

Leverage the power of Dify by automating your chatflow and workflow triggers efficiently using this webhook plugin! 🎉

🙏 Acknowledgments

Special thanks to the Dify team for delivering a fantastic developer experience and tools that facilitated the creation of this plugin. The first version of this plugin was developed during a beta program, and we appreciate the support and resources made available throughout the period. ❤️*

CATEGORY
Extension
VERSION
0.5.1
perzeuss·03/28/2025 07:01 AM
REQUIREMENTS
App invocation
Endpoint registration
Maximum memory
256MB