AutomationFlowsAI & RAG › Predict Restaurant Food Waste with Gemini AI and Google Sheets Reporting

Predict Restaurant Food Waste with Gemini AI and Google Sheets Reporting

ByOneclick AI Squad @oneclick-ai on n8n.io

This automated n8n workflow performs daily forecasting of sales and raw material needs for a restaurant. By analyzing historical data and predicting future usage with AI, businesses can minimize food waste, optimize inventory, and improve operational efficiency. The forecast is…

Cron / scheduled trigger★★★★☆ complexityAI-powered21 nodesGoogle SheetsAgentGmailGoogle Gemini ChatTool Think
AI & RAG Trigger: Cron / scheduled Nodes: 21 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #5982 — we link there as the canonical source.

This workflow follows the Agent → Gmail recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "ER0P5gVPl7ARd3cU",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Restaurant food waste prediction System",
  "tags": [],
  "nodes": [
    {
      "id": "7ecc2319-ee53-4b62-b529-666c82fb88b6",
      "name": "Daily Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -280,
        420
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 22
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "fa199f84-c3da-4e05-867f-20cab560c633",
      "name": "Fetch Historical Sales Data",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -60,
        420
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1621929706,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1QZXX_gjNTTZ0vqPozNysjASQS3UcgwwWVpYvN7r-T_I/edit#gid=1621929706",
          "cachedResultName": "food wastage data"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1QZXX_gjNTTZ0vqPozNysjASQS3UcgwwWVpYvN7r-T_I",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1QZXX_gjNTTZ0vqPozNysjASQS3UcgwwWVpYvN7r-T_I/edit?usp=drivesdk",
          "cachedResultName": "Restaurant stock predictions"
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "d186b482-008a-45b1-a766-963ead9bc4de",
      "name": "Format Data for AI Forecasting",
      "type": "n8n-nodes-base.code",
      "position": [
        160,
        420
      ],
      "parameters": {
        "jsCode": "// Fetch all incoming items\nconst items = $input.all();\n\n// Extract the raw row data (each item.json is one row)\nconst rawRows = items.map(item => item.json);\n\n// Bundle everything into a single field\nconst payload = { rows: rawRows };\n\n// Return a single output item whose json contains your full dataset\nreturn [{ json: { data: payload } }];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "4f401f04-a17e-4dfc-874f-d5e7e0983316",
      "name": "AI Forecast Generator\t",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        380,
        420
      ],
      "parameters": {
        "text": "={{ $json.data }}",
        "options": {
          "systemMessage": "You are a demand forecasting and optimisation AI assistant for a restaurant. \n\nYou will receive data items, each with fields:\n- Date (YYYY-MM-DD)\n- Dish\n- Sales (number of dishes sold)\n- Raw Material\n- Used (kg)\n- Wastage (kg)\n\nYour tasks are:\n1. Analyze the past 5 days per dish and per raw material.\n2. Identify trends (e.g., increasing/decreasing sales, stable/wasteful usage).\n3. Predict next-day sales per dish and raw material usage (in kg) using simple time-series methods (like moving average or linear trend).\n4. Adjust raw material predictions to reduce expected wastage\u2014aim for coverage with ~5% buffer.\n5. Calculate \"predicted food waste reduce\" as: (predicted raw material use) \u2212 (optimal raw material procurement). This indicates how much waste you\u2019re avoiding.\n6. Return output as JSON array with:\n   - Date (next day\u2019s date, YYYY-MM-DD)\n   - Dish\n   - predicted Sales (number)\n   - Raw Material\n   - predicted Use (kg)\n   - predicted food waste reduce (kg)\n\nConstraints:\n- Use clear numerical rounding (one decimal place).\n- Prioritize realistic, small improvements (justified by data).\n\nExample output item:\n{\n  \"Date\": \"2025-07-14\",\n  \"Dish\": \"Pasta\",\n  \"predicted Sales\": 60,\n  \"Raw Material\": \"Tomato\",\n  \"predicted Use (kg)\": 12.0,\n  \"predicted food waste reduce (kg)\": 0.5\n}\n\nWrite a JSON array containing one item per (Dish \u00d7 Raw Material), sorted alphabetically by Dish.\n"
        },
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "c1888087-d468-4f25-bf3d-5b5185e34719",
      "name": "Clean & Structure AI Output",
      "type": "n8n-nodes-base.code",
      "position": [
        760,
        420
      ],
      "parameters": {
        "jsCode": "// 1. Grab the AI agent output (assuming it's in item.json.output or item.json.content)\nconst raw = $input.item.json.output || $input.item.json.content;\n\n// 2. Clean it by removing triple backticks, optional \"json\" tag, and any common prefixes\nlet cleaned = raw\n  .replace(/```json/, '')\n  .replace(/```/g, '')\n  .replace(/^(Here is (the )?JSON[:\\s]*)/, '')\n  .trim();\n\n// 3. Parse JSON safely\nlet parsed;\ntry {\n  parsed = JSON.parse(cleaned);\n} catch (e) {\n  throw new Error('Failed to parse AI JSON: ' + e.message + '\\nRaw cleaned text: ' + cleaned);\n}\n\n// 4. Return each JSON object as its own item for downstream nodes\nreturn parsed.map(obj => ({ json: obj }));\n"
      },
      "typeVersion": 2
    },
    {
      "id": "d766931a-e722-402e-aa88-58c1b39935d5",
      "name": "Log Forecast to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        980,
        420
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [
            {
              "id": "Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Dish",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Dish",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "predicted Sales",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "predicted Sales",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Raw Material",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Raw Material",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "predicted Use (kg)",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "predicted Use (kg)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "predicted food waste reduce (kg)",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "predicted food waste reduce (kg)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1653513259,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1QZXX_gjNTTZ0vqPozNysjASQS3UcgwwWVpYvN7r-T_I/edit#gid=1653513259",
          "cachedResultName": "predicted food data for low wastage"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1QZXX_gjNTTZ0vqPozNysjASQS3UcgwwWVpYvN7r-T_I",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1QZXX_gjNTTZ0vqPozNysjASQS3UcgwwWVpYvN7r-T_I/edit?usp=drivesdk",
          "cachedResultName": "Restaurant stock predictions"
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "a9f91c73-41e6-4955-bbd5-1e9ff658df1e",
      "name": "Create Email Summary\t",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1200,
        420
      ],
      "parameters": {
        "text": "={{ $('AI Forecast Generator\t').item.json.output }}",
        "options": {
          "systemMessage": "You are an intelligent assistant tasked with drafting a clear, concise and professional summary email based on forecast data for a restaurant. You\u2019ll receive an array of forecast objects in this format:\n\n[\n  {\n    \"Date\": \"2025-07-14\",\n    \"Dish\": \"Pasta\",\n    \"predicted Sales\": 60,\n    \"Raw Material\": \"Cream\",\n    \"predicted Use (kg)\": 3.6,\n    \"predicted food waste reduce (kg)\": 0.1\n  },\n  ...\n]\n\nYour goal:\n1. Open with a friendly greeting.\n2. Provide a one-sentence overview: mention the date, how many dishes are forecasted, and overall expected food waste reduction.\n3. List each dish in its own bullet point. For each dish list:\n   - Total predicted sales.\n   - The raw materials needed with predicted usage.\n   - Highlight expected waste reduction (if >0).\n4. Conclude with a recommended action, something like: \u201cPlease adjust tomorrow\u2019s procurement based on these forecasts to minimize waste.\u201d Offer to discuss specifics if needed.\n5. Keep tone professional but warm.\n\nExample style:\n\n\u201cHi [Manager Name],\n\nHere\u2019s your forecast summary for July 14, 2025:\n\n- **Pasta (60 servings):** You will need Cream (3.6\u202fkg), Flour (6\u202fkg) and Tomato (12\u202fkg), reducing expected food waste by approx. 1.9\u202fkg.\n- **Pizza (50 servings):** Cheese 10\u202fkg, waste reduction ~0.5\u202fkg.\n- **Salad (40 servings):** Lettuce 8\u202fkg, no predicted waste reduction.\n\nOverall, this forecast anticipates around 2.4\u202fkg less waste across all dishes.\n\nPlease adjust tomorrow\u2019s orders accordingly to minimize waste. Let me know if you'd like a deeper breakdown!\u201d\n\nReturn only the email body text (no JSON or markdown fences).\n"
        },
        "promptType": "define"
      },
      "executeOnce": true,
      "typeVersion": 1.9,
      "alwaysOutputData": true
    },
    {
      "id": "1c9cec9e-d90b-4479-b569-9ef2726a6987",
      "name": "Send Email Forecast Report\t",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1560,
        420
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "={{ $json.output }}",
        "options": {},
        "subject": "Next monday prediction",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "1f400e94-9bc2-414c-aedc-6f7f86c887d0",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -300,
        140
      ],
      "parameters": {
        "width": 150,
        "height": 480,
        "content": "Initiates the workflow every day to perform food waste prediction.\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "65a5d131-945b-40ee-bf66-b33f4600d97c",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        140
      ],
      "parameters": {
        "color": 3,
        "width": 150,
        "height": 480,
        "content": "Reads past food usage & sales from Google Sheets to understand trends.\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "8cc25bd0-38bf-485a-a75b-7bed2ae24b1e",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        360,
        140
      ],
      "parameters": {
        "color": 6,
        "width": 290,
        "height": 480,
        "content": "Uses Gemini AI to forecast food demand and recommend waste reduction.\n\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "3afb2901-aeaa-49a2-920a-806ce0e5dc9d",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        960,
        140
      ],
      "parameters": {
        "color": 4,
        "width": 150,
        "height": 480,
        "content": "Stores AI-generated forecast back into a forecast-specific Google Sheet.\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "458c1f5e-0a7a-4981-afd6-efc64c286e5d",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        740,
        140
      ],
      "parameters": {
        "color": 3,
        "width": 150,
        "height": 480,
        "content": "Parses AI response into structured and clean format for reporting.\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "5917d966-9260-4ace-baf9-4ecd666021f4",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        140,
        140
      ],
      "parameters": {
        "color": 4,
        "width": 150,
        "height": 480,
        "content": "Cleans and organizes raw data into a structure suitable for AI processing.\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "16b34b52-3d0e-4dc5-95eb-8eaecd7fdfa3",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1540,
        140
      ],
      "parameters": {
        "width": 150,
        "height": 480,
        "content": "Delivers the forecast report via email to decision-makers (kitchen, manager, etc).\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "08d6406a-b9ef-4b10-90cf-7d4c98a60921",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1180,
        140
      ],
      "parameters": {
        "color": 5,
        "width": 290,
        "height": 480,
        "content": "Creates a concise, human-friendly summary of the forecast.\n\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "5a088b10-604f-475f-a611-3b147ae9ce0c",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        220,
        -340
      ],
      "parameters": {
        "width": 640,
        "height": 260,
        "content": "## \ud83d\udccc Workflow Purpose: Restaurant Food Waste Prediction System\n\nThis workflow automates daily forecasting of sales and raw material needs for a restaurant. By analyzing historical data and predicting future usage with AI, it helps minimize food waste, optimize inventory, and improve operational efficiency. The forecast is stored in Google Sheets and sent via email for easy review by staff and management."
      },
      "typeVersion": 1
    },
    {
      "id": "28b4b3dc-5e7c-41a7-8dda-4cf67eacef0a",
      "name": "Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        400,
        640
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.5-pro"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f0e9f8d4-4a86-4167-b833-5ac3ab3a5545",
      "name": "Mind",
      "type": "@n8n/n8n-nodes-langchain.toolThink",
      "position": [
        520,
        640
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "f7e04c0c-cba5-46f4-bc47-fb26731f2375",
      "name": "Chat Model for Query ",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1220,
        640
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.5-pro"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "dbddf020-ef31-43b4-85a9-3f459ac56d6b",
      "name": "Mind For Think",
      "type": "@n8n/n8n-nodes-langchain.toolThink",
      "position": [
        1340,
        640
      ],
      "parameters": {},
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "f6380285-b1c9-49e1-82bf-12c2db027369",
  "connections": {
    "Mind": {
      "ai_tool": [
        [
          {
            "node": "AI Forecast Generator\t",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Forecast Generator\t",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Daily Trigger": {
      "main": [
        [
          {
            "node": "Fetch Historical Sales Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mind For Think": {
      "ai_tool": [
        [
          {
            "node": "Create Email Summary\t",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Chat Model for Query ": {
      "ai_languageModel": [
        [
          {
            "node": "Create Email Summary\t",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Create Email Summary\t": {
      "main": [
        [
          {
            "node": "Send Email Forecast Report\t",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Forecast Generator\t": {
      "main": [
        [
          {
            "node": "Clean & Structure AI Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean & Structure AI Output": {
      "main": [
        [
          {
            "node": "Log Forecast to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Historical Sales Data": {
      "main": [
        [
          {
            "node": "Format Data for AI Forecasting",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Forecast to Google Sheets": {
      "main": [
        [
          {
            "node": "Create Email Summary\t",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Data for AI Forecasting": {
      "main": [
        [
          {
            "node": "AI Forecast Generator\t",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This automated n8n workflow performs daily forecasting of sales and raw material needs for a restaurant. By analyzing historical data and predicting future usage with AI, businesses can minimize food waste, optimize inventory, and improve operational efficiency. The forecast is…

Source: https://n8n.io/workflows/5982/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

In this guide, we’ll walk you through setting up an AI-driven workflow that automatically fetches daily sales, food waste, and customer feedback data from Google Sheets, generates actionable insights

Google Gemini Chat, Tool Think, Google Sheets +2
AI & RAG

This automated n8n workflow performs weekly forecasting of restaurant sales and raw material requirements using historical data from Google Sheets and AI predictions powered by Google Gemini. The fore

Google Sheets, Agent, Tool Think +2
AI & RAG

The Multi-Model Agency Content Engine is a high-performance editorial system designed for agencies. It solves the "blank page" problem by alternating between real-world social proof and strategic expe

Google Sheets, Gmail, Google Drive +6
AI & RAG

kisisel asistan. Uses toolWorkflow, toolHttpRequest, toolCalculator, toolThink. Scheduled trigger; 43 nodes.

Tool Workflow, Tool Http Request, Tool Calculator +15
AI & RAG

This workflow helps you find and evaluate job opportunities automatically, without spending hours searching and comparing roles. It uses your resume to look for relevant jobs on LinkedIn, checks how w

Google Drive, HTTP Request, Google Gemini Chat +3