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:
@@ -10,11 +10,14 @@ import {
|
|||||||
UserOutlined,
|
UserOutlined,
|
||||||
MenuFoldOutlined,
|
MenuFoldOutlined,
|
||||||
MenuUnfoldOutlined,
|
MenuUnfoldOutlined,
|
||||||
|
ApartmentOutlined,
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import { useAuthStore } from '../store/auth';
|
import { useAuthStore } from '../store/auth';
|
||||||
import Dashboard from '../pages/Dashboard';
|
import Dashboard from '../pages/Dashboard';
|
||||||
import WhatsAppAccounts from '../pages/WhatsAppAccounts';
|
import WhatsAppAccounts from '../pages/WhatsAppAccounts';
|
||||||
import Inbox from '../pages/Inbox';
|
import Inbox from '../pages/Inbox';
|
||||||
|
import FlowList from '../pages/FlowList';
|
||||||
|
import FlowBuilder from '../pages/FlowBuilder';
|
||||||
|
|
||||||
const { Header, Sider, Content } = Layout;
|
const { Header, Sider, Content } = Layout;
|
||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
@@ -46,6 +49,11 @@ export default function MainLayout() {
|
|||||||
icon: <WhatsAppOutlined />,
|
icon: <WhatsAppOutlined />,
|
||||||
label: 'WhatsApp',
|
label: 'WhatsApp',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: '/flows',
|
||||||
|
icon: <ApartmentOutlined />,
|
||||||
|
label: 'Flujos',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: '/settings',
|
key: '/settings',
|
||||||
icon: <SettingOutlined />,
|
icon: <SettingOutlined />,
|
||||||
@@ -151,6 +159,9 @@ export default function MainLayout() {
|
|||||||
<Route path="/" element={<Dashboard />} />
|
<Route path="/" element={<Dashboard />} />
|
||||||
<Route path="/inbox" element={<Inbox />} />
|
<Route path="/inbox" element={<Inbox />} />
|
||||||
<Route path="/whatsapp" element={<WhatsAppAccounts />} />
|
<Route path="/whatsapp" element={<WhatsAppAccounts />} />
|
||||||
|
<Route path="/flows" element={<FlowList />} />
|
||||||
|
<Route path="/flows/new" element={<FlowBuilder />} />
|
||||||
|
<Route path="/flows/:id" element={<FlowBuilder />} />
|
||||||
<Route path="/settings" element={<div>Configuración (próximamente)</div>} />
|
<Route path="/settings" element={<div>Configuración (próximamente)</div>} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</Content>
|
</Content>
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ class Settings(BaseSettings):
|
|||||||
# WhatsApp Core
|
# WhatsApp Core
|
||||||
WHATSAPP_CORE_URL: str = "http://localhost:3001"
|
WHATSAPP_CORE_URL: str = "http://localhost:3001"
|
||||||
|
|
||||||
|
# Flow Engine
|
||||||
|
FLOW_ENGINE_URL: str = "http://localhost:8001"
|
||||||
|
|
||||||
# CORS
|
# CORS
|
||||||
CORS_ORIGINS: str = "http://localhost:5173,http://localhost:3000"
|
CORS_ORIGINS: str = "http://localhost:5173,http://localhost:3000"
|
||||||
|
|
||||||
|
|||||||
@@ -271,6 +271,38 @@ async def handle_whatsapp_event(
|
|||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
conversation.last_message_at = datetime.utcnow()
|
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()
|
db.commit()
|
||||||
return {"status": "ok"}
|
return {"status": "ok"}
|
||||||
|
|||||||
Reference in New Issue
Block a user