Automated Restaurant Demand and Inventory Forecasting System using Gemini AI - n8n Workflow

Use this powerful n8n workflow to automate weekly restaurant sales and raw material inventory forecasting. It leverages Google Sheets data and the advanced capabilities of the Gemini AI n8n node for accurate predictions.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Restaurant Owners and Managers seeking to optimize inventory and reduce food waste.

  • Operations Analysts needing reliable weekly demand forecasts automatically.

  • n8n users looking for advanced, practical examples of integrating AI Agents (like Gemini) into business processes.

  • Developers interested in leveraging the n8n workflow platform for custom forecasting solutions.

Overview

Manual forecasting is time-consuming and often inaccurate, leading to high levels of food waste or stock shortages in the restaurant industry. This sophisticated n8n workflow solves this by providing a hands-free, AI-driven prediction system. It is designed as a reusable n8n template that reads historical sales and usage data from Google Sheets, sends this complex dataset to a specialized Gemini AI agent for analysis and prediction, and then logs the resultant forecast back into a Google Sheet while alerting key stakeholders via email.

By leveraging the Google Gemini n8n node, this n8n workflow delivers high accuracy in predicting both future dish sales and the exact required quantities of raw materials, ensuring efficient procurement and minimizing costly human error.

How it Works

This automation is initiated by a specific n8n trigger, the Schedule Trigger, set to run once per week.


  1. Trigger and Data Retrieval: The ‘Trigger Weekly Forecast’ n8n node starts the process weekly. The workflow then uses the ‘Load Historical Sales Data’ Google Sheets n8n node to retrieve all historical sales and inventory usage records from a designated spreadsheet.

  2. Data Preparation: The ‘Format Input for AI Agent’ n8n node, using custom code, aggregates the numerous rows of data into a single, structured JSON payload, optimizing it for the AI Agent input. This is crucial for the forecasting n8n workflow.

  3. AI Forecasting: The core of this n8n workflow is the ‘Generate Forecast with AI’ n8n node (a Langchain AI Agent). It sends the historical data to the configured Chat Model (Gemini 2.5 Pro). The agent is instructed via a detailed system prompt to analyze sales trends, predict the next week's sales for specific dishes, and calculate the corresponding raw material requirements.

  4. Output Interpretation: The AI's response often comes wrapped in markdown format. The ‘Interpret AI Forecast Output’ n8n node utilizes custom JavaScript code to strip away markdown fences (```json) and parse the clean forecast data into a usable JSON object.

  5. Logging Results: The parsed forecast is immediately appended as a new row in the designated ‘prediction data’ sheet using the ‘Log Forecast to Google Sheets’ n8n node.

  6. Notification: Finally, the ‘Email Forecast Summary’ Gmail n8n node sends a detailed email to the manager, including the predicted date and a direct link back to the updated Google Sheet, completing the automated n8n workflow cycle.

Installation Guide

To deploy this comprehensive n8n template, follow these steps:


  1. Import the n8n Workflow: Copy the provided JSON data and import it directly into your n8n instance via the 'New Workflow' > 'Import from JSON' option.

  2. Google Sheets Credentials: This n8n workflow requires a Google Sheets Service Account credential to read historical data and write new predictions. Ensure the service account email has editor access to your target spreadsheet.

  3. Google Gemini Credentials: Configure a credential for the LangChain Chat Model (Google Gemini/PaLM). This requires a valid Gemini API key to allow the AI n8n node to perform the complex data analysis.

  4. Gmail Setup: Set up your Gmail OAuth2 credentials for the ‘Email Forecast Summary’ n8n node. Update the sendTo parameter to the email address of the recipient stakeholder (e.g., your restaurant manager).

  5. Customize Sheets: Update the 'Load Historical Sales Data' and 'Log Forecast to Google Sheets' n8n nodes to point to your specific historical data and prediction sheets/tabs within your designated Google Sheets document ID.

  6. Activate: Save and activate the n8n workflow. The schedule n8n trigger will handle subsequent weekly runs.

Node Details

Trigger Weekly Forecast (Schedule Trigger): This n8n trigger is responsible for initiating the entire automation on a weekly basis, ensuring forecasts are generated consistently for the subsequent week.
Load Historical Sales Data (Google Sheets n8n node): Connects to Google Sheets using a Service Account to fetch raw, historical sales data and material usage required for the AI model.
Format Input for AI Agent (Code n8n node): Executes custom JavaScript to transform the list of rows from Google Sheets into a single JSON object. This structure is critical for efficient processing by the Gemini AI n8n node.
Generate Forecast with AI (Langchain AI Agent n8n node): The core intelligence. It uses the input data and a highly detailed system message to instruct the Gemini 2.5 Pro model to analyze trends and generate a structured JSON forecast, including sales predictions and necessary raw material quantities.
Interpret AI Forecast Output (Code n8n node): Custom code dedicated to cleaning the AI's response, specifically removing common markdown wrappers (like ```json) to extract a clean, parseable JSON object suitable for database logging.
Log Forecast to Google Sheets (Google Sheets n8n node): Appends the clean, AI-generated forecast data to a separate 'prediction data' tab, updating the master record.


  • Email Forecast Summary (Gmail n8n node): Sends a notification email to stakeholders, including key predicted data points and a direct link to the updated Google Sheets document, summarizing the results of the n8n workflow run.

Related n8n Workflows

Free

Nodes: 8 Nodes
Updated: December 26 2025
View all
Created by

The AI Squad Initiative is a pioneering effort to build, automate and scale AI-powered workflows using n8n.io. Our mission is to help individuals and businesses integrate AI agents seamlessly into their daily operations from automating tasks and enhancing productivity to creating innovative, intelligent solutions. We design modular, reusable AI workflow templates that empower creators, developers and teams to supercharge their automation with minimal effort and maximum impact.

Featured*