whatsapp notification using Twilio

This commit is contained in:
Waheed-Mousad
2025-06-09 05:48:10 +03:00
parent ad73310848
commit 79934c4337
7 changed files with 44 additions and 20 deletions
+3 -3
View File
@@ -1,9 +1,9 @@
from .whatsapp_notify_node import WhatsAppNotifyNode
from .notify_whatsapp_twilio import WhatsAppNotifyNodeTwilio
NODE_CLASS_MAPPINGS = {
"WhatsAppNotifyNode": WhatsAppNotifyNode,
"WhatsAppNotifyNodeTwilio": WhatsAppNotifyNodeTwilio,
}
NODE_DISPLAY_NAME_MAPPINGS = {
"WhatsAppNotifyNode": "📲 WhatsApp Notify",
"WhatsAppNotifyNodeTwilio": "📲 WhatsApp (Twilio)",
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
+40
View File
@@ -0,0 +1,40 @@
from twilio.rest import Client
class WhatsAppNotifyNodeTwilio:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"img": ("IMAGE",),
"message": ("STRING", {"default": "✅ Workflow completed!"}),
"sid": ("STRING", {"default": "Your Twilio SID here"}),
"token": ("STRING", {"default": "Your Twilio Auth Token"}),
"from_number": ("STRING", {"default": "whatsapp:+14155238886"}), # Twilio Sandbox
"to_number": ("STRING", {"default": "whatsapp:+YOUR_PHONE_NUMBER"}), # Your verified number
}
}
RETURN_TYPES = ("IMAGE",)
FUNCTION = "notify"
CATEGORY = "Notifications"
def notify(self, img, message, sid, token, from_number, to_number):
try:
# Basic validation
required_fields = [sid, token, from_number, to_number]
if any(v.strip() == "" or "Twilio" in v for v in required_fields):
raise ValueError("One or more required fields are missing or still set to default.")
client = Client(sid.strip(), token.strip())
sent = client.messages.create(
from_=from_number.strip(),
body=message.strip(),
to=to_number.strip()
)
print(f"[📲 WhatsAppNotifyNodeTwilio] ✅ WhatsApp message sent. SID: {sent.sid}")
except Exception as e:
print("❌ WhatsAppNotifyNodeTwilio Error: ", str(e).split('\n')[0])
return (img,)
+1
View File
@@ -0,0 +1 @@
twilio
-17
View File
@@ -1,17 +0,0 @@
class WhatsAppNotifyNode:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"img": ("IMAGE",),
"message": ("STRING", {"default": "✅ Workflow completed!"}),
}
}
RETURN_TYPES = ("IMAGE",)
FUNCTION = "notify"
CATEGORY = "Notifications"
def notify(self, img, message: str):
print(f"[📲 WhatsAppNotifyNode] Message to send: {message}")
return (img,) # Pass image forward so node isn't "useless"