Recordatorios automáticos de productos y cupones de Magento 2 a Telegram (anti-duplicado)

Avanzado

Este es unSocial Mediaflujo de automatización del dominio deautomatización que contiene 27 nodos.Utiliza principalmente nodos como If, Code, MySql, Twitter, Telegram. Recordatorios automáticos de productos y cupones de Magento 2 a Telegram (con protección contra duplicados)

Requisitos previos
  • Información de conexión de la base de datos MySQL
  • Credenciales de API de Twitter
  • Bot Token de Telegram
  • 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": "475f038f0c1743165ad39f5fa1e828653b3237cbd0f743c0a3f15e90ddc9aa2b",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "0eacaccd-7ca0-493b-bcf6-60758b3b0f5e",
      "name": "Disparador Programado",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -960,
        -440
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "b77cb27a-f72f-4e79-af4d-c128375b6aef",
      "name": "Obtener Información de Regla",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        240,
        -140
      ],
      "parameters": {
        "url": "=https://magekwik.com/rest/V1/salesRules/{{ $json.item_id }}",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "typeVersion": 4.2
    },
    {
      "id": "29b72aef-59f5-45f5-b81f-bb383b8817a7",
      "name": "Estado del Cupón",
      "type": "n8n-nodes-base.if",
      "position": [
        420,
        -140
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "90c39652-acba-47a2-beff-494cd117b13c",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.is_active }}",
              "rightValue": "={{ $json.is_active }}"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "28dce2fb-11e4-4c4a-845c-17d68c857130",
      "name": "Publicar en Telegram1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        980,
        -160
      ],
      "webhookId": "05b88e7c-bf3a-4a29-aa98-f331831ea6c4",
      "parameters": {
        "text": "={{ $json.coupon }}",
        "chatId": "",
        "additionalFields": {
          "parse_mode": "HTML"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d1d70202-6b0e-4ce4-9820-c94109c758ad",
      "name": "Alerta de Producto a Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        980,
        40
      ],
      "webhookId": "05b88e7c-bf3a-4a29-aa98-f331831ea6c4",
      "parameters": {
        "media": {
          "media": [
            {
              "media": "={{ $json.image }}",
              "additionalFields": {
                "caption": "={{ $json.message }}"
              }
            }
          ]
        },
        "chatId": "",
        "operation": "sendMediaGroup",
        "additionalFields": {}
      },
      "typeVersion": 1
    },
    {
      "id": "693d5ef4-0776-4401-97ff-bb49378a8c77",
      "name": "Inicializar Base de Datos",
      "type": "n8n-nodes-base.mySql",
      "position": [
        -520,
        -440
      ],
      "parameters": {
        "query": "CREATE TABLE IF NOT EXISTS posted_items (item_id INT PRIMARY KEY, item_type ENUM('product', 'coupon') NOT NULL, item_value VARCHAR(255), posted BOOLEAN DEFAULT FALSE, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);",
        "options": {},
        "operation": "executeQuery"
      },
      "typeVersion": 2.4
    },
    {
      "id": "99ebf843-ecf6-46da-9f5b-fbbc242db19b",
      "name": "Obtener Producto Nuevo",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -360,
        120
      ],
      "parameters": {
        "url": "={{$vars.STORE}}rest/V1/products?searchCriteria[sortOrders][0][field]=created_at&searchCriteria[sortOrders][0][direction]=DESC",
        "options": {},
        "authentication": "headerAuth",
        "allowUnauthorizedCerts": true
      },
      "typeVersion": 1
    },
    {
      "id": "f8b54b91-b743-4d3b-9637-2f769b46a48b",
      "name": "Obtener Información del Producto",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        240,
        120
      ],
      "parameters": {
        "url": "=https://your-website.com/rest/default/V1/products/{{ $json.item_value }}",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "typeVersion": 4.2
    },
    {
      "id": "ef85ab97-027b-4fdd-b79c-c38b2795707e",
      "name": "Marcar Cupón como Publicado",
      "type": "n8n-nodes-base.mySql",
      "position": [
        1260,
        -140
      ],
      "parameters": {
        "query": "UPDATE posted_items set posted = 1 WHERE item_id = {{ $('Get Latest Offer').item.json.items[0].rule_id }} AND item_type = 'coupon';",
        "options": {},
        "operation": "executeQuery"
      },
      "typeVersion": 2.4
    },
    {
      "id": "6716f687-198b-4cff-8212-9e6789d597f9",
      "name": "Marcar Producto como Publicado",
      "type": "n8n-nodes-base.mySql",
      "position": [
        1260,
        100
      ],
      "parameters": {
        "query": "UPDATE posted_items set posted = 1 WHERE item_id = {{ $('Product Status').item.json.id }} AND item_type = 'product';",
        "options": {},
        "operation": "executeQuery"
      },
      "typeVersion": 2.4
    },
    {
      "id": "347f5828-f6f9-4d0e-9771-e9b3884c9a27",
      "name": "Obtener Oferta Más Reciente",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -360,
        -140
      ],
      "parameters": {
        "url": "={{$vars.STORE}}/rest/V1/coupons/search?searchCriteria[sortOrders][0][field]=created_at&searchCriteria[sortOrders][0][direction]=DESC&searchCriteria[pageSize]=1",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "typeVersion": 4.2
    },
    {
      "id": "4fcb066a-f4c8-4449-86d8-6f39513994ab",
      "name": "Formato de Mensaje de Producto",
      "type": "n8n-nodes-base.code",
      "position": [
        680,
        120
      ],
      "parameters": {
        "jsCode": "const product =  $input.first().json\n\nconst message = `🛙 New Product Alert!\\n\\n*${product.name}*\\nPrice: $${product.price}\\n\\nCheck it out now:\\nhttps://magekwik.com/${product.custom_attributes[2].value}`;\n\nreturn [{\n  json: {\n    message,\n    image: product.media_gallery_entries?.[0]?.file\n      ? `https://magekwik.com/pub/media/catalog/product${product.media_gallery_entries[0].file}`\n      : null,\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "44e6392f-80b1-4a2b-8081-c0004ed3e0fa",
      "name": "Formato de Mensaje de Cupón",
      "type": "n8n-nodes-base.code",
      "position": [
        680,
        -140
      ],
      "parameters": {
        "jsCode": "\nconst coupon = `🎁 New Coupon Alert! 🎁\\n\n🎟️ <b>Coupon Code</b>: ${$('Get Latest Offer').first().json.items[0].code}\n🔄 Usage: ${$('Get Rule Info').first().json.times_used || 0}/${$('Get Rule Info').first().json.uses_per_customer || '∞'}\n✅ Status: ${$('Get Rule Info').first().json.is_active ? 'ACTIVE ✅' : 'INACTIVE ❌'}`\n\nreturn [{\n  json: {\n    coupon\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "0bf1f58c-1b8d-43eb-a110-121e94d7e44a",
      "name": "Nueva Entrada de Cupón",
      "type": "n8n-nodes-base.mySql",
      "position": [
        -160,
        -140
      ],
      "parameters": {
        "query": "SET @coupon_id = '{{ $json.items[0].coupon_id }}';\nSET @search_coupon = '{{ $json.items[0].code }}';\n\nINSERT INTO posted_items (\n    item_id, \n    item_type,\n    item_value,\n    posted, \n    updated_at\n)\nSELECT \n    @coupon_id AS item_id,\n    'coupon' AS item_type,\n    @search_coupon AS item_value,\n    FALSE AS posted,\n    CURRENT_TIMESTAMP AS updated_at\nFROM dual\nWHERE NOT EXISTS (\n    SELECT 1 \n    FROM posted_items \n    WHERE item_id = @coupon_id AND item_type = 'coupon'\n);\n\nSELECT * \nFROM posted_items \nWHERE item_id = @coupon_id AND item_type = 'coupon'",
        "options": {},
        "operation": "executeQuery"
      },
      "notesInFlow": false,
      "typeVersion": 2.4,
      "alwaysOutputData": false
    },
    {
      "id": "d060693e-aed5-40cf-9a36-28bf84d96925",
      "name": "Nueva Entrada de Producto",
      "type": "n8n-nodes-base.mySql",
      "position": [
        -160,
        120
      ],
      "parameters": {
        "query": "SET @product_id = '{{ $json.items[0].id }}';\nSET @product_sku = '{{ $json.items[0].sku }}';\n\nINSERT INTO posted_items (\n    item_id, \n    item_type,\n    item_value,\n    posted, \n    updated_at\n)\nSELECT \n    @product_id AS item_id,\n    'product' AS item_type,\n    @product_sku AS item_value,\n    FALSE AS posted,\n    CURRENT_TIMESTAMP AS updated_at\nFROM dual\nWHERE NOT EXISTS (\n    SELECT 1 \n    FROM posted_items \n    WHERE item_id = @product_id AND item_type = 'product'\n);\n\nSELECT * \nFROM posted_items \nWHERE item_id = @product_id AND item_type = 'product'",
        "options": {},
        "operation": "executeQuery"
      },
      "notesInFlow": false,
      "typeVersion": 2.4,
      "alwaysOutputData": false
    },
    {
      "id": "ad3f87a5-a37a-4672-984b-5b8a510ea6a4",
      "name": "Estado del Producto",
      "type": "n8n-nodes-base.if",
      "position": [
        420,
        120
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "90c39652-acba-47a2-beff-494cd117b13c",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "={{ $json.is_active }}"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "dceda5b3-9126-453b-bd6e-01f5ddbc8a60",
      "name": "Cupón a X",
      "type": "n8n-nodes-base.twitter",
      "onError": "continueRegularOutput",
      "disabled": true,
      "position": [
        980,
        -340
      ],
      "parameters": {
        "text": "={{ $json.coupon }}",
        "additionalFields": {}
      },
      "typeVersion": 2,
      "alwaysOutputData": true
    },
    {
      "id": "17e427ed-77f5-4d3c-a6cf-8937f955b9c0",
      "name": "Publicación de Producto X",
      "type": "n8n-nodes-base.twitter",
      "onError": "continueRegularOutput",
      "position": [
        980,
        260
      ],
      "parameters": {
        "text": "={{ $json.image }}\n\n{{ $json.message }}",
        "additionalFields": {}
      },
      "typeVersion": 2,
      "alwaysOutputData": true
    },
    {
      "id": "70972854-d872-4665-8971-217494646726",
      "name": "Protección contra Duplicados de Cupón",
      "type": "n8n-nodes-base.if",
      "position": [
        40,
        -140
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "90c39652-acba-47a2-beff-494cd117b13c",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $json.posted }}",
              "rightValue": 1
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "c3c88742-1e58-483d-95ee-4fef4fb69104",
      "name": "Protección contra Duplicados de Producto",
      "type": "n8n-nodes-base.if",
      "position": [
        40,
        120
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "90c39652-acba-47a2-beff-494cd117b13c",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $json.posted }}",
              "rightValue": 1
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2,
      "alwaysOutputData": false
    },
    {
      "id": "458acf57-b472-4d4f-a609-4e9d2737c506",
      "name": "Nota Adhesiva",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        900,
        -400
      ],
      "parameters": {
        "color": 4,
        "width": 260,
        "height": 820,
        "content": "\n## Post to X & Telegram"
      },
      "typeVersion": 1
    },
    {
      "id": "63f50109-8206-4da5-9429-46e89ef651aa",
      "name": "Nota Adhesiva1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1200,
        -220
      ],
      "parameters": {
        "color": 3,
        "width": 220,
        "height": 480,
        "content": "## Record as Posted "
      },
      "typeVersion": 1
    },
    {
      "id": "769d34f1-5b3a-41ff-8dc6-9a658eccd52f",
      "name": "Nota Adhesiva2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1040,
        -500
      ],
      "parameters": {
        "color": 7,
        "width": 700,
        "height": 240,
        "content": "## Auto Schedule Trigger & Initialise DB"
      },
      "typeVersion": 1
    },
    {
      "id": "d37f209e-5fa7-46be-8e72-5d1c3757be59",
      "name": "Nota Adhesiva3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        620,
        -220
      ],
      "parameters": {
        "color": 6,
        "height": 500,
        "content": "## Format Messages"
      },
      "typeVersion": 1
    },
    {
      "id": "c9c618af-1ba3-4c82-a629-8cf0b1a84c9f",
      "name": "Nota Adhesiva4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -440,
        -220
      ],
      "parameters": {
        "color": 5,
        "width": 1040,
        "height": 240,
        "content": "                    ## Magento 2 - Checks for Latest Voucher - Record in Database - Validates"
      },
      "typeVersion": 1
    },
    {
      "id": "d9399795-e4ff-4590-bd37-3901beb1aee5",
      "name": "Nota Adhesiva5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -440,
        40
      ],
      "parameters": {
        "color": 5,
        "width": 1040,
        "height": 240,
        "content": "                          ## Magento 2 - Checks for New Product - Record in Database - Validates"
      },
      "typeVersion": 1
    },
    {
      "id": "1d1624e4-cdc1-4b50-886d-cefc118259cf",
      "name": "Nota Adhesiva6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        -500
      ],
      "parameters": {
        "width": 660,
        "height": 240,
        "content": "## Magento 2 (Adobe Commerce): Automated X & Telegram Posting for New Products and Vouchers \n\n## - This Automation Comes with Duplicate Prevention"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "dceda5b3-9126-453b-bd6e-01f5ddbc8a60": {
      "main": [
        [
          {
            "node": "ef85ab97-027b-4fdd-b79c-c38b2795707e",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "29b72aef-59f5-45f5-b81f-bb383b8817a7": {
      "main": [
        [
          {
            "node": "44e6392f-80b1-4a2b-8081-c0004ed3e0fa",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "b77cb27a-f72f-4e79-af4d-c128375b6aef": {
      "main": [
        [
          {
            "node": "29b72aef-59f5-45f5-b81f-bb383b8817a7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ad3f87a5-a37a-4672-984b-5b8a510ea6a4": {
      "main": [
        [
          {
            "node": "4fcb066a-f4c8-4449-86d8-6f39513994ab",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "17e427ed-77f5-4d3c-a6cf-8937f955b9c0": {
      "main": [
        [
          {
            "node": "6716f687-198b-4cff-8212-9e6789d597f9",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "347f5828-f6f9-4d0e-9771-e9b3884c9a27": {
      "main": [
        [
          {
            "node": "0bf1f58c-1b8d-43eb-a110-121e94d7e44a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f8b54b91-b743-4d3b-9637-2f769b46a48b": {
      "main": [
        [
          {
            "node": "ad3f87a5-a37a-4672-984b-5b8a510ea6a4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "0eacaccd-7ca0-493b-bcf6-60758b3b0f5e": {
      "main": [
        [
          {
            "node": "347f5828-f6f9-4d0e-9771-e9b3884c9a27",
            "type": "main",
            "index": 0
          },
          {
            "node": "693d5ef4-0776-4401-97ff-bb49378a8c77",
            "type": "main",
            "index": 0
          },
          {
            "node": "99ebf843-ecf6-46da-9f5b-fbbc242db19b",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "99ebf843-ecf6-46da-9f5b-fbbc242db19b": {
      "main": [
        [
          {
            "node": "d060693e-aed5-40cf-9a36-28bf84d96925",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d060693e-aed5-40cf-9a36-28bf84d96925": {
      "main": [
        [
          {
            "node": "c3c88742-1e58-483d-95ee-4fef4fb69104",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "0bf1f58c-1b8d-43eb-a110-121e94d7e44a": {
      "main": [
        [
          {
            "node": "70972854-d872-4665-8971-217494646726",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "28dce2fb-11e4-4c4a-845c-17d68c857130": {
      "main": [
        [
          {
            "node": "ef85ab97-027b-4fdd-b79c-c38b2795707e",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4fcb066a-f4c8-4449-86d8-6f39513994ab": {
      "main": [
        [
          {
            "node": "d1d70202-6b0e-4ce4-9820-c94109c758ad",
            "type": "main",
            "index": 0
          },
          {
            "node": "17e427ed-77f5-4d3c-a6cf-8937f955b9c0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "44e6392f-80b1-4a2b-8081-c0004ed3e0fa": {
      "main": [
        [
          {
            "node": "28dce2fb-11e4-4c4a-845c-17d68c857130",
            "type": "main",
            "index": 0
          },
          {
            "node": "dceda5b3-9126-453b-bd6e-01f5ddbc8a60",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d1d70202-6b0e-4ce4-9820-c94109c758ad": {
      "main": [
        [
          {
            "node": "6716f687-198b-4cff-8212-9e6789d597f9",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "c3c88742-1e58-483d-95ee-4fef4fb69104": {
      "main": [
        [],
        [
          {
            "node": "f8b54b91-b743-4d3b-9637-2f769b46a48b",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "70972854-d872-4665-8971-217494646726": {
      "main": [
        [],
        [
          {
            "node": "b77cb27a-f72f-4e79-af4d-c128375b6aef",
            "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 - Redes sociales

¿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.

Información del flujo de trabajo
Nivel de dificultad
Avanzado
Número de nodos27
Categoría1
Tipos de nodos8
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