feat: Implement JSON-based conversational flow engine

This commit introduces a modular, JSON-driven conversational flow engine.

Key changes:
- Adds `talia_bot/modules/flow_engine.py` to manage loading and processing conversational flows from external files.
- Separates all conversational logic into individual JSON files within `talia_bot/data/flows/`, organized by user role (admin, crew, client).
- Updates `talia_bot/main.py` to use the new flow engine, replacing the previous hardcoded logic with a dynamic dispatcher.
- Corrects the `.gitignore` file to properly track the new JSON flow files while ensuring sensitive credentials like `google_key.json` remain ignored.
- Updates the `README.md` to reflect the new architecture, providing clear documentation for the modular flow system.

This new architecture makes the bot more maintainable and scalable by decoupling the conversation logic from the core application code.
This commit is contained in:
google-labs-jules[bot]
2025-12-21 07:45:55 +00:00
parent ac52998d47
commit 4750ddf43d
13 changed files with 277 additions and 7 deletions

View File

@@ -0,0 +1,25 @@
{
"id": "admin_block_agenda",
"role": "admin",
"trigger_button": "🛑 Bloquear Agenda",
"steps": [
{
"step_id": 0,
"variable": "BLOCK_DATE",
"question": "Necesito bloquear la agenda. ¿Para cuándo?",
"options": ["Hoy", "Mañana"]
},
{
"step_id": 1,
"variable": "BLOCK_TIME",
"question": "Dame el horario exacto que necesitas bloquear (ej. 'de 2pm a 4pm').",
"input_type": "text"
},
{
"step_id": 2,
"variable": "BLOCK_TITLE",
"question": "Finalmente, dame una breve descripción o motivo del bloqueo.",
"input_type": "text"
}
]
}

View File

@@ -0,0 +1,19 @@
{
"id": "admin_check_agenda",
"role": "admin",
"trigger_button": "📅 Revisar Agenda",
"steps": [
{
"step_id": 0,
"variable": "AGENDA_TIMEFRAME",
"question": "Consultando el oráculo del tiempo... ⏳",
"options": ["📅 Hoy", "🔮 Mañana"]
},
{
"step_id": 1,
"variable": "AGENDA_ACTION",
"question": "Aquí tienes tu realidad: {CALENDAR_DATA}",
"options": ["✅ Todo bien", "🛑 Bloquear Espacio"]
}
]
}

View File

@@ -0,0 +1,25 @@
{
"id": "admin_create_nfc_tag",
"role": "admin",
"trigger_button": " Crear Tag NFC",
"steps": [
{
"step_id": 0,
"variable": "NFC_ACTION_TYPE",
"question": "Creemos un nuevo tag NFC. ¿Qué acción quieres que dispare?",
"options": ["Iniciar Flujo", "URL Estática"]
},
{
"step_id": 1,
"variable": "NFC_FLOW_CHOICE",
"question": "Okay, ¿qué flujo debería iniciar este tag?",
"input_type": "dynamic_keyboard_flows"
},
{
"step_id": 2,
"variable": "NFC_CONFIRM",
"question": "Perfecto. Cuando acerques tu teléfono a este tag, se iniciará el flujo '{flow_name}'. Aquí tienes los datos para escribir en el tag: {NFC_DATA}",
"options": ["✅ Hecho"]
}
]
}

View File

@@ -0,0 +1,25 @@
{
"id": "admin_idea_capture",
"role": "admin",
"trigger_button": "💡 Capturar Idea",
"steps": [
{
"step_id": 0,
"variable": "IDEA_CONTENT",
"question": "Te escucho. 💡 Las ideas vuelan...",
"input_type": "text_or_audio"
},
{
"step_id": 1,
"variable": "IDEA_CATEGORY",
"question": "¿En qué cajón mental guardamos esto?",
"options": ["💰 Negocio", "📹 Contenido", "👤 Personal"]
},
{
"step_id": 2,
"variable": "IDEA_ACTION",
"question": "¿Cuál es el plan de ataque?",
"options": ["✅ Crear Tarea", "📓 Guardar Nota"]
}
]
}

View File

@@ -0,0 +1,13 @@
{
"id": "admin_print_file",
"role": "admin",
"trigger_button": "🖨️ Imprimir",
"steps": [
{
"step_id": 0,
"variable": "UPLOAD_FILE",
"question": "Por favor, envíame el archivo que quieres imprimir.",
"input_type": "document"
}
]
}

View File

@@ -0,0 +1,31 @@
{
"id": "admin_project_management",
"role": "admin",
"trigger_button": "🏗️ Ver Proyectos",
"steps": [
{
"step_id": 0,
"variable": "PROJECT_SELECT",
"question": "Aquí está el tablero de ajedrez...",
"input_type": "dynamic_keyboard_vikunja_projects"
},
{
"step_id": 1,
"variable": "TASK_SELECT",
"question": "Has seleccionado el proyecto {project_name}. ¿Qué quieres hacer?",
"input_type": "dynamic_keyboard_vikunja_tasks"
},
{
"step_id": 2,
"variable": "ACTION_TYPE",
"question": "¿Cuál es la jugada?",
"options": ["🔄 Actualizar Estatus", "💬 Agregar Comentario"]
},
{
"step_id": 3,
"variable": "UPDATE_CONTENT",
"question": "Adelante. Soy todo oídos.",
"input_type": "text_or_audio"
}
]
}

View File

@@ -0,0 +1,25 @@
{
"id": "client_sales_funnel",
"role": "client",
"trigger_automatic": true,
"steps": [
{
"step_id": 0,
"variable": "CLIENT_NAME",
"question": "Hola. Soy Talia, la mano derecha de Armando. ✨Él está ocupado creando, pero yo soy la puerta de entrada. ¿Con quién tengo el gusto?",
"input_type": "text"
},
{
"step_id": 1,
"variable": "CLIENT_INDUSTRY",
"question": "Mucho gusto, {user_name}. Para entender mejor tus necesidades, ¿cuál es el giro de tu negocio o tu industria?",
"options": ["🍽️ Restaurantes", "🩺 Salud", "🛍️ Retail", "อื่น ๆ"]
},
{
"step_id": 2,
"variable": "IDEA_PITCH",
"question": "Excelente. Ahora, el escenario es tuyo. 🎤 Cuéntame sobre tu proyecto o la idea que tienes en mente. No te guardes nada. Puedes escribirlo o, si prefieres, enviarme una nota de voz.",
"input_type": "text_or_audio"
}
]
}

View File

@@ -0,0 +1,13 @@
{
"id": "crew_print_file",
"role": "crew",
"trigger_button": "🖨️ Imprimir",
"steps": [
{
"step_id": 0,
"variable": "UPLOAD_FILE",
"question": "Claro, envíame el archivo que necesitas imprimir y yo me encargo.",
"input_type": "document"
}
]
}

View File

@@ -0,0 +1,31 @@
{
"id": "crew_request_time",
"role": "crew",
"trigger_button": "📅 Solicitar Agenda",
"steps": [
{
"step_id": 0,
"variable": "REQUEST_TYPE",
"question": "Para usar la agenda del estudio, necesito que seas preciso.",
"options": ["🎥 Grabación", "🎙️ Locución", "🎬 Edición", "🛠️ Mantenimiento"]
},
{
"step_id": 1,
"variable": "REQUEST_DATE",
"question": "¿Para cuándo necesitas el espacio?",
"options": ["Hoy", "Mañana", "Esta Semana"]
},
{
"step_id": 2,
"variable": "REQUEST_TIME",
"question": "Dame el horario exacto que necesitas (ej. 'de 10am a 2pm').",
"input_type": "text"
},
{
"step_id": 3,
"variable": "REQUEST_JUSTIFICATION",
"question": "Entendido. Antes de confirmar, necesito que me expliques brevemente el plan o el motivo para justificar el bloqueo del espacio. Puedes escribirlo o enviarme un audio.",
"input_type": "text_or_audio"
}
]
}

View File

@@ -0,0 +1,37 @@
{
"id": "crew_secret_onboarding",
"role": "crew",
"trigger_command": "/abracadabra",
"steps": [
{
"step_id": 0,
"variable": "ONBOARD_START",
"question": "Vaya, vaya... Parece que conoces el comando secreto. 🎩. Antes de continuar, necesito saber tu nombre completo.",
"input_type": "text"
},
{
"step_id": 1,
"variable": "ONBOARD_ORIGIN",
"question": "Un placer, {user_name}. ¿Cuál es tu base de operaciones principal?",
"options": ["🏢 Office", "✨ Aura"]
},
{
"step_id": 2,
"variable": "ONBOARD_EMAIL",
"question": "Perfecto. Ahora necesito tu correo electrónico de la empresa.",
"input_type": "text"
},
{
"step_id": 3,
"variable": "ONBOARD_PHONE",
"question": "Y por último, tu número de teléfono.",
"input_type": "text"
},
{
"step_id": 4,
"variable": "ONBOARD_CONFIRM",
"question": "Gracias. He enviado una notificación al Administrador para que apruebe tu acceso. En cuanto lo haga, tendrás acceso completo. ¡Bienvenido a bordo!",
"options": ["✅ Entendido"]
}
]
}

View File

@@ -0,0 +1,22 @@
[
{
"service_name": "Web Development for Restaurants",
"description": "Custom websites and online ordering systems for restaurants, helping you reach more customers and streamline your operations.",
"keywords": ["restaurant", "food", "online ordering", "website", "restaurantes", "comida"]
},
{
"service_name": "Patient Management Systems for Healthcare",
"description": "A secure and efficient software solution for managing patient records, appointments, and billing in medical clinics.",
"keywords": ["healthcare", "medical", "patient", "clinic", "salud", "médico", "pacientes"]
},
{
"service_name": "Content Creation & Social Media Strategy",
"description": "Engaging content packages and social media management to build your brand's online presence and connect with your audience.",
"keywords": ["content creation", "social media", "marketing", "branding", "contenido", "redes sociales"]
},
{
"service_name": "General Business Consulting",
"description": "Strategic consulting to help you optimize business processes, identify growth opportunities, and improve overall performance.",
"keywords": ["business", "consulting", "strategy", "growth", "negocio", "consultoría"]
}
]