CORTEXFLOW · FREE FOREVER

Automation

Multi-Store Sales Consolidator

↓ Download workflow JSON

Import in n8n: Workflows → ⋯ → Import from file, then add your credentials. Free download with a free account.

How it works

Your Monday-morning sales briefing, fully automatic:

  1. STEP 1 — Weekly trigger + config + NEW log — the “Weekly Monday Trigger” fires every Monday at 8:00 AM. “CONFIG — Store Settings” holds every editable value (owner email, spreadsheet ID, Drive folder ID, per-store tab names, anomaly threshold). The run is logged to the Report Runs tab with status NEW.
  2. STEP 2 — List store sheets + prepare store list — “List Store Sheets — Google Drive” lists every spreadsheet in your configured Drive folder (one per store). “Prepare Store List” maps each file to a store name (from the file name) plus its sales tab, and “IF — Sheets Found” stops cleanly when the folder is empty.
  3. STEP 3 — Loop stores: read, tag, consolidate — “Loop Stores — Split In Batches” processes one store at a time: “Read Store Sheet” reads that store’s sales tab, “Tag Rows — Add Store Name” stamps every row with the store, and “Append Consolidated Rows” appends them to the Consolidated Sales sheet.
  4. STEP 4 — Aggregate totals + WoW + PROCESSING — “Read Consolidated Rows — This Week” pulls the consolidated rows, then “Compute Weekly Totals” calculates per-store revenue, units sold, the top 5 items, and week-over-week changes (this week vs last week). The run flips to PROCESSING in the log.
  5. STEP 5 — AI weekly analyst — “AI Agent — Weekly Sales Analyst” (gpt-4o-mini) reads the totals and, via the “Structured Output Parser — Sales Insights”, returns {total_revenue, revenue_wow_change_pct, per_store, top_items, insights, red_flags}.
  6. STEP 6 — Anomaly check → Telegram alert — “IF — Revenue Anomaly” compares |week-over-week revenue change| against your revenue_anomaly_threshold_pct. A swing past the threshold fires an instant “Telegram — Anomaly Alert” with the red flags. Both branches continue to the report.
  7. STEP 7 — HTML report → Gmail → DONE → Telegram — “Build Report HTML” renders the owner email (per-store table, top items, AI insights, red flags), “Gmail — Send Weekly Report” emails it to you, the log flips to DONE, and “Telegram — Success Notification” confirms with the headline numbers.
  8. STEP 8 — Failure path — if no store sheets are found, the run is logged as FAILED and “Telegram — Failure Alert” tells you to check the Drive folder ID.

Status flow in Sheets (Report Runs tab): NEW → PROCESSING → DONE (or FAILED when no store sheets are found)

Set up steps

You’ll need:

  • n8n (self-hosted or cloud) — n8n.io
  • Google Sheets + Google Drive OAuth2 credentials — n8n Credentials → Google Sheets OAuth2 / Google Drive OAuth2
  • An OpenAI API key — platform.openai.com/signup → API keys
  • Gmail OAuth2 credential — n8n Credentials → Gmail OAuth2 (send the report from your own account)
  • A Telegram bot — telegram.org → message @BotFather, send /newbot, copy the token; get your chat ID from @userinfobot

Steps:

  1. Import the workflow — in n8n, Workflows → Import from File → select multi-store-sales-consolidator.json.
  2. Prepare your store sheets — in Google Drive, create one spreadsheet per store inside a single folder (the file name becomes the store name). Each sheet needs a tab with exactly these headers: Date | Item | Qty | Revenue. Share every sheet with the Google account connected to n8n.
  3. Create the log workbook — make a Google Sheet with two tabs:
    • Report Runs with headers: Run Date | Week Of | Status | Stores | Total Revenue | Notes
    • Consolidated Sales with headers: Date | Store | Item | Qty | Revenue
  4. CONFIG — Store Settings — open the Set node and fill in:
    • owner_email — where the weekly HTML report goes
    • spreadsheet_id — the log workbook’s ID (from its URL)
    • sales_drive_folder_id — the Drive folder ID containing one spreadsheet per store (from its URL)
    • store_sheet_tabs — comma-separated tab names, one per store in file order (e.g. Weekly Sales)
    • revenue_anomaly_threshold_pct — alert when |week-over-week revenue change| hits this % (default 15)
    • telegram_chat_id — your Telegram chat ID
    • log_sheet_name / consolidated_sheet_name — only change if you renamed the tabs in step 3
  5. Credentials — select your Google Sheets credential in all seven Sheets nodes, your Google Drive credential in “List Store Sheets — Google Drive”, your OpenAI credential in “OpenAI Chat Model — Analyst”, your Gmail credential in “Gmail — Send Weekly Report”, and your Telegram credential in both Telegram nodes (or use the credential prompt on import). Then activate the workflow.

Customize it

  • Schedule — “Weekly Monday Trigger” runs Mondays at 8:00 AM; change the weekday or time for your reporting cadence (daily runs work too — the WoW logic keys off whatever day it runs).
  • Anomaly sensitivity — raise or lower revenue_anomaly_threshold_pct in “CONFIG — Store Settings” (10 for twitchy, 25 for only real fires).
  • More stores, no changes — drop another store spreadsheet in the Drive folder and it gets picked up automatically next run. Store name comes from the file name, so name files like Downtown.xlsx / Airport Mall.xlsx.
  • Report branding — edit the HTML template in “Build Report HTML” to add your logo, currency symbols, or a section linking back to the Consolidated Sales sheet.
  • AI depth — the system prompt in “AI Agent — Weekly Sales Analyst” is your analyst’s brief: add margin targets, promo calendars, or “compare against last month too” and the structured output keeps the report format stable.
  • Sell it — this is the classic agency product the YouTube crowd keeps pitching: clone the workflow per retail client, swap the one CONFIG node, point it at their Drive folder, done.

Workflow nodes

This workflow is built from 24 nodes. Here's what each one does:

#NodeTypeWhat it does
1 Weekly Monday Trigger Schedule Trigger Starts the workflow automatically on a schedule.
2 CONFIG — Store Settings Set Holds editable configuration values — fill in your own settings here before activating.
3 Log Run — Status NEW Google Sheets Reads from or writes to a Google Sheet — this workflow's log and state store.
4 List Store Sheets — Google Drive Google Drive Uploads, downloads, or manages files in Google Drive.
5 Prepare Store List Code Runs custom JavaScript to transform, filter, or compute data between steps.
6 IF — Sheets Found IF Splits the flow into branches based on a condition.
7 Loop Stores — Split In Batches Split In Batches Processes a long list of items in small batches.
8 Read Store Sheet Google Sheets Reads from or writes to a Google Sheet — this workflow's log and state store.
9 Tag Rows — Add Store Name Code Runs custom JavaScript to transform, filter, or compute data between steps.
10 Append Consolidated Rows Google Sheets Reads from or writes to a Google Sheet — this workflow's log and state store.
11 Read Consolidated Rows — This Week Google Sheets Reads from or writes to a Google Sheet — this workflow's log and state store.
12 Compute Weekly Totals Code Runs custom JavaScript to transform, filter, or compute data between steps.
13 Log Run — Status PROCESSING Google Sheets Reads from or writes to a Google Sheet — this workflow's log and state store.
14 AI Agent — Weekly Sales Analyst AI Agent The AI brain — reasons over the task and calls tools to get it done.
15 OpenAI Chat Model — Analyst OpenAI Chat Model The language model powering the AI agent.
16 Structured Output Parser — Sales Insights Structured Output Parser Forces the AI to return clean, structured JSON instead of free text.
17 IF — Revenue Anomaly IF Splits the flow into branches based on a condition.
18 Telegram — Anomaly Alert Telegram Sends you a Telegram message or alert.
19 Build Report HTML Code Runs custom JavaScript to transform, filter, or compute data between steps.
20 Gmail — Send Weekly Report Gmail Sends or reads email through your Gmail account.
21 Log Run — Status DONE Google Sheets Reads from or writes to a Google Sheet — this workflow's log and state store.
22 Telegram — Success Notification Telegram Sends you a Telegram message or alert.
23 Log Run — Status FAILED Google Sheets Reads from or writes to a Google Sheet — this workflow's log and state store.
24 Telegram — Failure Alert Telegram Sends you a Telegram message or alert.

Setup instructions

1. Add your credentials

In n8n go to Credentials → New, create each credential below, then open the named node and select it:

NodeCredential to add
Log Run — Status NEW Google Sheets OAuth2
List Store Sheets — Google Drive Google Drive OAuth2
Read Store Sheet Google Sheets OAuth2
Append Consolidated Rows Google Sheets OAuth2
Read Consolidated Rows — This Week Google Sheets OAuth2
Log Run — Status PROCESSING Google Sheets OAuth2
OpenAI Chat Model — Analyst OpenAI API
Telegram — Anomaly Alert Telegram Bot API
Gmail — Send Weekly Report Gmail OAuth2
Log Run — Status DONE Google Sheets OAuth2
Telegram — Success Notification Telegram Bot API
Log Run — Status FAILED Google Sheets OAuth2
Telegram — Failure Alert Telegram Bot API

2. Fill in your config values

Open the config node listed below and replace each placeholder with your own value before activating the workflow:

NodeFieldWhat to paste
CONFIG — Store Settings owner_email PASTE_YOUR_OWNER_EMAIL
Your owner email
CONFIG — Store Settings spreadsheet_id PASTE_YOUR_SPREADSHEET_ID
Your spreadsheet id
CONFIG — Store Settings sales_drive_folder_id PASTE_YOUR_GOOGLE_DRIVE_FOLDER_ID
Your google drive folder id
CONFIG — Store Settings telegram_chat_id PASTE_YOUR_TELEGRAM_CHAT_ID
Your telegram chat id

How this workflow starts

  • Schedule Trigger: Runs every weeks.

Use cases

Owners of multi-location businesses live in spreadsheet chaos: five stores, five sales files, and a Sunday evening spent copy-pasting them into one place. This template does that job every Monday at 8 AM without anyone touching it. It lists every store spreadsheet in a Google Drive folder, reads each store's sales tab one at a time, tags every row with its store name, and consolidates everything into a single sheet. Then it computes per-store revenue, units, top items, and week-over-week changes, lets an AI analyst write up the insights, and emails you a formatted HTML report — with an instant Telegram alert if revenue swings past your anomaly threshold.

The coffee shop owner with six locations

Maya owns six coffee shops and used to spend her Monday mornings stitching together six different sales exports. Now she drops one spreadsheet per shop into a Drive folder — the file name becomes the store name automatically — and the Weekly Monday Trigger does the rest. The Loop Stores node processes each shop in turn, Tag Rows stamps every line with its store, and the consolidated data feeds Compute Weekly Totals for per-store revenue and week-over-week change. Practical tip: set revenue_anomaly_threshold_pct to 10 in the CONFIG node if you want to hear about every wobble, or 25 if you only want real fires — the Telegram Anomaly Alert fires the moment the swing crosses your number.

The car wash franchise manager reporting to investors

A franchise group with eight car washes needs the same numbers every week for its investor update. The Build Report HTML node renders a per-store table, top items, AI insights, and red flags into one email that the Gmail node sends to the owner, while the Report Runs log tracks every execution from NEW to PROCESSING to DONE. Practical tip: edit the HTML template in Build Report HTML to add your brand colors and a link back to the Consolidated Sales sheet, so the weekly email doubles as your investor-ready report with one click.

The convenience store owner catching shrinkage early

When revenue at one location quietly drops 20 percent, it can be theft, a broken register, or a staffing problem — but only if you notice. The AI Agent — Weekly Sales Analyst reads the totals through a Structured Output Parser and returns red_flags alongside the headline numbers, and the IF — Revenue Anomaly node compares the absolute week-over-week change against your threshold. A swing past it fires the Telegram alert immediately, before the Monday report even lands. Practical tip: add a line to the analyst's system prompt like "flag any store whose top items changed unusually fast" and the structured output will surface suspicious shifts in the same stable format.

The restaurant group deciding the menu

For a three-location restaurant group, the top 5 items calculation is more than a vanity metric — it drives purchasing and menu decisions. Compute Weekly Totals pulls the top items across the consolidated data, and the AI analyst's insights section puts them in context against last week's numbers. When a dish falls out of the top five two weeks running, the owner sees it in Monday's email instead of discovering it in a quarterly review. Practical tip: drop another store spreadsheet into the Drive folder and it is picked up automatically on the next run, so adding a fourth location requires zero workflow changes.

The agency selling weekly reporting as a service

Retail reporting is a proven agency product, and this workflow is built to be cloned: one CONFIG node holds the owner email, spreadsheet ID, Drive folder ID, tab names, anomaly threshold, and Telegram chat ID. Point a new client at their own Drive folder and their Monday report just works. Practical tip: change the Weekly Monday Trigger to a daily schedule for clients who want tighter control — the week-over-week logic keys off whatever day it runs, and the Telegram success notification gives them headline numbers every morning.

← All templates