mirror of
https://github.com/langgenius/dify-plugin-daemon.git
synced 2026-07-22 09:45:27 -04:00
70ba852ecc
* feat: cli tool support create trigger plugins * fix(trigger): update placeholder comment in SubscriptionConstructor for webhook registration --------- Co-authored-by: Harry <xh001x@hotmail.com>
30 lines
980 B
Python
30 lines
980 B
Python
from collections.abc import Mapping
|
|
from typing import Any
|
|
|
|
from werkzeug import Request
|
|
|
|
from dify_plugin.entities.trigger import Variables
|
|
from dify_plugin.errors.trigger import EventIgnoreError
|
|
from dify_plugin.interfaces.trigger import Event
|
|
|
|
|
|
class {{ .PluginName | SnakeToCamel }}TriggerEvent(Event):
|
|
"""
|
|
Basic example trigger handler that emits the raw incoming payload.
|
|
Replace the logic here with your integration specific processing.
|
|
"""
|
|
|
|
def _on_event(self, request: Request, parameters: Mapping[str, Any], payload: Mapping[str, Any]) -> Variables:
|
|
payload = request.get_json(silent=True) or {}
|
|
|
|
sample_filter = parameters.get("sample_filter")
|
|
if sample_filter and sample_filter not in str(payload):
|
|
raise EventIgnoreError()
|
|
|
|
return Variables(
|
|
variables={
|
|
"message": "Hello from {{ .PluginName | SnakeToCamel }}!",
|
|
"raw_event": payload,
|
|
}
|
|
)
|