feat(phase2): integrate flow engine and add flows navigation

- Add FLOW_ENGINE_URL to API Gateway config
- Integrate flow engine in message handler (BOT status only)
- Add /flows routes to MainLayout with FlowList and FlowBuilder
- Add Flujos menu item with ApartmentOutlined icon

This completes Phase 2: Flow Engine Básico

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Claude AI
2026-01-29 10:24:08 +00:00
parent c97d380635
commit 363e332f29
3 changed files with 46 additions and 0 deletions

View File

@@ -18,6 +18,9 @@ class Settings(BaseSettings):
# WhatsApp Core
WHATSAPP_CORE_URL: str = "http://localhost:3001"
# Flow Engine
FLOW_ENGINE_URL: str = "http://localhost:8001"
# CORS
CORS_ORIGINS: str = "http://localhost:5173,http://localhost:3000"

View File

@@ -271,6 +271,38 @@ async def handle_whatsapp_event(
from datetime import datetime
conversation.last_message_at = datetime.utcnow()
db.commit()
db.refresh(message)
# Process message through Flow Engine (if in BOT status)
if conversation.status == ConversationStatus.BOT:
async with httpx.AsyncClient() as client:
try:
await client.post(
f"{settings.FLOW_ENGINE_URL}/process",
json={
"conversation_id": str(conversation.id),
"contact": {
"id": str(contact.id),
"phone_number": contact.phone_number,
"name": contact.name,
},
"conversation": {
"id": str(conversation.id),
"status": conversation.status.value,
},
"message": {
"id": str(message.id),
"content": content,
"type": message.type.value,
},
},
timeout=30,
)
except Exception as e:
print(f"Flow engine error: {e}")
return {"status": "ok"}
db.commit()
return {"status": "ok"}