Quick overview
This workflow collects a portfolio request via an n8n Form, loads holdings from Google Sheets, calculates portfolio risk and concentration metrics, generates an HTML risk narrative with OpenAI, then emails the full report via Gmail and appends an audit record back to Google Sheets.
How it works
- Receives a portfolio analysis request from an n8n Form containing the investor details, base currency, and a Google Sheet ID.
- Reads all holdings from the provided Google Sheets document (Portfolio tab) and bundles the rows into a single portfolio dataset.
- Calculates market value, allocations, sector and asset-class breakdowns, P&L, concentration flags, and a 0–100 risk score.
- Sends the computed portfolio summary, breakdowns, risk flags, and holdings to OpenAI to generate a structured risk report in HTML.
- Builds a branded HTML email that includes the AI narrative plus sector and top-holdings tables and a concentration alert banner.
- Sends the HTML risk report to the investor via Gmail and appends a summary row to a Google Sheets “Analysis Log” audit sheet.
Setup
- Create a Google Sheet with a tab named “Portfolio” and headers: ticker, company, sector, asset_class, quantity, avg_buy_price, current_price.
- Connect a Google Sheets OAuth2 credential and set the audit log document ID (replace YOUR_AUDIT_LOG_SHEET_ID) with a sheet tab named “Analysis Log” containing the mapped columns.
- Connect an OpenAI API credential in the OpenAI Chat Model node and select the model to use.
- Connect a Gmail OAuth2 credential to send emails, then activate the workflow and use the generated Form URL to submit your portfolio request.