Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/JuanSebasSV/healtyhelp/llms.txt

Use this file to discover all available pages before exploring further.

The Chat API powers NutriBot, HealtyHelp’s conversational nutrition assistant. NutriBot uses Groq LLaMA 3.3 70B (llama-3.3-70b-versatile) and personalises every response with the authenticated user’s health profile, allergies, dietary preferences, and the filtered recipe catalogue. All routes require a valid Bearer token in the Authorization header.

POST /api/chat

Sends a message to NutriBot and receives a reply. The conversation history (up to the last 10 messages) can be provided to maintain context across turns. Request body
message
string
required
The user’s message text. Cannot be empty.
history
array
Optional array of previous conversation turns. Maximum of 10 entries are used (older entries are silently discarded). Each entry must begin with a user message — any leading model entries are removed before the request is forwarded to Groq.
[
  { "role": "user",  "text": "Qué puedo desayunar hoy?" },
  { "role": "model", "text": "Te recomiendo avena con fresas..." }
]
The history array uses "model" for the assistant role. Internally, the API maps "model""assistant" when building the Groq request, because the Groq API follows the OpenAI message role convention.
How personalisation works Before calling Groq, the server:
  1. Loads the user’s healthProfile (condiciones, categorias, alergias, preferencias) and legacy alergia field.
  2. Filters the recipe catalogue to those matching healthProfile.categorias (or the full catalogue if none are set).
  3. Removes recipes whose ingredientes contain any of the user’s allergies.
  4. Injects the filtered recipe list, the user’s profile, and a behaviour directive into a system prompt that also includes the active NutriBot prompt from AIConfig.
Response 200 OK
{
  "reply": "¡Hola, María! Para tu desayuno con diabetes te sugiero la Avena Integral (320 kcal) con índice glucémico bajo..."
}
Error responses
StatusBodyCondition
400{ "error": "El mensaje es requerido" }message field is missing or empty
429{ "error": "rate_limit", "reply": "Estoy recibiendo muchas consultas..." }Groq quota exceeded or upstream 429/503
500{ "error": "Error al procesar tu mensaje" }Unexpected server-side error
curl -X POST https://api.healtyhelp.com/api/chat \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "Qué puedo cenar hoy con diabetes?"
  }'

GET /api/chat/filtros

Returns the full health profile used to personalise chat responses, including allergies and preferences (unlike GET /api/recomendaciones/filtros, which intentionally omits those fields). Response 200 OK
{
  "condiciones":  ["diabetes", "hipertension"],
  "categorias":   ["almuerzo", "cena"],
  "alergias":     ["maní", "mariscos"],
  "preferencias": ["alto en proteína"]
}
FieldTypeDescription
condicionesstring[]Active health conditions; drive both chat and recommendations
categoriasstring[]Meal category filters; restrict the recipe catalogue shown to NutriBot
alergiasstring[]Allergen strings; recipes containing matching ingredients are filtered out before the chat call
preferenciasstring[]Free-form dietary preferences; surfaced to NutriBot in the system prompt for context only
curl https://api.healtyhelp.com/api/chat/filtros \
  -H "Authorization: Bearer <token>"

PUT /api/chat/health-profile

Updates the authenticated user’s health profile. All fields are optional arrays — omit any field to leave it unchanged. Request body
condiciones
string[]
Replace the user’s active health condition identifiers. See the Recommendations API for the full list of recognised values.
categorias
string[]
Replace the active meal category filters used to narrow the recipe catalogue (e.g. ["desayuno", "almuerzo"]).
alergias
string[]
Replace the user’s allergen list. Ingredient matching is case-insensitive substring search.
preferencias
string[]
Replace the user’s free-form dietary preferences (e.g. ["alto en proteína", "sin gluten"]).
Response 200 OK
{
  "message": "Perfil actualizado",
  "healthProfile": {
    "condiciones":  ["diabetes"],
    "categorias":   ["almuerzo"],
    "alergias":     ["maní"],
    "preferencias": []
  }
}
curl -X PUT https://api.healtyhelp.com/api/chat/health-profile \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "condiciones": ["diabetes", "hipertension"],
    "alergias": ["maní"]
  }'

GET /api/chat/prompt

Returns the current NutriBot system prompt stored in AIConfig. This is the base behaviour directive injected at the start of every chat completion. Response 200 OK
{
  "prompt": "Eres NutriBot, el asistente de nutrición de HealtyHelp..."
}
The prompt is cached in memory for up to 60 seconds. Changes made via PUT /api/chat/prompt take effect immediately (cache is invalidated on save), but concurrent server instances may serve the old prompt for up to one minute.
curl https://api.healtyhelp.com/api/chat/prompt \
  -H "Authorization: Bearer <token>"

PUT /api/chat/prompt

Replaces the NutriBot system prompt. All authenticated users can call this endpoint; restrict access to admin roles at the application level. Request body
prompt
string
required
New system prompt text. Must be a non-empty string.
Response 200 OK
{
  "message": "Prompt actualizado",
  "prompt": "Eres NutriBot, el asistente de nutrición de HealtyHelp..."
}
Error responses
StatusCondition
400prompt is missing, not a string, or blank
500Database write error
curl -X PUT https://api.healtyhelp.com/api/chat/prompt \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Eres NutriBot, asistente de nutrición de HealtyHelp. Responde siempre en español..."
  }'

Build docs developers (and LLMs) love