From d69dfb7c8b2183a633bd849839e056e9317d4803 Mon Sep 17 00:00:00 2001 From: changchiyou Date: Wed, 27 Mar 2024 10:25:57 +0800 Subject: [PATCH] feat: support google chat webhook https://github.com/open-webui/open-webui/pull/1305/\#issuecomment-2021151237 --- backend/utils/webhook.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/backend/utils/webhook.py b/backend/utils/webhook.py index 4cfa41640..ed626d03e 100644 --- a/backend/utils/webhook.py +++ b/backend/utils/webhook.py @@ -1,17 +1,18 @@ import json - import requests from config import VERSION, WEBUI_FAVICON_URL, WEBUI_NAME - def post_webhook(url: str, message: str, event_data: dict) -> bool: try: payload = {} - if "https://hooks.slack.com" in url: + # Slack and Google Chat Webhooks + if "https://hooks.slack.com" in url or "https://chat.googleapis.com" in url: payload["text"] = message + # Discord Webhooks elif "https://discord.com/api/webhooks" in url: payload["content"] = message + # Microsoft Teams Webhooks elif "webhook.office.com" in url: action = event_data.get("action", "undefined") facts = [ @@ -33,6 +34,7 @@ def post_webhook(url: str, message: str, event_data: dict) -> bool: } ], } + # Default Payload else: payload = {**event_data} @@ -41,4 +43,4 @@ def post_webhook(url: str, message: str, event_data: dict) -> bool: return True except Exception as e: print(e) - return False + return False \ No newline at end of file