Files
talia_bot/talia_bot/webhook_client.py
google-labs-jules[bot] 402fd1d8bc refactor: Clean up empty modules and fix imports
Remove empty placeholder modules talia_bot/modules/printer.py and talia_bot/modules/sales_rag.py.

Update import paths across multiple modules to be absolute from the project root (talia_bot), improving consistency.

Corrected import paths for config variables and utility functions. Standardized the use of the ADMIN_ID configuration variable, resolving a discrepancy where OWNER_CHAT_ID was used.

Removed a duplicated docstring in scheduler.py.
2025-12-21 08:35:05 +00:00

34 lines
1.2 KiB
Python

# app/webhook_client.py
# Este script se encarga de enviar datos a servicios externos usando "webhooks".
# En este caso, se comunica con n8n.
import requests
from talia_bot.config import N8N_WEBHOOK_URL, N8N_TEST_WEBHOOK_URL
def send_webhook(event_data):
"""
Envía datos de un evento al servicio n8n.
Usa el webhook normal y, si falla o no existe, usa el de test como fallback.
"""
# Intentar con el webhook principal
if N8N_WEBHOOK_URL:
try:
print(f"Intentando enviar a webhook principal: {N8N_WEBHOOK_URL}")
response = requests.post(N8N_WEBHOOK_URL, json=event_data)
response.raise_for_status()
return response.json()
except Exception as e:
print(f"Fallo en webhook principal: {e}")
# Fallback al webhook de test
if N8N_TEST_WEBHOOK_URL:
try:
print(f"Intentando enviar a webhook de fallback (test): {N8N_TEST_WEBHOOK_URL}")
response = requests.post(N8N_TEST_WEBHOOK_URL, json=event_data)
response.raise_for_status()
return response.json()
except Exception as e:
print(f"Fallo en webhook de fallback: {e}")
return None