better Webex
Build, push image, and notify Watchtower / build-image (push) Successful in 42s
Build, push image, and notify Watchtower / notify (push) Successful in 12s

This commit is contained in:
2026-08-17 14:46:35 +02:00
parent 0149c1e5b2
commit 44b4c8034f
3 changed files with 123 additions and 25 deletions
+33 -6
View File
@@ -66,7 +66,7 @@ class WebexManager:
new_doc = self.save_tokens(res.json())
return new_doc["access_token"]
def create_support_room(self, client_name: str, client_email: str) -> str:
def create_support_room(self, client_name: str, client_email: str, alert_type: str, alert_message: str, alert_id: str) -> str:
"""Creates a team support room and invites the client and yourself."""
access_token = self.get_access_token()
headers = {
@@ -79,12 +79,13 @@ class WebexManager:
f"{self.base_url}/rooms",
headers=headers,
json={
"title": f"Smartwave Support: {client_name}",
"title": f"Smartwave Support: {client_name} - {alert_type} ({alert_id})",
"teamId": self.team_id
}
)
room_res.raise_for_status()
room_id = room_res.json()["id"]
room_details = room_res.json()
room_id = room_details["id"]
# 2. Add Client via email (Webex sends invite if user does not exist)
if client_email:
@@ -103,13 +104,39 @@ class WebexManager:
)
# 4. Optional: Send initial welcome message in the room
self.send_message(
room_id,
message=f"Support room initialized for {client_name}. An agent will be with you shortly.",
access_token=access_token
)
self.send_alert_info_message(room_id, alert_type, alert_message, alert_id, access_token=access_token)
return room_details
def send_message(self, room_id: str, message: str | None = None, markdown: str | None = None, access_token: str | None = None):
# Fetch the token so it auto-refreshes if needed
if not access_token:
access_token = self.get_access_token()
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json"
}
requests.post(
f"{self.base_url}/messages",
headers=headers,
json={
"roomId": room_id,
"text": f"Support room initialized for {client_name}. An agent will be with you shortly."
"text": message,
"markdown": markdown
}
)
).raise_for_status()
def send_alert_info_message(self, room_id: str, alert_type: str, alert_message: str, alert_id: str, added_alert_info: bool = False, access_token: str | None = None):
"""Sends a structured alert info message to the specified Webex room."""
if added_alert_info:
message = f"Additional Alert Details:\n- Type: {alert_type}\n- Message: {alert_message}\n- Alert ID: {alert_id}"
else:
message = f"Alert Details:\n- Type: {alert_type}\n- Message: {alert_message}\n- Alert ID: {alert_id}"
return room_id
self.send_message(room_id, message=message, access_token=access_token)