Documentation Index
Fetch the complete documentation index at: https://mintlify.com/AdriP-maker/JAAR_Antigravity/llms.txt
Use this file to discover all available pages before exploring further.
aiService assists collectors (cobradores) by generating context-aware, empathic collection messages tailored to each resident’s payment behavior profile. The service first tries to use Chrome’s Built-in AI (window.ai), then automatically falls back to handcrafted template messages when the API is unavailable — ensuring the feature works fully offline.
Cash only. Per board policy, SIMAP Digital only accepts in-person cash payments. The AI prompt explicitly instructs the language model never to suggest digital payment methods such as Yappy, bank transfers, or deposits.
Behavior profiles
Before generating a message, the service internally calls the privateanalizarComportamiento(userId) function, which calls getResumenUsuario from pagosService and classifies the resident into one of three profiles:
| Profile | Condition | Message tone |
|---|---|---|
'puntual' | resumen.deuda === 0 | Warm thank-you message. |
'olvidadizo' | resumen.mesesDeuda === 1 | Friendly WhatsApp-style reminder. |
'moroso' | resumen.mesesDeuda >= 2 | Firm but empathic message offering a payment plan or a visit to the board. |
getSugerenciaCobrador(usuarioTarget)
Generates a suggested collection message for a resident. Internally:
- Calls
analizarComportamiento(usuarioTarget.id)to determine the resident’s behavior profile. - Calls
getResumenUsuario(usuarioTarget.id)to retrieve debt figures. - Builds a structured prompt and submits it to
window.ai.createTextSession()if the Chrome Built-in AI API is available. - If
window.aiis absent, returns a pre-built template message based on the profile.
A resident object. Typically sourced from the
usuarios Dexie table or the DEMO_USERS constant.Resident ID — passed to
pagosService functions to look up payment history.Resident’s display name (e.g.,
'Los Alonsos'). Injected directly into the AI prompt and fallback templates.Resident’s sector or neighborhood (e.g.,
'Caballero Abajo'). Included in the prompt for geographic context.true if the message was generated successfully (either by the AI or the fallback template). false only if an unexpected exception occurs.The generated collection message ready to copy into WhatsApp or read aloud. On error, returns
'No se pudo conectar con el motor de IA.'.Prompt template
Whenwindow.ai is available, the following prompt is sent to the language model. The values in ${} are interpolated at runtime:
Fallback template messages
Whenwindow.ai is unavailable (e.g., non-Chrome browser, offline with no cached model), the service returns one of two static templates:
For 'puntual' residents:
¡Hola [nombre]! Gracias por estar al día. Tu buen comportamiento nos ayuda a mantener el agua fluyendo.For
'olvidadizo' or 'moroso' residents:
Hola [nombre], soy de la Junta de Agua. Vemos un saldo pendiente de B/. [deuda]. Recuerda que el pago solo se realiza en efectivo con nuestro cobrador o en la junta. ¡Saludos!
Usage example
Error handling
If an unexpected exception is thrown during profile analysis or the AI session, the function catches it internally and returns a safe error state rather than propagating the exception:Future versions may route the prompt to OpenAI using a
VITE_OPENAI_API_KEY environment variable, as noted in the source. The fallback structure is already in place to support this seamlessly.