Skip to content

Commit

Permalink
Add notification to the webhook realtime transcript (#1256)
Browse files Browse the repository at this point in the history
Issue: #1255
  • Loading branch information
beastoin authored Nov 6, 2024
2 parents eb3275d + 050c732 commit 30cdb15
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions backend/utils/webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
enable_user_webhook_db, set_user_webhook_db
from models.memory import Memory
from models.users import WebhookType
import database.notifications as notification_db
from utils.notifications import send_notification


def memory_created_webhook(uid, memory: Memory):
Expand Down Expand Up @@ -73,6 +75,13 @@ async def realtime_transcript_webhook(uid, segments: List[dict]):
timeout=15,
)
print('realtime_transcript_webhook:', webhook_url, response.status_code)
response_data = response.json()
if not response_data:
return
message = response_data.get('message', '')
if message and len(message) > 5:
token = notification_db.get_token_only(uid)
send_webhook_notification(token, message)
except Exception as e:
print(f"Error sending realtime transcript to developer webhook: {e}")
else:
Expand Down Expand Up @@ -152,3 +161,6 @@ def webhook_first_time_setup(uid: str, wType: WebhookType) -> bool:
enable_user_webhook_db(uid, wType)
res = True
return res

def send_webhook_notification(token: str, message: str):
send_notification(token, "Webhook" + ' says', message)

0 comments on commit 30cdb15

Please sign in to comment.