feat: add find_customer_by_identifier tool and customer state fields

- Add find_customer_by_identifier tool to NaliiaTools
- Add customer_name and customer_id to MessagesState schema
- Update NALIIA_PROMPT template with new tools
- Integrate customer lookup in chat webhook using phone number
This commit is contained in:
2026-03-11 00:02:56 -05:00
parent 4669ae2289
commit 5de87b7c8f
4 changed files with 59 additions and 0 deletions

View File

@@ -27,6 +27,7 @@ class NaliiaTools:
self.schedule_appointment,
self.find_service_centers,
self.find_products_and_services,
self.find_customer_by_identifier,
]
@tool
@@ -72,6 +73,32 @@ class NaliiaTools:
return today_date_formated
@tool
def find_customer_by_identifier(identifier: str) -> str:
"""
Busca un cliente por su identificador (teléfono, email o número de documento).
Args:
identifier: Identificador del cliente (teléfono, email o número de documento).
Returns:
str: JSON con la información del cliente encontrado.
Estructura: {"id": int, "name": str, "phone": str, "email": str}
Ejemplo: '{"id": 1, "name": "Juan Perez", "phone": "573001234567", "email": "juan@example.com"}'
Retorna "{}" si no se encuentra el cliente.
"""
async def call_tool():
async with _MCP_CLIENT:
result = await _MCP_CLIENT.call_tool(
"find_customer_by_identifier", {"identifier": identifier}
)
logger.info(result.content[0].text)
return result
result = asyncio.run(call_tool())
return result.content[0].text
@tool
def find_service_centers():
"""