πŸ“ˆ Track commodity portfolio drift with Google Sheets, Gemini AI and Gmail alerts

⚑ 19 views Β· πŸ“ˆ Crypto Trading & Stock Market

Description

Commodity Portfolio Tracker using n8n, Google Sheets, Gemini AI & Gmail Alerts

This workflow automatically monitors a commodity portfolio stored in Google Sheets, compares actual allocation against predefined targets, detects deviations and sends intelligent rebalance alerts via email using Gemini AI. It also logs every run (success, failure or no action) into a tracking sheet for audit purposes.

Quick Implementation Steps

  1. Connect Google Sheets, Gmail and Gemini credentials in your n8n account
  2. Add holdings data in Google Sheets
  3. Configure targets in β€œWorkflow Settings” node
  4. Create rebalance_log sheet with required columns
  5. Test workflow β†’ Activate schedule

What It Does

This workflow acts as an automated portfolio monitoring system specifically designed for commodity-based investments such as Gold, Silver, Oil, Copper and Natural Gas. It reads portfolio holdings using the Read Holdings node and combines them with configuration from the Workflow Settings node.

The workflow validates data through Validate Portfolio Data, calculates allocation via Calculate Portfolio Allocation and identifies deviations using Detect Portfolio Drift. If deviations exceed limits, Classify Alert Severity determines how critical the situation is.

Finally, Build Alert Prompt and Generate Alert Message (Gemini AI) create a human-readable alert, which is processed in Prepare Alert Payload, sent via Send Rebalance Email and logged using Log Sent Alert, Log Validation Failure or Log No Action depending on the outcome.

Who It’s For

Requirements

How It Works & Setup Instructions

Step 1: Prepare Google Sheets

Create two sheets:

Holdings Sheet

Columns example: asset, units, price, current_value, last_updated

Log Sheet (rebalance_log)

Columns: run_date,total_value,rebalance_needed,severity,affected_assets,alert_sent,summary,reason_skipped

Step 2: Configure Workflow Settings Node

Update values inside Workflow Settings node:

Step 3: Connect Credentials

Step 4: Workflow Execution Flow (Node-by-Node)

  1. Schedule Trigger starts the workflow
  2. Read Holdings fetches portfolio data
  3. Workflow Settings provides configuration
  4. Synchronize Inputs merges both sources
  5. Prepare Portfolio Context structures the data
  6. Validate Portfolio Data ensures correctness
  7. Check Validation Status routes valid/invalid data
  8. Calculate Portfolio Allocation computes percentages
  9. Detect Portfolio Drift identifies deviations
  10. Check Rebalance Requirement decides action path
  11. Classify Alert Severity assigns severity level
  12. Build Alert Prompt prepares AI input
  13. Generate Alert Message creates final message
  14. Merge Alert Data combines AI + data
  15. Prepare Alert Payload formats output
  16. Send Rebalance Email sends alert
  17. Log Sent Alert / Log No Action / Log Validation Failure store results

How To Customize Nodes

Add-ons

Use Case Examples

  1. Daily monitoring of commodity portfolios
  2. Automated advisory alerts for wealth managers
  3. DIY investor portfolio tracking system
  4. Risk management for diversified assets
  5. Audit trail for compliance and reporting

There can be many more variations of this workflow depending on business needs.

Troubleshooting Guide

IssuePossible CauseSolution
No columns foundSheet missing headersAdd header row in first row
Undefined values in logWrong node connectionConnect from payload node instead of email node
Email not sentGmail credentials issueReconnect Gmail account
AI output emptyPrompt or API issueCheck Gemini node input
Validation failedIncorrect data formatFix holdings sheet values

Need Help

If you need assistance setting up this workflow, customizing features or building automation solutions, feel free to reach out to our n8n experts at WeblineIndia.

We can help you:

Get in touch to turn your ideas into production-ready workflows.

πŸ”— Nodes Used

Google Sheets, Gmail, Schedule Trigger, Google Gemini

πŸ“₯ Import

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

πŸ“– Importing guide Β· πŸ”‘ Credential setup