Alerta de bajo inventario para Magento 2 a través de Slack y Gmail (compatible MSI)

Avanzado

Este es unMiscellaneousflujo de automatización del dominio deautomatización que contiene 18 nodos.Utiliza principalmente nodos como If, Code, Gmail, Slack, HttpRequest. Alerta de inventario bajo para Magento 2 a través de Slack y Gmail (compatible con MSI)

Requisitos previos
  • Cuenta de Google y credenciales de API de Gmail
  • Bot Token de Slack o URL de Webhook
  • Pueden requerirse credenciales de autenticación para la API de destino

Categoría

Vista previa del flujo de trabajo
Visualización de las conexiones entre nodos, con soporte para zoom y panorámica
Exportar flujo de trabajo
Copie la siguiente configuración JSON en n8n para importar y usar este flujo de trabajo
{
  "meta": {
    "instanceId": "54d8e296590faa0bb0e9d6290ad6ee2f19b78aa7b248ecb45c5f7c5ff622d210",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "7d9139ff-f51e-4017-8831-5f8c6c273f51",
      "name": "Verificación Diaria de Inventario",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1860,
        500
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "50 8 * * *"
            }
          ]
        }
      },
      "notesInFlow": false,
      "typeVersion": 1.2
    },
    {
      "id": "bc8d384a-c5d8-4864-a157-cb21f3643d84",
      "name": "Verificar si se Necesitan Alertas",
      "type": "n8n-nodes-base.if",
      "position": [
        -780,
        500
      ],
      "parameters": {
        "options": {
          "looseTypeValidation": true
        },
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "condition-001",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $node[\"Process Stock Data and Identify Low Stock\"].json[\"lowStockAlerts\"].length > 0 }}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "c42fabc3-2180-49e2-8ea5-d24500dbdea0",
      "name": "Enviar Alerta de Inventario",
      "type": "n8n-nodes-base.slack",
      "position": [
        -20,
        340
      ],
      "webhookId": "4d8500c1-7086-4fc8-8b8b-6ff061c4381b",
      "parameters": {
        "text": "={{ $json.slackMessage }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "name",
          "value": "#magento-notifications"
        },
        "otherOptions": {
          "includeLinkToWorkflow": false
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "d0278e03-e2af-48c0-af7c-2be43a504398",
      "name": "Información del Flujo de Trabajo",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1960,
        -140
      ],
      "parameters": {
        "width": 420,
        "height": 300,
        "content": "         📦 MAGENTO 2 STOCK ALERTS\n**Author: Kanaka Kishore Kandregula **\n\nWORKFLOW PURPOSE:\nAutomatically monitor Magento 2 (Adobe Commerce) inventory levels and alert when products are running low\n\nSETUP REQUIREMENTS:\n- Magento 2 store with product inventory tracking\n- Slack & Gmail channels for alerts (#magento-notifications)\n- Define low stock threshold (default: 5 units)\n"
      },
      "typeVersion": 1
    },
    {
      "id": "f9c6eb47-2f17-4039-b1f0-48ea84ce8b09",
      "name": "Características y Configuración",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -600,
        -140
      ],
      "parameters": {
        "color": 4,
        "width": 400,
        "height": 300,
        "content": "                KEY FEATURES\n\n✅ MSI Support\n✅ Daily automated inventory checks\n✅ Customisable stock thresholds\n✅ Multiple SKU Reporting\n✅ Proactive restocking alerts\n\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "accd7ae8-f4d7-4bc3-8d99-2e9ecac7ece2",
      "name": "Valor Comercial",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -160,
        -140
      ],
      "parameters": {
        "color": 7,
        "width": 360,
        "height": 300,
        "content": "             BUSINESS VALUE\n\n🚫 Prevent stockouts\n💰 Maintain sales revenue\n📊 Better inventory management\n⏰ Proactive restocking\n\nTIME TO BUILD: 20 minutes\nDIFFICULTY: Intermediate\nROI: High - prevents lost sales"
      },
      "typeVersion": 1
    },
    {
      "id": "f3651bdf-d90e-42f5-ba94-3bf4e4c55511",
      "name": "Obtener Todos los SKU de Productos",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1420,
        320
      ],
      "parameters": {
        "url": "=https://magekwik.com/rest/V1/products?searchCriteria[pageSize]=0&searchCriteria[filterGroups][0][filters][0][field]=type_id&searchCriteria[filterGroups][0][filters][0][conditionType]=nin&searchCriteria[filterGroups][0][filters][0][value]=configurable,virtual,downloadable&fields=items[sku,extension_attributes[stock_item[manage_stock]]]",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth"
      },
      "typeVersion": 4.2
    },
    {
      "id": "c20eaa02-c1ce-4999-9aef-8c6a3fd959ee",
      "name": "Extraer SKUs",
      "type": "n8n-nodes-base.code",
      "position": [
        -1180,
        320
      ],
      "parameters": {
        "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nconst skus = [];\nfor (const item of $input.first().json.items) {\n  skus.push(item.sku);\n}\nreturn [{ json: { skus: skus } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "a3fe994f-e782-4c55-8cdb-b8a256acdf37",
      "name": "Obtener Estado de Stock MSI",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1420,
        680
      ],
      "parameters": {
        "url": "=https://magekwik.com/rest/V1/inventory/source-items?searchCriteria[filterGroups][0][filters][0][field]=sku&searchCriteria[filterGroups][0][filters][0][conditionType]=in&searchCriteria[filterGroups][0][filters][0][value]={{ encodeURIComponent($node[\"Extract SKUs\"].json[\"skus\"].join(',')) }}",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth"
      },
      "typeVersion": 4.2
    },
    {
      "id": "2cf2065b-f235-4582-b439-4902a0097e10",
      "name": "Procesar Datos de Stock e Identificar Bajo Inventario",
      "type": "n8n-nodes-base.code",
      "position": [
        -1180,
        680
      ],
      "parameters": {
        "jsCode": "const lowStockItems = [];\nconst lowStockThreshold = 10; // Define your low stock threshold here\nconst minSourceQuantity = 5; // Define minimum quantity per source if applicable\n\n// Assuming the MSI stock data is in $json.items\nfor (const item of  $input.first().json.items) {\n  const sku = item.sku;\n  const sourceCode = item.source_code;\n  const quantity = item.quantity;\n  const status = item.status; // 1 for In Stock, 0 for Out of Stock\n\n  // Check if the item is in stock and below the overall low stock threshold\n  // Or if a specific source is very low\n  if (status === 1 && (quantity <= lowStockThreshold || quantity <= minSourceQuantity)) {\n    lowStockItems.push({\n      sku: sku,\n      source: sourceCode,\n      quantity: quantity,\n      status: status === 1 ? 'In Stock' : 'Out of Stock'\n    });\n  }\n}\n\n// You can further process lowStockItems to group by SKU or format as needed\n// For now, we'll return a list of individual low stock entries.\nreturn [{ json: { lowStockAlerts: lowStockItems } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "c92398cf-70f4-4d93-a273-693bc3c1bbd5",
      "name": "Enviar un mensaje",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -20,
        620
      ],
      "webhookId": "ff620d7f-3427-4a4f-a945-4cdef714a98b",
      "parameters": {
        "sendTo": "kmyprojects@gmail.com",
        "message": "={{ $json.gmailHtml }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "={{ $json.subjectLine }}"
      },
      "typeVersion": 2.1
    },
    {
      "id": "55ffa452-f2c5-43c2-996d-0f0fb7c9bed4",
      "name": "Formatear Mensaje",
      "type": "n8n-nodes-base.code",
      "position": [
        -480,
        500
      ],
      "parameters": {
        "jsCode": "const lowStockAlerts = Array.isArray($input.first().json.lowStockAlerts) ? $input.first().json.lowStockAlerts : [];\n\nlet plainText = \"*📦 Low Stock Alert for Magento 2 Multi-Store (MSI)*\\n\\n\";\nlet htmlText = \"<b>📦 Low Stock Alert for Magento 2 Multi-Store (MSI)</b><br><br>\";\n\nif (lowStockAlerts.length === 0) {\n  plainText += \"_No low stock items found at this time._\";\n  htmlText += \"<i>No low stock items found at this time.</i>\";\n} else {\n  plainText += \"*The following products have low stock:*\\n\\n\";\n  htmlText += \"<b>The following products have low stock:</b><br><br>\";\n\n  // Text version\n  plainText += \"```\\nSKU       Source     Quantity  Status\\n\";\n  plainText += \"--------  ---------  --------  --------\\n\";\n\n  // HTML table version\n  htmlText += `<table border=\"1\" cellpadding=\"6\" cellspacing=\"0\" style=\"border-collapse: collapse;\">\n    <thead>\n      <tr>\n        <th align=\"left\">SKU</th>\n        <th align=\"left\">Source</th>\n        <th align=\"left\">Quantity</th>\n        <th align=\"left\">Status</th>\n      </tr>\n    </thead>\n    <tbody>\n  `;\n\n  lowStockAlerts.forEach(item => {\n    const sku = item.sku || 'N/A';\n    const source = item.source || 'N/A';\n    const quantity = item.quantity || 0;\n    const status = item.status || 'Unknown';\n\n    // Plain text table row\n    plainText += `${sku.padEnd(10)}${source.padEnd(11)}${String(quantity).padEnd(9)}${status}\\n`;\n\n    // HTML table row\n    htmlText += `<tr>\n      <td>${sku}</td>\n      <td>${source}</td>\n      <td>${quantity}</td>\n      <td>${status}</td>\n    </tr>`;\n  });\n\n  plainText += \"```\\n\\n🔍 Please check your Magento 2 inventory.\";\n  htmlText += \"</tbody></table><br><br>🔍 <b>Please check your Magento 2 inventory.</b>\";\n}\n\n// Output both formats\nreturn [{\n  json: {\n    slackMessage: plainText,\n    gmailHtml: htmlText,\n    subjectLine: `🔔 Magento 2 Low Stock Alert – ${new Date().toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' })}`\n  }\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "974a2ff6-768b-44b4-bf14-7b8534c99eac",
      "name": "Nota Adhesiva",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1500,
        -140
      ],
      "parameters": {
        "color": 5,
        "width": 420,
        "height": 300,
        "content": "                 WORK FLOW\n\n1. Schedule Trigger (daily 8:50 AM check)\n2. Magento 2 (get all products)\n3. Code Node (filter low stock items)\n4. If Node (check if any alerts needed)\n5. Format alert message\n6. Slack & Gmail (send inventory alert)"
      },
      "typeVersion": 1
    },
    {
      "id": "0d19935c-9078-435a-a940-49fdfef93bef",
      "name": "Nota Adhesiva1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1040,
        -140
      ],
      "parameters": {
        "color": 3,
        "width": 400,
        "height": 300,
        "content": "           CONFIGURATION NOTES\n\n- Adjust lowStockThreshold variable in Process Stock Data node\n- Modify daily schedule timing as needed\n- You Bearer Token from Magento\n- Slack & Gmail API details"
      },
      "typeVersion": 1
    },
    {
      "id": "cde3e885-dad8-4467-840a-52dbfd0997e1",
      "name": "Nota Adhesiva2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1940,
        400
      ],
      "parameters": {
        "color": 7,
        "width": 280,
        "height": 300,
        "content": "     Trigs Daily 8:50am"
      },
      "typeVersion": 1
    },
    {
      "id": "ca9ffce4-f84c-4da1-aa0c-5b50812fe8ff",
      "name": "Nota Adhesiva3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1520,
        220
      ],
      "parameters": {
        "color": 5,
        "width": 540,
        "height": 660,
        "content": "                      Magento Logic"
      },
      "typeVersion": 1
    },
    {
      "id": "a563ff82-2b81-468b-a33f-0780c9522a4c",
      "name": "Nota Adhesiva4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -120,
        220
      ],
      "parameters": {
        "color": 4,
        "width": 320,
        "height": 660,
        "content": "           Notifications"
      },
      "typeVersion": 1
    },
    {
      "id": "70c8982e-ea87-4d75-8a69-ee6ad174b4c1",
      "name": "Nota Adhesiva5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -820,
        400
      ],
      "parameters": {
        "color": 6,
        "width": 520,
        "height": 300,
        "content": "              Checks & Message Formatting"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "c20eaa02-c1ce-4999-9aef-8c6a3fd959ee": {
      "main": [
        [
          {
            "node": "a3fe994f-e782-4c55-8cdb-b8a256acdf37",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "55ffa452-f2c5-43c2-996d-0f0fb7c9bed4": {
      "main": [
        [
          {
            "node": "c42fabc3-2180-49e2-8ea5-d24500dbdea0",
            "type": "main",
            "index": 0
          },
          {
            "node": "c92398cf-70f4-4d93-a273-693bc3c1bbd5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f3651bdf-d90e-42f5-ba94-3bf4e4c55511": {
      "main": [
        [
          {
            "node": "c20eaa02-c1ce-4999-9aef-8c6a3fd959ee",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "7d9139ff-f51e-4017-8831-5f8c6c273f51": {
      "main": [
        [
          {
            "node": "f3651bdf-d90e-42f5-ba94-3bf4e4c55511",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "bc8d384a-c5d8-4864-a157-cb21f3643d84": {
      "main": [
        [
          {
            "node": "55ffa452-f2c5-43c2-996d-0f0fb7c9bed4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "a3fe994f-e782-4c55-8cdb-b8a256acdf37": {
      "main": [
        [
          {
            "node": "2cf2065b-f235-4582-b439-4902a0097e10",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2cf2065b-f235-4582-b439-4902a0097e10": {
      "main": [
        [
          {
            "node": "bc8d384a-c5d8-4864-a157-cb21f3643d84",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Preguntas frecuentes

¿Cómo usar este flujo de trabajo?

Copie el código de configuración JSON de arriba, cree un nuevo flujo de trabajo en su instancia de n8n y seleccione "Importar desde JSON", pegue la configuración y luego modifique la configuración de credenciales según sea necesario.

¿En qué escenarios es adecuado este flujo de trabajo?

Avanzado - Varios

¿Es de pago?

Este flujo de trabajo es completamente gratuito, puede importarlo y usarlo directamente. Sin embargo, tenga en cuenta que los servicios de terceros utilizados en el flujo de trabajo (como la API de OpenAI) pueden requerir un pago por su cuenta.

Flujos de trabajo relacionados recomendados

Aprobación automática a través de Gmail para desactivar productos no vendidos de Magento 2 durante un año
Deshabilitar automáticamente productos no vendidos de Magento 2 en un año mediante aprobación de Gmail
If
Code
Gmail
+
If
Code
Gmail
22 NodosKanaka Kishore Kandregula
Extracción de documentos
Verificación de vencimiento y recordatorios de actualización para publicaciones de empleos desde Google Sheets usando HTTP Last-Modified
Automatización de recordatorios de publicación de empleos vencidos con Google Sheets, verificaciones HTTP y Gmail
If
Set
Code
+
If
Set
Code
19 NodosWeblineIndia
Recursos Humanos
Automatización de la puntuación de riesgos de proveedores
Automatización de la puntuación de riesgos de proveedores con D&B, NewsAPI y recordatorios de Gmail
If
Set
Code
+
If
Set
Code
16 NodosRodrigue
Varios
Recordatorios automáticos de productos y cupones de Magento 2 a Telegram (anti-duplicado)
Recordatorios automáticos de productos y cupones de Magento 2 a Telegram (con protección contra duplicados)
If
Code
My Sql
+
If
Code
My Sql
27 NodosKanaka Kishore Kandregula
Redes sociales
Alertas de caída de criptomonedas Bitcoin y Ethereum (Telegram, Slack y SMS)
Enviar alertas de caída de Bitcoin y Ethereum a Telegram, Slack y SMS
If
Code
Slack
+
If
Code
Slack
8 NodosDavid Olusola
Comercio de criptomonedas
Automatizar la publicación de RSS a Medium con Groq, Gemini y sistema de aprobación de Slack
Automatizar el flujo de publicación de RSS a Medium con Groq, Gemini y sistema de aprobación de Slack
If
Set
Code
+
If
Set
Code
41 NodosObisDev
Creación de contenido
Información del flujo de trabajo
Nivel de dificultad
Avanzado
Número de nodos18
Categoría1
Tipos de nodos7
Descripción de la dificultad

Adecuado para usuarios avanzados, flujos de trabajo complejos con 16+ nodos

Autor
Kanaka Kishore Kandregula

Kanaka Kishore Kandregula

@kmyprojects

Experienced Magento 2 Developer with 10+ years of expertise in building and optimizing eCommerce solutions. Over the past year, I’ve expanded my skills into workflow automation using n8n, streamlining business processes and integrating systems for efficiency. Passionate about solving complex problems, enhancing performance, and leveraging automation to drive smarter workflows.

Enlaces externos
Ver en n8n.io

Compartir este flujo de trabajo

Categorías

Categorías: 34