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:
@@ -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"}
|
||||
|
||||
Reference in New Issue
Block a user