{
  "name": "Chat with the news",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "low-stock-alert",
        "options": {}
      },
      "id": "8e352d59-f026-480e-8ac1-9f6bbbb35ba3",
      "name": "Low Stock Alert Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        240,
        304
      ]
    },
    {
      "parameters": {
        "chatId": "1359948065",
        "text": "=\ud83d\udea8 Low Stock Alert\n\nProduct: {{ $('Route by Priority').item.json.body.productName }}\nCurrent Stock: {{ $('Route by Priority').item.json.body.currentStock }}\nMinimum: {{ $('Route by Priority').item.json.body.minimumThreshold }}\nPriority: {{ $('Route by Priority').item.json.body.priority }}",
        "additionalFields": {}
      },
      "id": "b3bb84bc-aa71-413c-9af4-09b55274cccc",
      "name": "Send Telegram Alert",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        496,
        304
      ],
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "triggerAtDay": [
                1
              ],
              "triggerAtHour": 8
            }
          ]
        }
      },
      "id": "70d0de1d-1d99-4311-a00b-9d4472a95210",
      "name": "Weekly Schedule",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.3,
      "position": [
        240,
        624
      ]
    },
    {
      "parameters": {
        "url": "https://jsonplaceholder.typicode.com/posts",
        "options": {}
      },
      "id": "04a4ef5c-93f9-4455-a8b8-7bb1bc629e88",
      "name": "Fetch Report Source 1",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        464,
        528
      ]
    },
    {
      "parameters": {
        "mode": "combine",
        "combineBy": "combineByPosition",
        "options": {}
      },
      "id": "0a6c4989-e0e8-4bd4-b435-6796e0207647",
      "name": "Combine Reports",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        688,
        624
      ]
    },
    {
      "parameters": {
        "url": "https://jsonplaceholder.typicode.com/posts",
        "options": {}
      },
      "id": "0137021f-29e6-49b9-9cc0-ca20140c9675",
      "name": "Fetch Report Source 2",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        464,
        720
      ],
      "executeOnce": true
    },
    {
      "parameters": {
        "html": "<html>\n<head><style>body { font-family: Arial, sans-serif; } table { border-collapse: collapse; width: 100%; } th, td { border: 1px solid #ddd; padding: 8px; text-align: left; } th { background-color: #4CAF50; color: white; }</style></head>\n<body>\n<h1>Weekly Inventory Report</h1>\n<h2>Inventory Status</h2>\n<table>\n<tr><th>Metric</th><th>Value</th></tr>\n<tr><td>Total Products</td><td>{{ $json.totalProducts }}</td></tr>\n<tr><td>Low Stock Items</td><td>{{ $json.lowStockItems }}</td></tr>\n<tr><td>Out of Stock</td><td>{{ $json.outOfStock }}</td></tr>\n</table>\n<h2>Weekly Movements</h2>\n<table>\n<tr><th>Metric</th><th>Value</th></tr>\n<tr><td>Total Movements</td><td>{{ $json.weeklyMovements }}</td></tr>\n<tr><td>Inbound</td><td>{{ $json.inbound }}</td></tr>\n<tr><td>Outbound</td><td>{{ $json.outbound }}</td></tr>\n</table>\n</body>\n</html>"
      },
      "id": "2823d972-3a91-459a-9103-ff6780babb8e",
      "name": "Format Report HTML",
      "type": "n8n-nodes-base.html",
      "typeVersion": 1.2,
      "position": [
        912,
        624
      ]
    },
    {
      "parameters": {
        "fromEmail": "inventory@company.com",
        "toEmail": "<__PLACEHOLDER_VALUE__Report recipient email (e.g., management@company.com)__>",
        "subject": "=Weekly Inventory Report - {{ $now.toFormat(\"MMMM d, yyyy\") }}",
        "html": "={{ $json.html }}",
        "options": {}
      },
      "id": "2ae4bc3c-9bd4-428a-a641-d4f723deacbf",
      "name": "Email Weekly Report",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2.1,
      "position": [
        1136,
        624
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "purchase-order",
        "options": {}
      },
      "id": "a5d859b8-2667-490c-adb2-996cdd697996",
      "name": "Purchase Order Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        240,
        944
      ]
    },
    {
      "parameters": {
        "mode": "markdownToHtml",
        "markdown": "=# Purchase Order\n\n**Order ID:** {{ $json.body.orderId }}\n**Date:** {{ $json.body.orderDate }}\n**Supplier:** {{ $json.body.supplier }}\n\n## Items\n\n{% for item in $json.body.items %}\n- {{ item.productName }}: {{ item.quantity }} units @ ${{ item.unitPrice }}\n{% endfor %}\n\n**Total Amount:** ${{ $json.body.totalAmount }}",
        "destinationKey": "htmlContent",
        "options": {}
      },
      "id": "cd6c05e5-fc8a-4ac0-b941-dbf8e4388e3b",
      "name": "Format Purchase Order",
      "type": "n8n-nodes-base.markdown",
      "typeVersion": 1,
      "position": [
        464,
        944
      ]
    },
    {
      "parameters": {
        "operation": "html",
        "binaryPropertyName": "purchaseOrder",
        "options": {
          "fileName": "=PO_{{ $json.body.orderId }}.pdf"
        }
      },
      "id": "8a8343d7-97de-4fa1-a606-cdfa76da41b2",
      "name": "Convert to PDF",
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        688,
        944
      ]
    },
    {
      "parameters": {
        "fromEmail": "purchasing@company.com",
        "toEmail": "={{ $json.body.supplierEmail }}",
        "subject": "=Purchase Order {{ $json.body.orderId }}",
        "html": "=<p>Dear Supplier,</p>\n<p>Please find attached our purchase order {{ $json.body.orderId }}.</p>\n<p>Best regards,<br>Purchasing Department</p>",
        "options": {
          "attachments": "purchaseOrder"
        }
      },
      "id": "2acb74c0-2bd1-4cc3-928d-4bdbc6dbc7e6",
      "name": "Email Purchase Order",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2.1,
      "position": [
        912,
        944
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "inventory-movement",
        "options": {}
      },
      "id": "ebe86b31-b6f0-4f19-992b-5cfbeae65f39",
      "name": "Movement Registration Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        240,
        1168
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "1",
              "name": "Movement ID",
              "value": "={{ $json.body.movementId }}",
              "type": "string"
            },
            {
              "id": "2",
              "name": "Product ID",
              "value": "={{ $json.body.productId }}",
              "type": "string"
            },
            {
              "id": "3",
              "name": "Product Name",
              "value": "={{ $json.body.productName }}",
              "type": "string"
            },
            {
              "id": "4",
              "name": "Movement Type",
              "value": "={{ $json.body.movementType }}",
              "type": "string"
            },
            {
              "id": "5",
              "name": "Quantity",
              "value": "={{ $json.body.quantity }}",
              "type": "number"
            },
            {
              "id": "6",
              "name": "Timestamp",
              "value": "={{ $json.body.timestamp }}",
              "type": "string"
            },
            {
              "id": "7",
              "name": "Location",
              "value": "={{ $json.body.location }}",
              "type": "string"
            },
            {
              "id": "8",
              "name": "Operator",
              "value": "={{ $json.body.operator }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "82f0e159-a9ef-419d-ab6e-b813e85f46e4",
      "name": "Format Movement Data",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        464,
        1168
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "1bGiMslX9ZXmbELtXiqq35Lt0CCNQUH0s4ycKUWJRHAg",
          "mode": "list",
          "cachedResultName": "Hoja de c\u00e1lculo sin t\u00edtulo",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bGiMslX9ZXmbELtXiqq35Lt0CCNQUH0s4ycKUWJRHAg/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultName": "Movements"
        }
      },
      "id": "a88dfa11-a3b7-4671-b8b0-71080a22bbc8",
      "name": "Append to Movement Log",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        688,
        1168
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 23,
              "triggerAtMinute": 59
            }
          ]
        }
      },
      "id": "b29237c1-2bb1-4e93-ac07-780a21648867",
      "name": "Daily Snapshot Schedule",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.3,
      "position": [
        240,
        1392
      ]
    },
    {
      "parameters": {
        "url": "https://jsonplaceholder.typicode.com/posts",
        "options": {}
      },
      "id": "b51332e0-4bf8-49d1-ab61-4da56a23d913",
      "name": "Fetch Inventory Snapshot",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        464,
        1392
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "1bGiMslX9ZXmbELtXiqq35Lt0CCNQUH0s4ycKUWJRHAg",
          "mode": "list",
          "cachedResultName": "Hoja de c\u00e1lculo sin t\u00edtulo",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bGiMslX9ZXmbELtXiqq35Lt0CCNQUH0s4ycKUWJRHAg/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultName": "Daily Snapshots"
        }
      },
      "id": "da4cc85e-cf58-4250-a87f-9880c3d004bf",
      "name": "Update Inventory Trends",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        688,
        1392
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Low Stock Alert Webhook": {
      "main": [
        [
          {
            "node": "Send Telegram Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Weekly Schedule": {
      "main": [
        [
          {
            "node": "Fetch Report Source 1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch Report Source 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Report Source 1": {
      "main": [
        [
          {
            "node": "Combine Reports",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine Reports": {
      "main": [
        [
          {
            "node": "Format Report HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Report Source 2": {
      "main": [
        [
          {
            "node": "Combine Reports",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Format Report HTML": {
      "main": [
        [
          {
            "node": "Email Weekly Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Purchase Order Webhook": {
      "main": [
        [
          {
            "node": "Format Purchase Order",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Purchase Order": {
      "main": [
        [
          {
            "node": "Convert to PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to PDF": {
      "main": [
        [
          {
            "node": "Email Purchase Order",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Movement Registration Webhook": {
      "main": [
        [
          {
            "node": "Format Movement Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Movement Data": {
      "main": [
        [
          {
            "node": "Append to Movement Log",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily Snapshot Schedule": {
      "main": [
        [
          {
            "node": "Fetch Inventory Snapshot",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Inventory Snapshot": {
      "main": [
        [
          {
            "node": "Update Inventory Trends",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "versionId": "510c9f37-6d10-4df8-81d7-11d75df5c7b3",
  "meta": {
    "templateId": "ready-to-run-ai-workflow-v5"
  },
  "id": "CFeqpS7HxIlsj4AW",
  "tags": []
}