Automated Pharmacy Inventory Alerts using Google Sheets - n8n Workflow

Monitor pharmacy inventory automatically. Use this specialized n8n workflow to check Google Sheets daily for low stock and expiring medicine, sending immediate email alerts to ensure safety and compliance.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Pharmacists and Pharmacy Managers who need reliable daily inventory status.
Operations teams looking for proven n8n templates to automate compliance checks.
Businesses using Google Sheets as a primary inventory control system.
Anyone needing an automated n8n solution for monitoring time-sensitive data.

Overview

Managing pharmaceutical inventory requires precision, especially regarding stock levels and expiry dates. Relying on manual checks is error-prone and inefficient. This powerful n8n workflow provides a robust automation solution. By connecting directly to your Google Sheets inventory database, this n8n template runs a detailed analysis daily. The core automation logic swiftly identifies items that are below a customizable stock threshold (default 10 units) or due to expire within 30 days (or are already expired). The result is a consolidated, actionable email alert sent automatically. This specific n8n workflow ensures timely replenishment, minimizes waste, and crucially, maintains patient safety by preventing the dispensing of outdated medications. It serves as a perfect example of a scheduled n8n node automation.

How it Works

The entire process is initiated by an internal n8n trigger, scheduled to run every morning.


  1. Scheduled Activation: The workflow begins with the Daily Stock Check n8n trigger, configured to run automatically at 9 AM daily.

  2. Data Retrieval: The Fetch Stock Data n8n node connects to the designated Google Sheet, pulling the entire inventory record set (columns A:E).

  3. Data Synchronization: A Wait For All Data n8n node ensures that the subsequent processing steps only execute once all data items have been successfully loaded.

  4. Core Analysis (Custom Code): The Check Expiry Date and Low Stock custom code n8n node performs the crucial business logic. It iterates through each inventory item, checking if the stockquantity is less than the defined threshold (default 10) and calculates if the expirydate is within a 30-day warning window. It compiles separate markdown lists for low stock and expiry alerts.

  5. Logging Results: The Update Google Sheet n8n node is intended to log the status of the generated alerts back into the inventory sheet, providing a historical record of notifications.

  6. Notification: The final step uses the Send Email Alert n8n node to construct a detailed email containing the summarized lowStockList and expiryList. This critical n8n workflow step ensures that the pharmacist receives timely, actionable intelligence.

Installation Guide

To deploy this powerful n8n workflow, follow these steps:


  1. Import: Copy the provided n8n workflow JSON into your n8n instance using the 'New' -> 'Import from JSON' feature.

  2. Google Sheets Credential Setup: This n8n workflow requires Google Sheets Service Account credentials to read and write data. Ensure these credentials are set up and linked to both Google Sheets n8n node instances.

  3. Sheet ID Replacement: In both the Fetch Stock Data and Update Google Sheet n8n node parameters, replace {{yourgooglesheet_id}} with the actual ID of your pharmacy inventory spreadsheet.

  4. SMTP Setup: Configure SMTP credentials and link them to the Send Email Alert n8n node to enable outgoing notifications.

  5. Email Configuration: Update the toEmail parameter in the Send Email Alert n8n node to the actual email address of the pharmacist or manager.

  6. Activate: Save and activate the n8n workflow. The cron n8n trigger will handle the daily execution automatically.

Node Details

Daily Stock Check (Cron n8n trigger):
Function: Serves as the automated n8n trigger, initiating the entire process on a schedule.
Key Configuration: Runs daily at 9:00 AM.
Fetch Stock Data (Google Sheets n8n node):
Function: Connects to the inventory database (Google Sheet) and retrieves the required data range.
Key Configuration: Operation set to 'Get All' rows from PharmacyInventory!A:E.
Check Expiry Date and Low Stock (Code n8n node):
Function: Executes custom JavaScript logic to determine which items require alerts based on stock thresholds (default 10) and expiry dates (30-day warning).
Key Configuration: Creates lowStockList and expiryList variables, which are then used to populate the email content in a subsequent n8n node.
Update Google Sheet (Google Sheets n8n node):
Function: Intended to write metadata back to the sheet, such as alert timestamps or status updates, ensuring the Google Sheet remains synchronized with the n8n workflow's actions.
Key Configuration: Operation set to 'Update'.
Send Email Alert (EmailSend n8n node):
Function: Formats and sends the finalized alert email using the lists generated by the Code n8n node.
* Key Configuration: Subject line includes the date; uses dynamic variables ({{ $json.lowStockList }} and {{ $json.expiryList }}) for the email body.

Related n8n Workflows

Free

Nodes: 6 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*