Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/KevinhosUTP/Automatizacion-Lurwis/llms.txt

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

Environment Variables

Comprehensive guide to all environment variables required for Automatización Lurwis.

n8n Core Configuration

Basic Settings

# Authentication
N8N_BASIC_AUTH_ACTIVE=true
N8N_BASIC_AUTH_USER=admin
N8N_BASIC_AUTH_PASSWORD=your-secure-password

# Host Configuration
N8N_HOST=your-domain.com
N8N_PORT=5678
N8N_PROTOCOL=https
WEBHOOK_URL=https://your-domain.com

# Execution Mode
EXECUTIONS_PROCESS=main
Security Critical: Never use default passwords in production. Use a password manager to generate strong credentials.

Advanced Settings

# Execution History
EXECUTIONS_DATA_SAVE_ON_ERROR=all
EXECUTIONS_DATA_SAVE_ON_SUCCESS=all
EXECUTIONS_DATA_PRUNE=true
EXECUTIONS_DATA_MAX_AGE=336  # 14 days in hours

# Performance
N8N_CONCURRENCY=10
NODE_OPTIONS=--max-old-space-size=4096

# Monitoring
N8N_METRICS=true
N8N_LOG_LEVEL=info

WhatsApp Business API

Meta Platform Credentials

# WhatsApp Business Account
WHATSAPP_API_TOKEN=your-meta-access-token
WHATSAPP_PHONE_NUMBER_ID=947279508470714
WHATSAPP_BUSINESS_ACCOUNT_ID=746650594705809

# Webhook Configuration
WHATSAPP_WEBHOOK_VERIFY_TOKEN=meta-verify
WHATSAPP_WEBHOOK_PATH=/webhook/meta-verify

How to Obtain Credentials

1

Access Meta Developer Console

  1. Go to Meta for Developers
  2. Navigate to your WhatsApp Business App
2

Get Access Token

  • Go to WhatsAppAPI Setup
  • Copy the temporary access token
  • For production: Generate a permanent token
3

Get Phone Number ID

  • In API Setup, find your test phone number
  • Copy the Phone number ID (visible in workflow: 947279508470714)
4

Configure Webhook

  • Go to WhatsAppConfiguration
  • Callback URL: https://your-domain.com/webhook/meta-verify
  • Verify Token: meta-verify
  • Subscribe to: messages field
The webhook must return a 200 status with the hub.challenge parameter for Meta verification to succeed.

Database Connections

PostgreSQL (Orders & Menu)

# Connection Details
POSTGRES_HOST=your-postgres-host.com
POSTGRES_PORT=5432
POSTGRES_DB=picanteria_db
POSTGRES_USER=lurwis_user
POSTGRES_PASSWORD=your-secure-password
POSTGRES_SSL=true

# Session Pooler (Recommended)
POSTGRES_CONNECTION_STRING=postgresql://lurwis_user:password@host:5432/picanteria_db?sslmode=require
The workflows use a session pooler connection with Row Level Security (RLS) enabled as noted in the workflow comments.

Tables Used by Workflows

The PostgreSQL database includes:
  • pedidos_picanteria - Customer orders
  • categorias - Menu categories
  • platos - Menu items
  • plato_precios - Item pricing by size

MongoDB (Conversation Memory)

# Connection String
MONGODB_CONNECTION_STRING=mongodb+srv://user:password@cluster.mongodb.net/
MONGODB_DATABASE=picanteria_db

# Authentication
MONGODB_USER=lurwis_user
MONGODB_PASSWORD=your-secure-password

Memory Collections

The system uses separate MongoDB collections for each conversation context:
CollectionPurposeContext Window
historial_clasificadorMessage intent classificationDefault
historial_detectorOrder detectionDefault
historial_pedidosOrder conversations25 messages
historial_eventosVenue event bookings15 messages
historial_reservasTable reservations15 messages
historial_generalGeneral inquiries10 messages
Each agent has its own collection to maintain precise conversation context and enable accurate metrics.

Redis (Message Buffer)

Connection Settings

REDIS_HOST=your-redis-host.com
REDIS_PORT=6379
REDIS_PASSWORD=your-redis-password
REDIS_DB=0

# Optional: TLS for production
REDIS_TLS=true

Buffer Configuration

The Receptor workflow uses Redis for message buffering:
  • Purpose: Aggregate rapid messages into a single context
  • Buffer Window: 8 seconds (configurable)
  • TTL Values:
    • buffer_{userId}: 30 seconds
    • ts_{userId}: 30 seconds (timestamp)
    • meta_{userId}: 120 seconds (metadata)
Redis is critical for preventing message fragmentation. Ensure it’s highly available in production.

AI & Language Models

Google Gemini

# API Configuration
GOOGLE_GEMINI_API_KEY=your-gemini-api-key
GOOGLE_GEMINI_MODEL=gemini-1.5-flash  # Fast classification
GOOGLE_GEMINI_MODEL_PRO=gemini-1.5-pro  # Order processing

How to Get Gemini API Key

1

Access Google AI Studio

2

Create API Key

  1. Click Create API Key
  2. Select or create a Google Cloud project
  3. Copy the generated key
3

Configure billing

  • Free tier: 60 requests/minute
  • Production: Enable billing for higher limits

Agent Models

The Procesador workflow uses different models for different agents:
  • Clasificador (Classifier): Fast model for intent detection
  • Agente Pedidos (Orders): Pro model with reasoning capability
  • Other Agents: Fast models (General, Reservations, Events)

Optional Services

Error Notifications

# Personal WhatsApp for error alerts
ERROR_NOTIFICATION_PHONE=51900769907  # From workflow pinData
ERROR_NOTIFICATION_ENABLED=true
The workflows mention an error workflow connected to a personal WhatsApp for real-time error monitoring.

Monitoring & Logging

# Application Monitoring
N8N_METRICS=true
N8N_METRICS_INCLUDE_DEFAULT_METRICS=true
N8N_METRICS_INCLUDE_WORKFLOW_ID_LABEL=true

# External Monitoring (Optional)
SENTRY_DSN=your-sentry-dsn
DATADOG_API_KEY=your-datadog-key

Environment-Specific Configurations

Development

# .env.development
N8N_HOST=localhost
N8N_PROTOCOL=http
N8N_PORT=5678
WEBHOOK_URL=http://localhost:5678
N8N_LOG_LEVEL=debug
EXECUTIONS_DATA_SAVE_ON_SUCCESS=none

Staging

# .env.staging
N8N_HOST=staging.your-domain.com
N8N_PROTOCOL=https
N8N_PORT=5678
WEBHOOK_URL=https://staging.your-domain.com
N8N_LOG_LEVEL=info

Production

# .env.production
N8N_HOST=your-domain.com
N8N_PROTOCOL=https
N8N_PORT=5678
WEBHOOK_URL=https://your-domain.com
N8N_LOG_LEVEL=warn
EXECUTIONS_DATA_SAVE_ON_ERROR=all
N8N_METRICS=true

# Production Security
POSTGRES_SSL=true
REDIS_TLS=true
N8N_BASIC_AUTH_ACTIVE=true

Environment File Template

Create a .env file with all required variables:
# ===========================
# n8n Configuration
# ===========================
N8N_BASIC_AUTH_ACTIVE=true
N8N_BASIC_AUTH_USER=
N8N_BASIC_AUTH_PASSWORD=
N8N_HOST=
N8N_PROTOCOL=https
WEBHOOK_URL=

# ===========================
# WhatsApp Business API
# ===========================
WHATSAPP_API_TOKEN=
WHATSAPP_PHONE_NUMBER_ID=
WHATSAPP_WEBHOOK_VERIFY_TOKEN=meta-verify

# ===========================
# PostgreSQL Database
# ===========================
POSTGRES_CONNECTION_STRING=
POSTGRES_SSL=true

# ===========================
# MongoDB Memory
# ===========================
MONGODB_CONNECTION_STRING=
MONGODB_DATABASE=picanteria_db

# ===========================
# Redis Buffer
# ===========================
REDIS_HOST=
REDIS_PORT=6379
REDIS_PASSWORD=
REDIS_TLS=true

# ===========================
# Google Gemini AI
# ===========================
GOOGLE_GEMINI_API_KEY=

# ===========================
# Monitoring (Optional)
# ===========================
N8N_METRICS=true
ERROR_NOTIFICATION_PHONE=
Copy this template to .env and fill in all values. Never commit .env to version control.

Credential Security Best Practices

Separate credentials for development, staging, and production:
.env.development
.env.staging
.env.production
  • API tokens: Every 90 days
  • Database passwords: Every 6 months
  • Webhook tokens: After any security incident
For production, consider:
  • AWS Secrets Manager
  • HashiCorp Vault
  • Azure Key Vault
  • Google Cloud Secret Manager
  • Use read-only database credentials where possible
  • Apply least-privilege principle
  • Enable RLS (Row Level Security) on PostgreSQL

Verification Checklist

Before deploying, verify all credentials:
  • n8n authentication configured
  • WhatsApp webhook verified with Meta
  • PostgreSQL connection successful
  • MongoDB collections created
  • Redis connection active
  • Google Gemini API key valid
  • All environment-specific values set
  • SSL/TLS enabled for production databases
  • Backup credentials stored securely

Next Steps

Production Deployment

Deploy to production with security best practices

Database Schema

Review complete database structure

Troubleshooting

Debug common credential issues

WhatsApp Integration

Detailed WhatsApp setup guide

Build docs developers (and LLMs) love