Kaffi is the CoffePrice AI assistant, powered by OpenAI’sDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/JaiderT/CoffeePrice/llms.txt
Use this file to discover all available pages before exploring further.
gpt-4o-mini model. It helps coffee producers and buyers navigate the platform, interpret price predictions, understand alerts, and make better selling decisions — all in plain, friendly Spanish.
The chatbot accepts a message history array so multi-turn conversations are supported. Before forwarding to OpenAI, the controller builds a detailed system prompt that grounds Kaffi in the CoffePrice context, applies an off-topic filter (blocking requests about unrelated subjects like history or sports), and detects offensive language. Certain high-frequency queries (e.g. “who pays the best price today?”) are answered with pre-built guided responses, bypassing the OpenAI call entirely for lower latency.
Endpoint: POST /api/chatbot
Auth: None (public)
Rate limiting: This endpoint is rate-limited. Exceeding the limit returns 429 Too Many Requests.
Request body
An array of message objects following the OpenAI chat format. Each object must have a
role ("user" or "assistant") and a content string. The last element in the array is treated as the current user message. Minimum one element required.Optional client-side context object. When provided, the controller serialises it into a secondary system message sent to OpenAI, enabling more relevant, page-aware responses. Useful sub-fields:
pagina— current route string (e.g."/precios","/alertas","/predicciones")datosPagina.resumenPrecios— object withmejorPrecio,mejorComprador,precioFNC,diferenciaVsFNCdatosPagina.prediccionResumen— object withprecioEstimado,tendencia,confianzadatosPagina.historialPredicciones— object withdiasConsultados,promedio,minimo,maximo,confianzaPromedio
Response fields
Kaffi’s plain-text reply, always in Spanish and capped at 3 short paragraphs (approximately 420 tokens).
Up to 3 suggested follow-up questions based on the current page context and the content of the user’s message. Intended for display as quick-reply chips in the chat UI.
Example
200 OK
400 Bad Request — If mensajes is missing or not an array.
500 Internal Server Error — If OPENAI_API_KEY is not configured or the OpenAI API returns an error.
Off-topic and content moderation
The controller applies two automatic filters before reaching the OpenAI API:- Off-topic filter: If the user’s message matches keywords unrelated to coffee, prices, or the platform (e.g. “segunda guerra mundial”, “futbol”, “javascript”) and contains no coffee or platform keywords, Kaffi returns a polite redirect response without consuming an OpenAI API call.
- Offensive language filter: A list of patterns detects offensive text. Kaffi responds respectfully, sets a boundary, and redirects to platform help.
POST /api/contacto
Sends a contact form email to the CoffePrice support address via Gmail/Nodemailer. The email is delivered to theEMAIL_USER environment variable address, with replyTo set to the sender’s email so support staff can reply directly.
Auth: None (public)
Rate limiting: Protected by contactLimiter middleware. Exceeding the limit returns 429 Too Many Requests.
Request body
Full name of the sender. Maximum 120 characters.
Sender’s email address. Must pass the regex
/^[^\s@]+@[^\s@]+\.[^\s@]+$/. Used as the replyTo address in the outgoing email.Email subject line. Optional. Maximum 180 characters. Newline characters are stripped automatically.
The message body. Maximum 4000 characters. All user-supplied content is HTML-escaped before being included in the email.
200 OK
400 Bad Request — If required fields are missing, the email format is invalid, or a field exceeds its length limit.
500 Internal Server Error — If Nodemailer fails to deliver the email (e.g. invalid EMAIL_USER/EMAIL_PASS credentials, Gmail quota exceeded).
Required environment variables
| Variable | Description |
|---|---|
EMAIL_USER | Gmail address used as both the sender and the recipient for contact form submissions. |
EMAIL_PASS | Gmail app password (not your account password). Generate one under your Google account’s security settings. |