WebhookNotifierNode support any input
This commit is contained in:
@@ -1,14 +1,12 @@
|
||||
# ComfyUI-WebhookNotifier
|
||||
|
||||
Webhook notification plugin for ComfyUI, used to send webhook notifications when image generation is completed.
|
||||
Webhook notification plugin for ComfyUI, used to send webhook notifications when workflow execution is completed.
|
||||
|
||||
## Features
|
||||
|
||||
- Automatically sends webhook notifications after generating images
|
||||
- Automatically sends webhook notifications after workflow execution
|
||||
- Supports custom JSON data in notifications
|
||||
- Provides two nodes:
|
||||
- `Webhook Notifier`: connect to an `IMAGE` output as a trigger
|
||||
- `Webhook Notifier (VHS)`: connect to a `VHS_FILENAMES` output as a trigger
|
||||
- Accepts any input type as trigger (IMAGE, STRING, LATENT, VHS_FILENAMES, etc.)
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -29,16 +27,16 @@ pip install -r requirements.txt
|
||||
|
||||
## Usage
|
||||
|
||||
The plugin provides a Webhook Notifier node that can be connected to image output to send notifications when generation is complete.
|
||||
The plugin provides a Webhook Notifier node that can be connected to any output to send notifications when execution is complete.
|
||||
|
||||
Parameter description:
|
||||
- `images`: Trigger input (required, can connect to an `IMAGE` output or a `VHS_FILENAMES` output; the data is **not** read or sent, only used as a trigger)
|
||||
- `webhook_url`: Webhook URL address (required, default is "https://example.com/webhook")
|
||||
- `any_input`: Trigger input (optional, accepts any type such as IMAGE, STRING, LATENT, VHS_FILENAMES, etc.; the data is **not** read or sent, only used as a trigger)
|
||||
- `additional_info`: Additional information in JSON format (optional, default is empty)
|
||||
|
||||
## Webhook Notification Format
|
||||
|
||||
The WebhookNotifier node sends the contents of the `additional_info` parameter as the JSON payload. **Note that the image data itself is not included in the webhook payload**. The node only requires the image input to trigger the notification when image generation is complete.
|
||||
The WebhookNotifier node sends the contents of the `additional_info` parameter as the JSON payload. **Note that the input data itself is not included in the webhook payload**. The node only requires the `any_input` connection to trigger the notification when execution is complete.
|
||||
|
||||
For example, if you provide the following in the additional_info field:
|
||||
|
||||
@@ -54,7 +52,7 @@ This exact JSON will be sent to the webhook URL. If the additional_info field is
|
||||
|
||||
## Example
|
||||
|
||||
Connect the output of an image generation node (type `IMAGE`) or a VHS/VideoHelperSuite node (type `VHS_FILENAMES`) to the WebhookNotifier node's `images` input, set your webhook URL, and optionally provide additional information in JSON format. When generation is complete and this node is executed, it will send a POST request to the specified webhook URL with your custom data.
|
||||
Connect any output (IMAGE, STRING, LATENT, VHS_FILENAMES, etc.) to the WebhookNotifier node's `any_input`, set your webhook URL, and optionally provide additional information in JSON format. When the upstream node completes execution, the webhook will send a POST request to the specified URL with your custom data.
|
||||
|
||||
## Debugging
|
||||
|
||||
|
||||
+2
-5
@@ -4,10 +4,7 @@ import os
|
||||
NODE_CLASS_MAPPINGS = {}
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {}
|
||||
|
||||
from .webhook_notifier import WebhookNotifierNode, WebhookNotifierVHSNode
|
||||
from .webhook_notifier import WebhookNotifierNode
|
||||
|
||||
NODE_CLASS_MAPPINGS["WebhookNotifierNode"] = WebhookNotifierNode
|
||||
NODE_DISPLAY_NAME_MAPPINGS["WebhookNotifierNode"] = "Webhook Notifier"
|
||||
|
||||
NODE_CLASS_MAPPINGS["WebhookNotifierVHSNode"] = WebhookNotifierVHSNode
|
||||
NODE_DISPLAY_NAME_MAPPINGS["WebhookNotifierVHSNode"] = "Webhook Notifier (VHS)"
|
||||
NODE_DISPLAY_NAME_MAPPINGS["WebhookNotifierNode"] = "Webhook Notifier"
|
||||
+4
-55
@@ -31,11 +31,11 @@ class WebhookNotifierNode:
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
# 接收图像结果,用于作为触发输入
|
||||
"images": ("IMAGE",),
|
||||
"webhook_url": ("STRING", {"default": "https://example.com/webhook"})
|
||||
},
|
||||
"optional": {
|
||||
# 通配符,接受任意类型作为触发输入
|
||||
"any_input": ("*",),
|
||||
"additional_info": ("STRING", {"default": "{}", "multiline": True})
|
||||
},
|
||||
"hidden": {
|
||||
@@ -49,7 +49,7 @@ class WebhookNotifierNode:
|
||||
FUNCTION = "notify"
|
||||
CATEGORY = "utils"
|
||||
|
||||
def notify(self, images, webhook_url, additional_info="{}"):
|
||||
def notify(self, webhook_url, any_input=None, additional_info="{}"):
|
||||
try:
|
||||
# Try to parse additional information
|
||||
try:
|
||||
@@ -74,55 +74,4 @@ class WebhookNotifierNode:
|
||||
print(f"Error preparing webhook: {str(e)}")
|
||||
|
||||
# No return value
|
||||
return ()
|
||||
|
||||
|
||||
class WebhookNotifierVHSNode:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
# 接收 VHS/VideoHelperSuite 等节点输出的文件名列表,用于作为触发输入
|
||||
"vhs_filenames": ("VHS_FILENAMES",),
|
||||
"webhook_url": ("STRING", {"default": "https://example.com/webhook"})
|
||||
},
|
||||
"optional": {
|
||||
"additional_info": ("STRING", {"default": "{}", "multiline": True})
|
||||
},
|
||||
"hidden": {
|
||||
}
|
||||
}
|
||||
|
||||
OUTPUT_NODE = True
|
||||
|
||||
RETURN_TYPES = ()
|
||||
RETURN_NAMES = ()
|
||||
FUNCTION = "notify"
|
||||
CATEGORY = "utils"
|
||||
|
||||
def notify(self, vhs_filenames, webhook_url, additional_info="{}"):
|
||||
try:
|
||||
# 解析附加信息
|
||||
try:
|
||||
extra_info = json.loads(additional_info) if additional_info else {}
|
||||
except json.JSONDecodeError:
|
||||
extra_info = {}
|
||||
|
||||
# 构建 payload(默认不发送具体文件名,仅作为触发)
|
||||
payload = {
|
||||
**extra_info
|
||||
}
|
||||
|
||||
# 在后台线程中发送 webhook
|
||||
threading.Thread(
|
||||
target=send_webhook_request,
|
||||
args=(webhook_url, payload),
|
||||
daemon=True
|
||||
).start()
|
||||
print("Webhook notification (VHS) started in background")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error preparing webhook (VHS): {str(e)}")
|
||||
|
||||
# 无返回值
|
||||
return ()
|
||||
return ()
|
||||
Reference in New Issue
Block a user