This workflow follows the Execute Workflow Trigger → 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": "Calidad de Lata \u2014 7b) Tool Consultar Evidencias",
"nodes": [
{
"id": "ewt-1",
"name": "Entrada de la tool",
"type": "n8n-nodes-base.executeWorkflowTrigger",
"typeVersion": 1.1,
"position": [
0,
0
],
"parameters": {
"inputSource": "workflowInputs",
"workflowInputs": {
"values": [
{
"name": "modo",
"type": "string"
},
{
"name": "dias_atras",
"type": "string"
},
{
"name": "linea",
"type": "string"
},
{
"name": "resultado",
"type": "string"
}
]
}
}
},
{
"id": "if-modo",
"name": "\u00bfModo resumen?",
"type": "n8n-nodes-base.if",
"typeVersion": 2.3,
"position": [
240,
0
],
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 3
},
"conditions": [
{
"id": "c1",
"leftValue": "={{ $json.modo }}",
"rightValue": "resumen",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"options": {}
}
},
{
"id": "pg-resumen",
"name": "Resumen por l\u00ednea",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.6,
"position": [
480,
-80
],
"alwaysOutputData": true,
"retryOnFail": true,
"maxTries": 2,
"parameters": {
"operation": "executeQuery",
"query": "SELECT linea, count(*) AS total, count(*) FILTER (WHERE resultado = 'OK') AS ok, count(*) FILTER (WHERE resultado = 'No OK') AS no_ok, count(*) FILTER (WHERE estado_resultado = 'revision_manual') AS revision_manual, count(*) FILTER (WHERE coherencia = false) AS incoherentes, round(avg(confianza)::numeric, 2) AS confianza_media, sum(tokens) AS tokens_totales FROM v_evidencias_completas WHERE capturado_en > now() - ($1 || ' days')::interval AND estado_ingesta <> 'duplicada' AND ($2 = '' OR linea = $2) GROUP BY linea ORDER BY linea;",
"options": {
"queryReplacement": "={{ [$json.dias_atras, $json.linea] }}"
}
},
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"id": "pg-detalle",
"name": "Detalle de evidencias",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.6,
"position": [
480,
100
],
"alwaysOutputData": true,
"retryOnFail": true,
"maxTries": 2,
"parameters": {
"operation": "executeQuery",
"query": "SELECT evidence_id, linea, equipo, capturado_en, tipo_foto, estado_resultado, resultado, confianza, revision_manual, calidad_impresion, coherencia, motivo, tokens FROM v_evidencias_completas WHERE capturado_en > now() - ($1 || ' days')::interval AND estado_ingesta <> 'duplicada' AND ($2 = '' OR linea = $2) AND ($3 = '' OR resultado = $3) ORDER BY capturado_en DESC LIMIT 30;",
"options": {
"queryReplacement": "={{ [$json.dias_atras, $json.linea, $json.resultado] }}"
}
},
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"id": "sticky-7b",
"name": "Nota-tool",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
0,
-220
],
"parameters": {
"content": "### 7b) Tool: Consultar evidencias\nSub-workflow usado como AI Tool por WF7 (Lupa). Inputs: modo ('resumen'|'detalle'), dias_atras, linea (opcional), resultado (opcional, solo detalle).\n\n'resumen' \u2192 totales por l\u00ednea (OK/No OK/revisi\u00f3n/incoherencias/confianza/tokens).\n'detalle' \u2192 hasta 30 evidencias individuales con motivo.\n\nLee de v_evidencias_completas (db/vistas-bi.sql), excluye duplicadas.\n\n\u26a0\ufe0f Debe estar ACTIVO (toggle ON): un sub-workflow inactivo no puede ser invocado por el Tool Workflow node del agente (falla silenciosa, 0 ejecuciones).\n\u26a0\ufe0f queryReplacement en formato ARRAY ({{ [a, b] }}), no comma-string \u2014 con par\u00e1metros vac\u00edos ('') el formato comma-string pierde el par\u00e1metro y Postgres tira 'no existe el par\u00e1metro $2'.",
"height": 260,
"width": 460,
"color": 4
}
}
],
"connections": {
"Entrada de la tool": {
"main": [
[
{
"node": "\u00bfModo resumen?",
"type": "main",
"index": 0
}
]
]
},
"\u00bfModo resumen?": {
"main": [
[
{
"node": "Resumen por l\u00ednea",
"type": "main",
"index": 0
}
],
[
{
"node": "Detalle de evidencias",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1",
"errorWorkflow": "I59vNrbU4KKGkHXF"
}
}
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
Calidad de Lata — 7b) Tool Consultar Evidencias. Uses executeWorkflowTrigger, postgres. Event-driven trigger; 5 nodes.
Source: https://github.com/aiporvos/sudamericanabebidas/blob/main/workflows/calidad-lata-7b-tool-evidencias.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.
Feedback Collection and Training Data. Uses executeWorkflowTrigger, postgres, httpRequest. Event-driven trigger; 4 nodes.
Interaction Logging Workflow. Uses executeWorkflowTrigger, postgres. Event-driven trigger; 3 nodes.
Stage C. Uses executeWorkflowTrigger, postgres. Event-driven trigger; 3 nodes.
Handoff_data. Uses executeWorkflowTrigger, postgres. Event-driven trigger; 2 nodes.
00-shared: Log Event. Uses executeWorkflowTrigger, postgres. Event-driven trigger; 2 nodes.