Adds webhook node.
This commit is contained in:
@@ -19,6 +19,13 @@ Plays a chime sound to notify the user.
|
||||
|
||||
<img src="assets/play_sound_node.jpg" width="400"/>
|
||||
|
||||
|
||||
## Webhook
|
||||
|
||||
Send a webhook to the specified URL. Supports customizing JSON body with the `json_format` template.
|
||||
|
||||
<img src="assets/webhook_node.jpg" width="400"/>
|
||||
|
||||
## Unified Notification
|
||||
|
||||
Supports multiple notification types in one node for convenience.
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
from .nodes.play_sound import PlaySound
|
||||
from .nodes.system_notification import SystemNotification
|
||||
from .nodes.unified_notification import UnifiedNotification
|
||||
from .nodes.webhook import Webhook
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"Notif-PlaySound": PlaySound,
|
||||
"Notif-SystemNotification": SystemNotification,
|
||||
"Notif-UnifiedNotification": UnifiedNotification,
|
||||
"Notif-Webhook": Webhook,
|
||||
}
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"Notif-PlaySound": "Play Sound",
|
||||
"Notif-SystemNotification": "System Notification",
|
||||
"Notif-UnifiedNotification": "Unified Notification",
|
||||
"Notif-Webhook": "Webhook",
|
||||
}
|
||||
|
||||
WEB_DIRECTORY = "./web"
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
@@ -0,0 +1,30 @@
|
||||
import requests
|
||||
import json
|
||||
|
||||
from .util import ComfyAnyType
|
||||
|
||||
class Webhook:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"any": (ComfyAnyType("*"), {}),
|
||||
# "mode": (["always", "on empty queue"], {}), # TODO: Need a way to get queue status from main.py
|
||||
"webhook_url": ("STRING", {'default': 'http://localhost:5000/'}),
|
||||
"notification_text": ('STRING', {'default': 'Your notification has triggered.'}),
|
||||
"json_format": ('STRING', {'default': '{"text": "<notification_text>"}'}),
|
||||
"timeout": ('FLOAT', {'default': 3, 'min': 0, 'max': 60}),
|
||||
},
|
||||
}
|
||||
|
||||
FUNCTION = 'hook'
|
||||
OUTPUT_NODE = True
|
||||
RETURN_TYPES = tuple()
|
||||
CATEGORY = "notifications"
|
||||
|
||||
def hook(self, any, webhook_url, notification_text, json_format, timeout):
|
||||
payload = json_format.replace("<notification_text>", notification_text)
|
||||
payload = json.loads(payload)
|
||||
res = requests.post(webhook_url, json=payload, timeout=timeout)
|
||||
res.raise_for_status()
|
||||
return (0, )
|
||||
Reference in New Issue
Block a user