Spaces:
Sleeping
Sleeping
Upload tools.py
Browse files
tools.py
CHANGED
|
@@ -227,8 +227,7 @@ async def send_email(
|
|
| 227 |
"""
|
| 228 |
resend_key = os.environ.get("RESEND_API_KEY")
|
| 229 |
if not resend_key:
|
| 230 |
-
|
| 231 |
-
raise ToolError("E-Mail-Versand ist nicht konfiguriert (API-Key fehlt). Bitte info@webstark.org per E-Mail kontaktieren.")
|
| 232 |
|
| 233 |
if "@" not in to_email:
|
| 234 |
raise ToolError("Die E-Mail-Adresse scheint ungültig zu sein.")
|
|
@@ -255,7 +254,6 @@ async def send_email(
|
|
| 255 |
|
| 256 |
resend_from_name = os.environ.get("RESEND_FROM_NAME", "Elite")
|
| 257 |
resend_from_email = os.environ.get("RESEND_FROM_EMAIL", "elite@webstark.org")
|
| 258 |
-
logger.info(f"E-Mail-Versuch: von={resend_from_name} <{resend_from_email}>, an={to_email}")
|
| 259 |
|
| 260 |
try:
|
| 261 |
async with aiohttp.ClientSession() as session:
|
|
@@ -267,7 +265,7 @@ async def send_email(
|
|
| 267 |
"Accept-Encoding": "identity",
|
| 268 |
},
|
| 269 |
json={
|
| 270 |
-
"from":
|
| 271 |
"to": [to_email],
|
| 272 |
"subject": subject,
|
| 273 |
"html": html_body,
|
|
@@ -279,13 +277,11 @@ async def send_email(
|
|
| 279 |
return f"E-Mail wurde erfolgreich an {to_email} gesendet."
|
| 280 |
else:
|
| 281 |
error_text = await resp.text()
|
| 282 |
-
logger.error(f"Resend-Fehler
|
| 283 |
-
|
| 284 |
-
raise ToolError(f"E-Mail-Versand fehlgeschlagen (HTTP {resp.status}): {error_text}")
|
| 285 |
except aiohttp.ClientError as e:
|
| 286 |
-
logger.error(f"
|
| 287 |
-
raise ToolError(
|
| 288 |
-
|
| 289 |
|
| 290 |
|
| 291 |
# ============================================================
|
|
@@ -473,7 +469,7 @@ async def _notify_new_lead(lead_data: dict) -> None:
|
|
| 473 |
"Accept-Encoding": "identity",
|
| 474 |
},
|
| 475 |
json={
|
| 476 |
-
"from":
|
| 477 |
"to": [notify_email],
|
| 478 |
"subject": f"🔥 Neuer Lead: {lead_data['name']} – {lead_data['interest']}",
|
| 479 |
"html": f"""
|
|
@@ -495,7 +491,7 @@ async def _notify_new_lead(lead_data: dict) -> None:
|
|
| 495 |
async def _notify_summary(summary: dict) -> None:
|
| 496 |
"""Sendet eine Gesprächs-Zusammenfassung per E-Mail an Webstark."""
|
| 497 |
resend_key = os.environ.get("RESEND_API_KEY")
|
| 498 |
-
notify_email = os.environ.get("NOTIFY_EMAIL", "
|
| 499 |
if not resend_key:
|
| 500 |
return
|
| 501 |
|
|
@@ -509,10 +505,9 @@ async def _notify_summary(summary: dict) -> None:
|
|
| 509 |
headers={
|
| 510 |
"Authorization": f"Bearer {resend_key}",
|
| 511 |
"Content-Type": "application/json",
|
| 512 |
-
"Accept-Encoding": "identity",
|
| 513 |
},
|
| 514 |
json={
|
| 515 |
-
"from":
|
| 516 |
"to": [notify_email],
|
| 517 |
"subject": f"📝 Gesprächs-Zusammenfassung: {summary['customer_name']}",
|
| 518 |
"html": f"""
|
|
|
|
| 227 |
"""
|
| 228 |
resend_key = os.environ.get("RESEND_API_KEY")
|
| 229 |
if not resend_key:
|
| 230 |
+
raise ToolError("E-Mail-Versand ist momentan nicht konfiguriert. Bitte wende dich an info@webstark.org.")
|
|
|
|
| 231 |
|
| 232 |
if "@" not in to_email:
|
| 233 |
raise ToolError("Die E-Mail-Adresse scheint ungültig zu sein.")
|
|
|
|
| 254 |
|
| 255 |
resend_from_name = os.environ.get("RESEND_FROM_NAME", "Elite")
|
| 256 |
resend_from_email = os.environ.get("RESEND_FROM_EMAIL", "elite@webstark.org")
|
|
|
|
| 257 |
|
| 258 |
try:
|
| 259 |
async with aiohttp.ClientSession() as session:
|
|
|
|
| 265 |
"Accept-Encoding": "identity",
|
| 266 |
},
|
| 267 |
json={
|
| 268 |
+
"from": "Elite <elite@webstark.org>",
|
| 269 |
"to": [to_email],
|
| 270 |
"subject": subject,
|
| 271 |
"html": html_body,
|
|
|
|
| 277 |
return f"E-Mail wurde erfolgreich an {to_email} gesendet."
|
| 278 |
else:
|
| 279 |
error_text = await resp.text()
|
| 280 |
+
logger.error(f"Resend-Fehler: {resp.status} – {error_text}")
|
| 281 |
+
raise ToolError("E-Mail konnte nicht gesendet werden. Bitte versuche es später.")
|
|
|
|
| 282 |
except aiohttp.ClientError as e:
|
| 283 |
+
logger.error(f"HTTP-Fehler beim E-Mail-Versand: {e}")
|
| 284 |
+
raise ToolError("E-Mail-Versand fehlgeschlagen. Netzwerkfehler.")
|
|
|
|
| 285 |
|
| 286 |
|
| 287 |
# ============================================================
|
|
|
|
| 469 |
"Accept-Encoding": "identity",
|
| 470 |
},
|
| 471 |
json={
|
| 472 |
+
"from": "Elite <elite@webstark.org>",
|
| 473 |
"to": [notify_email],
|
| 474 |
"subject": f"🔥 Neuer Lead: {lead_data['name']} – {lead_data['interest']}",
|
| 475 |
"html": f"""
|
|
|
|
| 491 |
async def _notify_summary(summary: dict) -> None:
|
| 492 |
"""Sendet eine Gesprächs-Zusammenfassung per E-Mail an Webstark."""
|
| 493 |
resend_key = os.environ.get("RESEND_API_KEY")
|
| 494 |
+
notify_email = os.environ.get("NOTIFY_EMAIL", "[EMAIL_ADDRESS]")
|
| 495 |
if not resend_key:
|
| 496 |
return
|
| 497 |
|
|
|
|
| 505 |
headers={
|
| 506 |
"Authorization": f"Bearer {resend_key}",
|
| 507 |
"Content-Type": "application/json",
|
|
|
|
| 508 |
},
|
| 509 |
json={
|
| 510 |
+
"from": "Elite <elite@webstark.org>",
|
| 511 |
"to": [notify_email],
|
| 512 |
"subject": f"📝 Gesprächs-Zusammenfassung: {summary['customer_name']}",
|
| 513 |
"html": f"""
|