๐Ÿค Send low-stock inventory reorder emails from Snowflake with Claude and Outlook

โšก 121 views ยท ๐Ÿค CRM & Sales Operations

Description

Quick overview

This workflow runs daily, queries Snowflake for items at or below their reorder level, and groups them by supplier. For each supplier, it uses Anthropic Claude to draft a reorder email, optionally appends details to a Google Docs log, and sends the email via Microsoft Outlook.

How it works

  1. A Schedule Trigger fires every day at 07:00 (Europe/Helsinki timezone) and passes through a Workflow Config node that holds your optional Google Docs log ID.
  2. A Snowflake query fetches all inventory rows where current_stock <= reorder_level. If no items qualify, the workflow exits cleanly via a Pass Through node with no further action.
  3. A Code node groups the low-stock items by supplier_name, producing one batch per vendor. A SplitInBatches loop then processes each supplier one at a time.
  4. For each supplier, a Set node extracts the supplier email, item count, and a pre-rendered Markdown item list, then passes everything to an LLM chain powered by Claude (claude-sonnet-4-6).
  5. Claude generates a concise, professional reorder request email body in Markdown, constrained by a system prompt to return only the email content with no preamble.
  6. The Markdown output is converted to HTML and optionally appended as a one-line entry to a Google Docs audit log (skipped if no doc ID is configured). The workflow then sends the HTML email to the supplier via Microsoft Outlook before advancing to the next vendor.

Setup

  1. Open the Workflow Config node and set log_doc_id to the document ID from your Google Doc URL (the string between /d/ and /edit). Leave it empty to skip audit logging entirely.
  2. Add your Snowflake credentials to the Query Snowflake DB node and verify the query matches your database name, schema, and table. The expected columns are item_id, item_name, current_stock, reorder_level, supplier_name, and supplier_email.
  3. Add your Anthropic credentials to the Claude Email Generation node.
  4. Add your Microsoft Outlook credentials to both the Send Reorder Email and Send Error Alert nodes. Update the toRecipients field in Send Error Alert to your alert address.
  5. If logging is enabled, add your Google Docs credentials to the Log to Google Docs node.
  6. In n8n Settings > Error Workflow, point to a dedicated error-handler sub-workflow that wires into the Send Error Alert node (it is intentionally unwired in this workflow).

Requirements

Customization

๐Ÿ”— Nodes Used

Snowflake, Microsoft Outlook, Google Docs, Markdown, Schedule Trigger, Basic LLM Chain

๐Ÿ“ฅ Import

Download workflow.json and import into n8n: Workflow menu โ†’ Import from File

๐Ÿ“– Importing guide ยท ๐Ÿ”‘ Credential setup