This workflow follows the Gmail → Google Sheets 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": "pedidosProductos",
"nodes": [
{
"parameters": {
"operation": "executeQuery",
"query": "SELECT\n p.id_pedido,\n c.nombre AS cliente,\n c.tipo_documento,\n c.documento,\n c.email,\n c.telefono,\n c.direccion,\n TO_CHAR(p.fecha, 'DD-MM-YYYY') AS fechaPedido,\n TO_CHAR(p.fechaprocesado, 'DD-MM-YYYY') AS fechaProcesado,\n p.id_estado,\n e.nombre_estado,\n mp.id_metodo_pago,\n mp.nombre_metodo AS metodo_pago,\n mp.descripcion AS descripcion_metodo_pago,\n pr.nombre AS producto,\n dp.cantidad,\n dp.precio_unitario,\n (dp.cantidad * dp.precio_unitario) AS subtotal\nFROM pedidos p\n JOIN clientes c ON p.id_cliente = c.id_cliente\n JOIN detalle_pedidos dp ON p.id_pedido = dp.id_pedido\n JOIN productos pr ON dp.id_producto = pr.id_producto\n JOIN estados_pedidos e ON p.id_estado = e.id_estado\n LEFT JOIN metodos_pago mp ON p.id_metodo_pago = mp.id_metodo_pago\nWHERE DATE(p.fecha) = CURRENT_DATE;\n\n-- 1,pendiente\n-- 2,procesando\n-- 3,enviado\n-- 4,entregado\n-- 5,cancelado",
"options": {}
},
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.6,
"position": [
-2928,
-512
],
"id": "b4f63d99-2bd0-4295-9213-761ebae7a02e",
"name": "estadosPediidosHoy",
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"rules": {
"values": [
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 3
},
"conditions": [
{
"leftValue": "={{ $json.id_estado }}",
"rightValue": 1,
"operator": {
"type": "number",
"operation": "equals"
},
"id": "efc7add4-19b7-420c-bd59-395c167b4d4d"
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "pendiente"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 3
},
"conditions": [
{
"id": "a0385715-6b57-49cb-8a1d-5c784480275f",
"leftValue": "={{ $json.id_estado }}",
"rightValue": 2,
"operator": {
"type": "number",
"operation": "equals"
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "procesando"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 3
},
"conditions": [
{
"id": "f9afa493-677a-4371-9155-18c2ae7742ed",
"leftValue": "={{ $json.id_estado }}",
"rightValue": 3,
"operator": {
"type": "number",
"operation": "equals"
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "enviado"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 3
},
"conditions": [
{
"id": "f216e669-767f-45e1-8a12-e2a3812899ce",
"leftValue": "={{ $json.id_estado }}",
"rightValue": 4,
"operator": {
"type": "number",
"operation": "equals"
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "entregado"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 3
},
"conditions": [
{
"id": "b4e7f808-a69b-4df5-a425-4908225fffa0",
"leftValue": "={{ $json.id_estado }}",
"rightValue": 5,
"operator": {
"type": "number",
"operation": "equals"
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "cancelado"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.switch",
"typeVersion": 3.4,
"position": [
-2528,
-576
],
"id": "d3e1b6f2-f1cf-45f3-822f-782364d9b956",
"name": "Switch"
},
{
"parameters": {
"operation": "appendOrUpdate",
"documentId": {
"__rl": true,
"value": "1pAphNQMC9sf1xi4_c_-LnE1ai2YU4l_kkDEZyyYe1FI",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": "gid=0",
"mode": "list",
"cachedResultName": "PENDIENTE",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pAphNQMC9sf1xi4_c_-LnE1ai2YU4l_kkDEZyyYe1FI/edit#gid=0"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"IDPEDIDOS": "={{ $('estadosPediidosHoy').item.json.id_pedido }}",
"CLIENTE": "={{ $('estadosPediidosHoy').item.json.cliente }}",
"EMAIL": "={{ $('estadosPediidosHoy').item.json.email }}",
"TELEFONO": "={{ $('estadosPediidosHoy').item.json.telefono }}",
"DIRECCION": "={{ $('estadosPediidosHoy').item.json.direccion }}",
"TIPODOC": "={{ $('estadosPediidosHoy').item.json.tipo_documento }}",
"DOCUMENTO": "={{ $('estadosPediidosHoy').item.json.documento }}",
"FECHA": "={{ $('estadosPediidosHoy').item.json.fechapedido }}",
"FECHAPROCESADO": "={{ $('estadosPediidosHoy').item.json.fechaprocesado }}",
"ESTADO": "={{ $('estadosPediidosHoy').item.json.nombre_estado }}",
"PRODUCTO": "={{ $('estadosPediidosHoy').item.json.producto }}",
"CANTIDAD": "={{ $('estadosPediidosHoy').item.json.cantidad }}",
"PRECIO": "={{ $('estadosPediidosHoy').item.json.precio_unitario }}",
"SUBTOTAL": "={{ $('estadosPediidosHoy').item.json.subtotal }}",
"METODO_PAGO": "={{ $json.metodo_pago }}"
},
"matchingColumns": [
"IDPEDIDOS"
],
"schema": [
{
"id": "IDPEDIDOS",
"displayName": "IDPEDIDOS",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "CLIENTE",
"displayName": "CLIENTE",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "EMAIL",
"displayName": "EMAIL",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "TELEFONO",
"displayName": "TELEFONO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "DIRECCION",
"displayName": "DIRECCION",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "TIPODOC",
"displayName": "TIPODOC",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "DOCUMENTO",
"displayName": "DOCUMENTO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "FECHA",
"displayName": "FECHA",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "FECHAPROCESADO",
"displayName": "FECHAPROCESADO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "ESTADO",
"displayName": "ESTADO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "METODO_PAGO",
"displayName": "METODO_PAGO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "PRODUCTO",
"displayName": "PRODUCTO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "CANTIDAD",
"displayName": "CANTIDAD",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "PRECIO",
"displayName": "PRECIO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "SUBTOTAL",
"displayName": "SUBTOTAL",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.7,
"position": [
-2208,
-736
],
"id": "967a0871-f244-4f72-9993-81e9024be158",
"name": "PENDIENTES",
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "appendOrUpdate",
"documentId": {
"__rl": true,
"value": "1pAphNQMC9sf1xi4_c_-LnE1ai2YU4l_kkDEZyyYe1FI",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": 1146715740,
"mode": "list",
"cachedResultName": "PROCESADOS",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pAphNQMC9sf1xi4_c_-LnE1ai2YU4l_kkDEZyyYe1FI/edit#gid=1146715740"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"IDPEDIDOS": "={{ $('estadosPediidosHoy').item.json.id_pedido }}",
"CLIENTE": "={{ $('estadosPediidosHoy').item.json.cliente }}",
"EMAIL": "={{ $('estadosPediidosHoy').item.json.email }}",
"TELEFONO": "={{ $('estadosPediidosHoy').item.json.telefono }}",
"DIRECCION": "={{ $('estadosPediidosHoy').item.json.direccion }}",
"TIPODOC": "={{ $('estadosPediidosHoy').item.json.tipo_documento }}",
"DOCUMENTO": "={{ $('estadosPediidosHoy').item.json.documento }}",
"FECHA": "={{ $('estadosPediidosHoy').item.json.fechapedido }}",
"FECHAPROCESADO": "={{ $('estadosPediidosHoy').item.json.fechaprocesado }}",
"ESTADO": "={{ $('estadosPediidosHoy').item.json.nombre_estado }}",
"PRODUCTO": "={{ $('estadosPediidosHoy').item.json.producto }}",
"CANTIDAD": "={{ $('estadosPediidosHoy').item.json.cantidad }}",
"PRECIO": "={{ $('estadosPediidosHoy').item.json.precio_unitario }}",
"SUBTOTAL": "={{ $('estadosPediidosHoy').item.json.subtotal }}",
"METODO_PAGO": "={{ $json.metodo_pago }}"
},
"matchingColumns": [
"IDPEDIDOS"
],
"schema": [
{
"id": "IDPEDIDOS",
"displayName": "IDPEDIDOS",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "CLIENTE",
"displayName": "CLIENTE",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "EMAIL",
"displayName": "EMAIL",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "TELEFONO",
"displayName": "TELEFONO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "DIRECCION",
"displayName": "DIRECCION",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "TIPODOC",
"displayName": "TIPODOC",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "DOCUMENTO",
"displayName": "DOCUMENTO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "FECHA",
"displayName": "FECHA",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "FECHAPROCESADO",
"displayName": "FECHAPROCESADO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "ESTADO",
"displayName": "ESTADO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "METODO_PAGO",
"displayName": "METODO_PAGO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "PRODUCTO",
"displayName": "PRODUCTO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "CANTIDAD",
"displayName": "CANTIDAD",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "PRECIO",
"displayName": "PRECIO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "SUBTOTAL",
"displayName": "SUBTOTAL",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.7,
"position": [
-2208,
-608
],
"id": "39ef8a64-7a81-49eb-8048-aef04c41345b",
"name": "PROCESADOS",
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "appendOrUpdate",
"documentId": {
"__rl": true,
"value": "1pAphNQMC9sf1xi4_c_-LnE1ai2YU4l_kkDEZyyYe1FI",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": 2042045926,
"mode": "list",
"cachedResultName": "ENTREGADOS",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pAphNQMC9sf1xi4_c_-LnE1ai2YU4l_kkDEZyyYe1FI/edit#gid=2042045926"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"IDPEDIDOS": "={{ $json.id_pedido }}",
"CLIENTE": "={{ $json.cliente }}",
"EMAIL": "={{ $json.email }}",
"TELEFONO": "={{ $json.telefono }}",
"DIRECCION": "={{ $json.direccion }}",
"TIPODOC": "={{ $json.tipo_documento }}",
"DOCUMENTO": "={{ $json.documento }}",
"FECHA": "={{ $json.fechapedido }}",
"FECHAPROCESADO": "={{ $json.fechaprocesado }}",
"ESTADO": "={{ $json.nombre_estado }}",
"PRODUCTO": "={{ $json.producto }}",
"CANTIDAD": "={{ $json.cantidad }}",
"PRECIO": "={{ $json.precio_unitario }}",
"SUBTOTAL": "={{ $json.subtotal }}",
"METODO_PAGO": "={{ $json.metodo_pago }}"
},
"matchingColumns": [
"IDPEDIDOS"
],
"schema": [
{
"id": "IDPEDIDOS",
"displayName": "IDPEDIDOS",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "CLIENTE",
"displayName": "CLIENTE",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "EMAIL",
"displayName": "EMAIL",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "TELEFONO",
"displayName": "TELEFONO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "DIRECCION",
"displayName": "DIRECCION",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "TIPODOC",
"displayName": "TIPODOC",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "DOCUMENTO",
"displayName": "DOCUMENTO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "FECHA",
"displayName": "FECHA",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "FECHAPROCESADO",
"displayName": "FECHAPROCESADO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "ESTADO",
"displayName": "ESTADO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "METODO_PAGO",
"displayName": "METODO_PAGO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "PRODUCTO",
"displayName": "PRODUCTO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "CANTIDAD",
"displayName": "CANTIDAD",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "PRECIO",
"displayName": "PRECIO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "SUBTOTAL",
"displayName": "SUBTOTAL",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.7,
"position": [
-2208,
-320
],
"id": "8ec2044a-aa7f-4aea-989e-955e16aecedd",
"name": "ENTREGADOS",
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "appendOrUpdate",
"documentId": {
"__rl": true,
"value": "1pAphNQMC9sf1xi4_c_-LnE1ai2YU4l_kkDEZyyYe1FI",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": 63721071,
"mode": "list",
"cachedResultName": "CANCELADOS",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pAphNQMC9sf1xi4_c_-LnE1ai2YU4l_kkDEZyyYe1FI/edit#gid=63721071"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"IDPEDIDOS": "={{ $('estadosPediidosHoy').item.json.id_pedido }}",
"CLIENTE": "={{ $('estadosPediidosHoy').item.json.cliente }}",
"TIPODOC": "={{ $('estadosPediidosHoy').item.json.tipo_documento }}",
"DOCUMENTO": "={{ $('estadosPediidosHoy').item.json.documento }}",
"FECHA": "={{ $('estadosPediidosHoy').item.json.fechapedido }}",
"ESTADO": "={{ $('estadosPediidosHoy').item.json.nombre_estado }}",
"PRODUCTO": "={{ $('estadosPediidosHoy').item.json.producto }}",
"CANTIDAD": "={{ $('estadosPediidosHoy').item.json.cantidad }}",
"PRECIO": "={{ $('estadosPediidosHoy').item.json.precio_unitario }}",
"SUBTOTAL": "={{ $json.subtotal }}",
"EMAIL": "={{ $('estadosPediidosHoy').item.json.email }}",
"TELEFONO": "={{ $('estadosPediidosHoy').item.json.telefono }}",
"DIRECCION": "={{ $('estadosPediidosHoy').item.json.direccion }}",
"FECHAPROCESADO": "={{ $('estadosPediidosHoy').item.json.fechaprocesado }}",
"METODO_PAGO": "={{ $json.metodo_pago }}"
},
"matchingColumns": [
"IDPEDIDOS"
],
"schema": [
{
"id": "IDPEDIDOS",
"displayName": "IDPEDIDOS",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "CLIENTE",
"displayName": "CLIENTE",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "EMAIL",
"displayName": "EMAIL",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "TELEFONO",
"displayName": "TELEFONO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "DIRECCION",
"displayName": "DIRECCION",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "TIPODOC",
"displayName": "TIPODOC",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "DOCUMENTO",
"displayName": "DOCUMENTO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "FECHA",
"displayName": "FECHA",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "FECHAPROCESADO",
"displayName": "FECHAPROCESADO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "ESTADO",
"displayName": "ESTADO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "METODO_PAGO",
"displayName": "METODO_PAGO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "PRODUCTO",
"displayName": "PRODUCTO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "CANTIDAD",
"displayName": "CANTIDAD",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "PRECIO",
"displayName": "PRECIO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "SUBTOTAL",
"displayName": "SUBTOTAL",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.7,
"position": [
-2192,
-176
],
"id": "9aa991b6-1106-4329-888d-829ce6fe0921",
"name": "CANCELADOS",
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "appendOrUpdate",
"documentId": {
"__rl": true,
"value": "1pAphNQMC9sf1xi4_c_-LnE1ai2YU4l_kkDEZyyYe1FI",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": 892828664,
"mode": "list",
"cachedResultName": "EMVIADOS",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pAphNQMC9sf1xi4_c_-LnE1ai2YU4l_kkDEZyyYe1FI/edit#gid=892828664"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"IDPEDIDOS": "={{ $('estadosPediidosHoy').item.json.id_pedido }}",
"CLIENTE": "={{ $('estadosPediidosHoy').item.json.cliente }}",
"EMAIL": "={{ $('estadosPediidosHoy').item.json.email }}",
"TELEFONO": "={{ $('estadosPediidosHoy').item.json.telefono }}",
"DIRECCION": "={{ $('estadosPediidosHoy').item.json.direccion }}",
"TIPODOC": "={{ $('estadosPediidosHoy').item.json.tipo_documento }}",
"DOCUMENTO": "={{ $('estadosPediidosHoy').item.json.documento }}",
"FECHA": "={{ $('estadosPediidosHoy').item.json.fechapedido }}",
"FECHAPROCESADO": "={{ $('estadosPediidosHoy').item.json.fechaprocesado }}",
"ESTADO": "={{ $('estadosPediidosHoy').item.json.nombre_estado }}",
"PRODUCTO": "={{ $('estadosPediidosHoy').item.json.producto }}",
"CANTIDAD": "={{ $('estadosPediidosHoy').item.json.cantidad }}",
"PRECIO": "={{ $('estadosPediidosHoy').item.json.precio_unitario }}",
"SUBTOTAL": "={{ $('estadosPediidosHoy').item.json.subtotal }}",
"METODO_PAGO": "={{ $json.metodo_pago }}"
},
"matchingColumns": [
"IDPEDIDOS"
],
"schema": [
{
"id": "IDPEDIDOS",
"displayName": "IDPEDIDOS",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "CLIENTE",
"displayName": "CLIENTE",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "EMAIL",
"displayName": "EMAIL",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "TELEFONO",
"displayName": "TELEFONO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "DIRECCION",
"displayName": "DIRECCION",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "TIPODOC",
"displayName": "TIPODOC",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "DOCUMENTO",
"displayName": "DOCUMENTO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "FECHA",
"displayName": "FECHA",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "FECHAPROCESADO",
"displayName": "FECHAPROCESADO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "ESTADO",
"displayName": "ESTADO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "METODO_PAGO",
"displayName": "METODO_PAGO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "PRODUCTO",
"displayName": "PRODUCTO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "CANTIDAD",
"displayName": "CANTIDAD",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "PRECIO",
"displayName": "PRECIO",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "SUBTOTAL",
"displayName": "SUBTOTAL",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.7,
"position": [
-2208,
-448
],
"id": "eb906e46-d906-4e78-8d0f-79c53e10f432",
"name": "ENVIADO",
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"rule": {
"interval": [
{
"field": "minutes",
"minutesInterval": 10
}
]
}
},
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.3,
"position": [
-3344,
-240
],
"id": "3b3ae1f3-947e-4d07-93bd-7495edea22bf",
"name": "Schedule Trigger"
},
{
"parameters": {
"sendTo": "={{ $json.email }}",
"subject": "=Pedido {{ $json.nombre_estado }} - {{ $json.cliente }}",
"message": "=<!DOCTYPE html>\n<html lang=\"es\">\n<head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>Estado de tu pedido - MenuAdmin</title>\n <style>\n * {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n }\n\n body {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n background-color: #f0f2f5;\n line-height: 1.6;\n color: #1a2a3a;\n }\n\n .email-wrapper {\n max-width: 600px;\n margin: 20px auto;\n background-color: #ffffff;\n border-radius: 20px;\n overflow: hidden;\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);\n }\n\n .email-header {\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n padding: 30px 24px;\n text-align: center;\n }\n\n .logo {\n font-size: 32px;\n font-weight: 800;\n color: #ffffff;\n margin-bottom: 8px;\n letter-spacing: -1px;\n }\n\n .logo span {\n font-weight: 400;\n opacity: 0.9;\n }\n\n .email-header h1 {\n color: #ffffff;\n font-size: 22px;\n font-weight: 500;\n margin-top: 8px;\n }\n\n .email-body {\n padding: 32px 32px;\n }\n\n .greeting {\n font-size: 18px;\n font-weight: 600;\n color: #1e293b;\n margin-bottom: 16px;\n }\n\n /* Status Badge */\n .status-badge {\n text-align: center;\n margin: 24px 0;\n }\n\n .status {\n display: inline-block;\n padding: 8px 24px;\n border-radius: 50px;\n font-weight: 700;\n font-size: 16px;\n }\n\n .status-pendiente {\n background-color: #fef3c7;\n color: #d97706;\n }\n\n .status-confirmado {\n background-color: #dbeafe;\n color: #2563eb;\n }\n\n .status-preparando {\n background-color: #e0e7ff;\n color: #4f46e5;\n }\n\n .status-enviado {\n background-color: #d1fae5;\n color: #059669;\n }\n\n .status-entregado {\n background-color: #d1fae5;\n color: #10b981;\n }\n\n .status-cancelado {\n background-color: #fee2e2;\n color: #dc2626;\n }\n\n /* Detalles del pedido */\n .order-details {\n background-color: #f8fafc;\n border-radius: 16px;\n padding: 24px;\n margin: 24px 0;\n }\n\n .order-title {\n font-size: 16px;\n font-weight: 700;\n color: #1e293b;\n margin-bottom: 16px;\n padding-bottom: 12px;\n border-bottom: 2px solid #e2e8f0;\n }\n\n .order-info {\n margin-bottom: 20px;\n }\n\n .info-row {\n display: flex;\n margin-bottom: 12px;\n font-size: 14px;\n }\n\n .info-label {\n width: 120px;\n font-weight: 600;\n color: #64748b;\n }\n\n .info-value {\n flex: 1;\n color: #1e293b;\n }\n\n /* Tabla de productos */\n .products-table {\n width: 100%;\n border-collapse: collapse;\n margin: 16px 0;\n }\n\n .products-table th {\n text-align: left;\n padding: 12px 8px;\n background-color: #f1f5f9;\n font-size: 12px;\n font-weight: 600;\n color: #64748b;\n text-transform: uppercase;\n }\n\n .products-table td {\n padding: 12px 8px;\n border-bottom: 1px solid #e2e8f0;\n font-size: 14px;\n color: #334155;\n }\n\n .products-table td:last-child {\n text-align: right;\n font-weight: 600;\n }\n\n .total-row {\n text-align: right;\n padding-top: 16px;\n font-weight: 700;\n font-size: 18px;\n color: #1e293b;\n }\n\n /* Timeline de estados */\n .timeline {\n margin: 32px 0;\n padding: 0 16px;\n }\n\n .timeline-step {\n display: flex;\n align-items: center;\n margin-bottom: 16px;\n position: relative;\n }\n\n .timeline-icon {\n width: 40px;\n height: 40px;\n border-radius: 50%;\n background-color: #e2e8f0;\n display: flex;\n align-items: center;\n justify-content: center;\n margin-right: 16px;\n font-size: 18px;\n }\n\n .timeline-icon.completed {\n background: linear-gradient(135deg, #10b981, #059669);\n color: white;\n }\n\n .timeline-icon.current {\n background: linear-gradient(135deg, #667eea, #764ba2);\n color: white;\n box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);\n }\n\n .timeline-content {\n flex: 1;\n }\n\n .timeline-title {\n font-weight: 600;\n color: #1e293b;\n font-size: 14px;\n }\n\n .timeline-date {\n font-size: 12px;\n color: #94a3b8;\n }\n\n /* Bot\u00f3n de seguimiento */\n .tracking-button {\n text-align: center;\n margin: 32px 0;\n }\n\n .button {\n display: inline-block;\n background: linear-gradient(135deg, #667eea, #764ba2);\n color: #ffffff !important;\n text-decoration: none;\n padding: 14px 32px;\n border-radius: 50px;\n font-weight: 600;\n font-size: 15px;\n transition: transform 0.2s;\n box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);\n }\n\n .button:hover {\n transform: translateY(-2px);\n }\n\n /* Mensaje adicional */\n .message-box {\n background-color: #fef3c7;\n border-left: 4px solid #f59e0b;\n padding: 16px;\n margin: 24px 0;\n border-radius: 8px;\n font-size: 14px;\n color: #92400e;\n }\n\n .divider {\n height: 1px;\n background: linear-gradient(90deg, transparent, #e2e8f0, transparent);\n margin: 24px 0;\n }\n\n /* Footer */\n .email-footer {\n background-color: #f8fafc;\n padding: 24px 32px;\n text-align: center;\n border-top: 1px solid #e2e8f0;\n }\n\n .social-links {\n margin-bottom: 16px;\n }\n\n .social-link {\n display: inline-block;\n margin: 0 8px;\n color: #94a3b8;\n text-decoration: none;\n font-size: 12px;\n }\n\n .social-link:hover {\n color: #667eea;\n }\n\n .copyright {\n font-size: 12px;\n color: #94a3b8;\n margin-top: 16px;\n }\n\n .copyright a {\n color: #94a3b8;\n text-decoration: none;\n }\n\n @media (max-width: 600px) {\n .email-wrapper {\n margin: 0;\n border-radius: 0;\n }\n .email-body {\n padding: 24px 20px;\n }\n .info-row {\n flex-direction: column;\n }\n .info-label {\n width: 100%;\n margin-bottom: 4px;\n }\n .products-table th,\n .products-table td {\n font-size: 12px;\n }\n }\n </style>\n</head>\n<body>\n <div class=\"email-wrapper\">\n <div class=\"email-header\">\n \n <h1>Actualizaci\u00f3n de tu pedido</h1>\n </div>\n\n <div class=\"email-body\">\n <p class=\"greeting\">Hola {{ $json.cliente }},</p>\n \n <p>Tu pedido <strong>#{{ $json.id_pedido }}</strong> - Puedes ver el estado actual a continuaci\u00f3n.</p>\n\n <!-- Estado del pedido -->\n <div class=\"status-badge\">\n <span class=\"status\">\n {{ $json.nombre_estado }}\n </span>\n </div>\n\n <!-- Detalles del pedido -->\n <div class=\"order-details\">\n <div class=\"order-title\">\ud83d\udccb Detalles del pedido</div>\n <div class=\"order-info\">\n <div class=\"info-row\">\n <span class=\"info-label\">N\u00famero de pedido:</span>\n <span class=\"info-value\">#{{ $json.id_pedido }}</span>\n </div>\n <div class=\"info-row\">\n <span class=\"info-label\">Fecha del pedido:</span>\n <span class=\"info-value\">{{ $json.fechapedido }}</span>\n </div>\n <div class=\"info-row\">\n <span class=\"info-label\">M\u00e9todo de pago:</span>\n <span class=\"info-value\">{{ $json.nombre_metodo }}</span>\n </div>\n <div class=\"info-row\">\n <span class=\"info-label\">Direcci\u00f3n de env\u00edo:</span>\n <span class=\"info-value\">{{ $json.direccion }}</span>\n </div>\n </div>\n\n\n \n \n\n <p style=\"font-size: 14px; color: #64748b; text-align: center;\">\n \u00bfTienes alguna pregunta? Respondiendo a este email nuestros asesores te ayudar\u00e1n.\n </p>\n </div>\n\n <div class=\"email-footer\">\n <div class=\"social-links\">\n <a href=\"#\" class=\"social-link\">Facebook</a>\n <a href=\"#\" class=\"social-link\">Instagram</a>\n <a href=\"#\" class=\"social-link\">LinkedIn</a>\n <a href=\"#\" class=\"social-link\">Twitter</a>\n </div>\n\n </div>\n </div>\n</body>\n</html>",
"options": {}
},
"type": "n8n-nodes-base.gmail",
"typeVersion": 2.2,
"position": [
-2736,
48
],
"id": "cd386dff-a9ec-45c5-940c-d55c12f350cf",
"name": "Send a message",
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "executeQuery",
"query": "SELECT\n n.id_notificacion,\n c.id_cliente,\n c.nombre AS cliente,\n c.email,\n c.direccion,\n p.id_pedido,\n mp.nombre_metodo,\n e.id_estado,\n e.nombre_estado,\n n.notificacion,\n TO_CHAR(p.fecha, 'DD-MM-YYYY') AS fechaPedido\nFROM notificaciones n\n JOIN clientes c ON n.cliente_id = c.id_cliente\n JOIN pedidos p ON n.pedidos_id = p.id_pedido\n JOIN estados_pedidos e ON p.id_estado = e.id_estado\n JOIN metodos_pago mp on p.id_metodo_pago = mp.id_metodo_pago\nWHERE n.notificacion = 'N'\n AND p.id_estado IN (3, 5) -- Solo pedidos ENVIADOS o CANCELADOS sin notificar\n;",
"options": {}
},
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.6,
"position": [
-2928,
48
],
"id": "7c1e420c-0a39-46f8-82f8-7b7c9c30280e",
"name": "Execute a SQL query",
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "executeQuery",
"query": "UPDATE notificaciones\n SET notificacion = 'E'\nWHERE cliente_id = {{ $('Execute a SQL query').item.json.id_cliente }}\nAND pedidos_id = {{ $('Execute a SQL query').item.json.id_pedido }}\n;",
"options": {}
},
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.6,
"position": [
-2496,
48
],
"id": "a8b219b7-ac59-40e7-a36d-ad9364168cb0",
"name": "Execute a SQL query1",
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"content": "CLASIFICO SEGFUN ESTADO DEL PEDIDO",
"height": 736,
"width": 560,
"color": 6
},
"type": "n8n-nodes-base.stickyNote",
"position": [
-2576,
-752
],
"typeVersion": 1,
"id": "d90182df-9d4d-44c2-bf5b-00ec33b2c9a4",
"name": "Sticky Note"
},
{
"parameters": {
"content": "CHEQUEO CUALES ESTAN PARA NOTIFICAR POR EMAIL LOS ENVIADOS O CANCELADO",
"height": 176,
"width": 672,
"color": "#57E5A8"
},
"type": "n8n-nodes-base.stickyNote",
"position": [
-2976,
16
],
"typeVersion": 1,
"id": "da8c6f88-5a28-470e-bf06-3af6b7a5e2a0",
"name": "Sticky Note1"
},
{
"parameters": {
"content": "CONSULTO LOS PEDIDOS DEL DIA",
"height": 304,
"width": 288
},
"type": "n8n-nodes-base.stickyNote",
"position": [
-3008,
-576
],
"typeVersion": 1,
"id": "31b6c8ff-03f2-484b-a41a-45bc335d0e23",
"name": "Sticky Note2"
},
{
"parameters": {
"content": "SE EJECUTA CADA 10 MINUTOS",
"height": 304,
"color": "#FDF386"
},
"type": "n8n-nodes-base.stickyNote",
"position": [
-3408,
-336
],
"typeVersion": 1,
"id": "95663499-2971-4ec3-a931-c9bc76d9df6e",
"name": "Sticky Note3"
}
],
"connections": {
"estadosPediidosHoy": {
"main": [
[
{
"node": "Switch",
"type": "main",
"index": 0
}
]
]
},
"Switch": {
"main": [
[
{
"node": "PENDIENTES",
"type": "main",
"index": 0
}
],
[
{
"node": "PROCESADOS",
"type": "main",
"index": 0
}
],
[
{
"node": "ENVIADO",
"type": "main",
"index": 0
}
],
[
{
"node": "ENTREGADOS",
"type": "main",
"index": 0
}
],
[
{
"node": "CANCELADOS",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "estadosPediidosHoy",
"type": "main",
"index": 0
},
{
"node": "Execute a SQL query",
"type": "main",
"index": 0
}
]
]
},
"ENVIADO": {
"main": [
[]
]
},
"CANCELADOS": {
"main": [
[]
]
},
"Send a message": {
"main": [
[
{
"node": "Execute a SQL query1",
"type": "main",
"index": 0
}
]
]
},
"PROCESADOS": {
"main": [
[]
]
},
"Execute a SQL query": {
"main": [
[
{
"node": "Send a message",
"type": "main",
"index": 0
}
]
]
},
"Execute a SQL query1": {
"main": [
[]
]
}
},
"active": true,
"settings": {
"executionOrder": "v1",
"binaryMode": "separate"
},
"versionId": "cf4cc7bb-75c6-49da-8545-f0d048399aba",
"meta": {
"templateCredsSetupCompleted": true
},
"id": "qNNYMuaFHqJuXzss",
"tags": []
}
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.
gmailOAuth2googleSheetsOAuth2Apipostgres
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
pedidosProductos. Uses postgres, googleSheets, gmail. Scheduled trigger; 15 nodes.
Source: https://github.com/moleculax/estadoPedidos/blob/main/pedidosProductos.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.
This workflow monitors customer health by combining payment behavior, complaint signals, and AI-driven feedback analysis. It runs on daily and weekly schedules to evaluate risk levels, escalate high-r
This workflow automatically monitors and reports data quality for any SQL table using configurable checks and thresholds. It evaluates key metrics—including null values, duplicate records, row count a
Continuous monitoring: Real-time surveillance of supplier performance, financial health, and operational status Risk scoring: AI-powered assessment of supplier risks across multiple dimensions (financ
Regulatory monitoring: Continuously tracks changes in laws, regulations, and compliance requirements across multiple jurisdictions Contract analysis: AI-powered review of existing contracts to identif
This workflow is designed for Customer Success Managers, Growth Teams, and SaaS Business Owners who want to proactively reduce churn using AI. It automates the analysis of customer health and the deli