diff --git a/frontend/src/layouts/MainLayout.tsx b/frontend/src/layouts/MainLayout.tsx index 15ced8b..70d9df1 100644 --- a/frontend/src/layouts/MainLayout.tsx +++ b/frontend/src/layouts/MainLayout.tsx @@ -10,11 +10,14 @@ import { UserOutlined, MenuFoldOutlined, MenuUnfoldOutlined, + ApartmentOutlined, } from '@ant-design/icons'; import { useAuthStore } from '../store/auth'; import Dashboard from '../pages/Dashboard'; import WhatsAppAccounts from '../pages/WhatsAppAccounts'; import Inbox from '../pages/Inbox'; +import FlowList from '../pages/FlowList'; +import FlowBuilder from '../pages/FlowBuilder'; const { Header, Sider, Content } = Layout; const { Text } = Typography; @@ -46,6 +49,11 @@ export default function MainLayout() { icon: , label: 'WhatsApp', }, + { + key: '/flows', + icon: , + label: 'Flujos', + }, { key: '/settings', icon: , @@ -151,6 +159,9 @@ export default function MainLayout() { } /> } /> } /> + } /> + } /> + } /> Configuración (próximamente)} /> diff --git a/services/api-gateway/app/core/config.py b/services/api-gateway/app/core/config.py index ebac1ea..b3e8260 100644 --- a/services/api-gateway/app/core/config.py +++ b/services/api-gateway/app/core/config.py @@ -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" diff --git a/services/api-gateway/app/routers/whatsapp.py b/services/api-gateway/app/routers/whatsapp.py index 8a3e395..2379a89 100644 --- a/services/api-gateway/app/routers/whatsapp.py +++ b/services/api-gateway/app/routers/whatsapp.py @@ -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"}