This workflow follows the Emailsend → Postgres recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"name": "Triaje - Reporte Diario (Postgres Directo)",
"nodes": [
{
"parameters": {
"rule": {
"interval": [
{
"field": "cronExpression",
"expression": "0 8 * * *"
}
]
}
},
"id": "cron-8am",
"name": "Cron 8:00 AM",
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.1,
"position": [
200,
300
]
},
{
"parameters": {
"operation": "executeQuery",
"query": "SELECT \n COUNT(*) as total_triages,\n COUNT(*) FILTER (WHERE urgency_level = 'critico') as critical_count,\n COUNT(*) FILTER (WHERE urgency_level = 'alto') as high_count,\n COUNT(*) FILTER (WHERE urgency_level = 'moderado') as moderate_count,\n COUNT(*) FILTER (WHERE urgency_level = 'bajo') as low_count\nFROM triages \nWHERE created_at >= CURRENT_DATE - INTERVAL '1 day' \n AND created_at < CURRENT_DATE;"
},
"id": "query-postgres",
"name": "Consultar Postgres",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.2,
"position": [
400,
300
],
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"jsCode": "const stats = $input.first().json;\nconst yesterday = new Date();\nyesterday.setDate(yesterday.getDate() - 1);\nconst dateStr = yesterday.toLocaleDateString('es-PE', { weekday:'long', year:'numeric', month:'long', day:'numeric' });\n\nconst total = parseInt(stats.total_triages) || 0;\n\nconst dist = {\n critico: parseInt(stats.critical_count) || 0,\n alto: parseInt(stats.high_count) || 0,\n moderado: parseInt(stats.moderate_count) || 0,\n bajo: parseInt(stats.low_count) || 0\n};\n\nconst urgencyRows = Object.entries(dist).map(([level, count]) => {\n const pct = total > 0 ? ((count / total) * 100).toFixed(1) : '0.0';\n const icons = { critico:'\ud83d\udd34', alto:'\ud83d\udfe0', moderado:'\ud83d\udfe1', bajo:'\ud83d\udfe2' };\n return `<tr><td style='padding:8px 12px;border-bottom:1px solid #eee'>${icons[level] || ''} ${level.charAt(0).toUpperCase() + level.slice(1)}</td><td style='padding:8px 12px;border-bottom:1px solid #eee;text-align:center'>${count}</td><td style='padding:8px 12px;border-bottom:1px solid #eee;text-align:center'>${pct}%</td></tr>`;\n}).join('');\n\nconst html = `<!DOCTYPE html><html><body style='font-family:Arial,sans-serif;background:#f5f7fa;padding:20px'>\n<div style='max-width:650px;margin:0 auto;background:white;border-radius:12px;overflow:hidden;box-shadow:0 4px 20px rgba(0,0,0,0.08)'>\n<div style='background:linear-gradient(135deg,#0F4C81,#00A86B);padding:28px;color:white;text-align:center'>\n <div style='font-size:40px;margin-bottom:8px'>\u2695</div>\n <h1 style='margin:0;font-size:22px;letter-spacing:2px'>REPORTE DIARIO</h1>\n <p style='margin:6px 0 0;opacity:0.85;text-transform:capitalize'>${dateStr}</p>\n</div>\n<div style='padding:28px'>\n <div style='display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-bottom:24px'>\n <div style='background:#f0fdf4;border:1px solid #bbf7d0;border-radius:8px;padding:16px;text-align:center'>\n <div style='font-size:32px;font-weight:700;color:#16a34a'>${total}</div>\n <div style='color:#15803d;font-size:12px;font-weight:600'>Triajes Totales</div>\n </div>\n <div style='background:#fef2f2;border:1px solid #fecaca;border-radius:8px;padding:16px;text-align:center'>\n <div style='font-size:32px;font-weight:700;color:#dc2626'>${dist.critico}</div>\n <div style='color:#b91c1c;font-size:12px;font-weight:600'>Casos Cr\u00edticos</div>\n </div>\n </div>\n \n <h3 style='color:#334155;font-size:16px;margin-bottom:12px;border-bottom:2px solid #f1f5f9;padding-bottom:8px'>Distribuci\u00f3n por Urgencia</h3>\n <table style='width:100%;border-collapse:collapse;margin-bottom:24px'>\n <thead><tr style='background:#f8fafc'><th style='padding:10px;text-align:left;color:#64748b;font-size:12px'>Nivel</th><th style='padding:10px;text-align:center;color:#64748b;font-size:12px'>Cantidad</th><th style='padding:10px;text-align:center;color:#64748b;font-size:12px'>%</th></tr></thead>\n <tbody>${urgencyRows}</tbody>\n </table>\n</div>\n<div style='background:#f8fafc;padding:20px;text-align:center;color:#94a3b8;font-size:12px'>\n Sistema de Triaje Cl\u00ednico IA - Generado autom\u00e1ticamente\n</div>\n</div></body></html>`;\n\nreturn { html, date: dateStr };"
},
"id": "build-email",
"name": "Construir Email",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
600,
300
]
},
{
"parameters": {
"fromEmail": "thutato09.2003@gmail.com",
"toEmail": "salopezma@unitru.edu.pe,gdrojasvi@unitru.edu.pe,requezadaro@unitru.edu.pe,dalucanoni@unitru.edu.pe",
"subject": "\ud83d\udcca Reporte Diario Triaje IA - {{ $json.date }}",
"emailType": "html",
"message": "={{ $json.html }}",
"options": {}
},
"id": "send-daily",
"name": "Enviar Reporte Diario",
"type": "n8n-nodes-base.emailSend",
"typeVersion": 2,
"position": [
800,
300
]
}
],
"connections": {
"Cron 8:00 AM": {
"main": [
[
{
"node": "Consultar Postgres",
"type": "main",
"index": 0
}
]
]
},
"Consultar Postgres": {
"main": [
[
{
"node": "Construir Email",
"type": "main",
"index": 0
}
]
]
},
"Construir Email": {
"main": [
[
{
"node": "Enviar Reporte Diario",
"type": "main",
"index": 0
}
]
]
}
},
"active": true,
"settings": {
"executionOrder": "v1"
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
postgres
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Triaje - Reporte Diario (Postgres Directo). Uses postgres, emailSend. Scheduled trigger; 4 nodes.
Source: https://github.com/tato09salm/triajeia/blob/44a5a776174c369bcf19a2f5f1adc0f4f21a84b2/n8n-workflows/03_reporte_diario.json — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
Disparador 1.8. Uses itemLists, postgres, emailSend, httpRequest. Scheduled trigger; 85 nodes.
This n8n workflow runs daily to analyze active customer behavior, engineers relevant features from usage and transaction data, applies a machine learning or AI-based model to predict churn probability
This n8n workflow automates continuous compliance monitoring across IT, OT, and cloud environments by aggregating security controls, validating policies (ISO 27001, NIST, GDPR, SOC2), detecting anomal
Automates real-time market monitoring, technical analysis, AI-powered signal generation for cryptocurrencies (and stocks), filters high-confidence trades, and delivers actionable alerts via multiple c
Scheduled processes retrieve customer feedback from multiple channels. The system performs sentiment analysis to classify tone, then uses OpenAI models to extract themes, topics, and urgency indicator