This commit is contained in:
2026-02-19 21:36:58 +00:00
committed by Anibal Angulo
parent 41ba38495b
commit 085e4b8610
37 changed files with 625 additions and 2200 deletions

View File

@@ -0,0 +1,53 @@
import logging
from fastapi import APIRouter, Depends, HTTPException
from ..models.notification import ExternalNotificationRequest
from ..services.notification_manager import NotificationManagerService
from ..dependencies import get_notification_manager
logger = logging.getLogger(__name__)
router = APIRouter(prefix="/api/v1/dialogflow", tags=["notifications"])
@router.post("/notification", status_code=200)
async def process_notification(
request: ExternalNotificationRequest,
notification_manager: NotificationManagerService = Depends(
get_notification_manager
),
) -> None:
"""
Process push notification from external system.
This endpoint receives notifications (e.g., "Your card was blocked") and:
1. Stores them in Redis/Firestore
2. Associates them with the user's conversation session
3. Triggers a Dialogflow event
When the user later sends a message asking about the notification
("Why was it blocked?"), the message filter will classify it as
NOTIFICATION and route to the appropriate handler.
Args:
request: External notification request with text, phone, and parameters
Returns:
None (204 No Content)
Raises:
HTTPException: 400 if validation fails, 500 for internal errors
"""
try:
logger.info("Received notification request")
await notification_manager.process_notification(request)
logger.info("Successfully processed notification request")
# Match Java behavior: process but don't return response body
except ValueError as e:
logger.error(f"Validation error: {str(e)}", exc_info=True)
raise HTTPException(status_code=400, detail=str(e))
except Exception as e:
logger.error(f"Error processing notification: {str(e)}", exc_info=True)
raise HTTPException(status_code=500, detail="Internal server error")