End-of-day orders summary on Telegram

Every night, get today's orders, revenue, cash-on-delivery share and top products from your Orders sheet.

Easy Saves ~3 hours/month E-commerceBy Flowngn team

Works with n8n · Make · Zapier

How it works

Trigger: Schedule — every day at 23:00
  1. Read your Orders sheet.
  2. Keep today's orders and add up the count and revenue.
  3. Work out how many were cash on delivery and the top 3 products.
  4. Send the summary to Telegram.

Diagram

Every day 23:00Schedule TriggerGRead ordersGoogle Sheets{ }Summarize todayCodeTSend to TelegramTelegram
Trigger App Code

Code

JavaScript used in the Code step — already included in the template below.

Summarize today · Code node
// Orders sheet columns: date | order_id | customer | phone | city | items | total | payment
// Adds up today's orders and builds a short Telegram message.
const today = new Date().toISOString().slice(0, 10);
const orders = $input.all()
  .map((item) => item.json)
  .filter((o) => String(o.date).slice(0, 10) === today);

const revenue = orders.reduce((sum, o) => sum + (Number(o.total) || 0), 0);
const cod = orders.filter((o) => /cod|cash/i.test(String(o.payment))).length;

// items look like "2× Black abaya، 1× Scarf"
const counts = {};
for (const o of orders) {
  for (const part of String(o.items || "").split(/[,،]/)) {
    const m = part.trim().match(/^(\d+)\s*[×x]\s*(.+)$/);
    if (m) counts[m[2]] = (counts[m[2]] || 0) + Number(m[1]);
  }
}
const top = Object.entries(counts)
  .sort((a, b) => b[1] - a[1])
  .slice(0, 3)
  .map(([name, qty]) => `- ${name}: ${qty}`)
  .join("\n");

return [{
  json: {
    message:
      `Orders today (${today}): ${orders.length}\n` +
      `Revenue: ${revenue.toLocaleString("en-US")}\n` +
      `Cash on delivery: ${cod} of ${orders.length}` +
      (top ? `\n\nTop products:\n${top}` : ""),
  },
}];

Build it

Pick your tool — same automation, step by step.

Copy and paste straight into an n8n canvas (Ctrl+V), or download and use Import from File. Then connect your own credentials and replace every YOUR_… placeholder.

Workflow JSON
Show code (136 lines)
{
  "name": "End-of-day orders summary on Telegram (Flowngn)",
  "nodes": [
    {
      "parameters": {
        "content": "## End-of-day orders summary on Telegram\nEvery night, get today's orders, revenue, cash-on-delivery share and top products from your Orders sheet.\n\n**Setup**\n1. Open each node and connect your own credentials.\n2. Replace every YOUR_… placeholder.\n3. Test once, then activate.\n\nFree template from Flowngn",
        "height": 260,
        "width": 340
      },
      "id": "2473c6c3-ba78-4235-a758-cbde9e312b58",
      "name": "Setup notes",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -420,
        -60
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 23
            }
          ]
        }
      },
      "id": "2473c6c3-ba78-4235-a758-cbde9e312b58",
      "name": "Every day 23:00",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "operation": "read",
        "documentId": {
          "__rl": true,
          "value": "YOUR_SPREADSHEET_ID",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "Orders",
          "mode": "name"
        },
        "options": {}
      },
      "id": "2473c6c3-ba78-4235-a758-cbde9e312b58",
      "name": "Read orders",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        300,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "// Orders sheet columns: date | order_id | customer | phone | city | items | total | payment\n// Adds up today's orders and builds a short Telegram message.\nconst today = new Date().toISOString().slice(0, 10);\nconst orders = $input.all()\n  .map((item) => item.json)\n  .filter((o) => String(o.date).slice(0, 10) === today);\n\nconst revenue = orders.reduce((sum, o) => sum + (Number(o.total) || 0), 0);\nconst cod = orders.filter((o) => /cod|cash/i.test(String(o.payment))).length;\n\n// items look like \"2× Black abaya، 1× Scarf\"\nconst counts = {};\nfor (const o of orders) {\n  for (const part of String(o.items || \"\").split(/[,،]/)) {\n    const m = part.trim().match(/^(\\d+)\\s*[×x]\\s*(.+)$/);\n    if (m) counts[m[2]] = (counts[m[2]] || 0) + Number(m[1]);\n  }\n}\nconst top = Object.entries(counts)\n  .sort((a, b) => b[1] - a[1])\n  .slice(0, 3)\n  .map(([name, qty]) => `- ${name}: ${qty}`)\n  .join(\"\\n\");\n\nreturn [{\n  json: {\n    message:\n      `Orders today (${today}): ${orders.length}\\n` +\n      `Revenue: ${revenue.toLocaleString(\"en-US\")}\\n` +\n      `Cash on delivery: ${cod} of ${orders.length}` +\n      (top ? `\\n\\nTop products:\\n${top}` : \"\"),\n  },\n}];"
      },
      "id": "2473c6c3-ba78-4235-a758-cbde9e312b58",
      "name": "Summarize today",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        600,
        0
      ]
    },
    {
      "parameters": {
        "chatId": "YOUR_CHAT_ID",
        "text": "={{ $json.message }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "id": "2473c6c3-ba78-4235-a758-cbde9e312b58",
      "name": "Send to Telegram",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        900,
        0
      ]
    }
  ],
  "connections": {
    "Every day 23:00": {
      "main": [
        [
          {
            "node": "Read orders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read orders": {
      "main": [
        [
          {
            "node": "Summarize today",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Summarize today": {
      "main": [
        [
          {
            "node": "Send to Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": []
}

Open in the playground to edit →

Tips

  • Pair it with the "orders to Google Sheets" flows for Salla, Zid or WooCommerce, which use the same columns.

Related flows