Skip to main content

Send portfolio risk reports with Google Sheets, GPT-4o-mini and Gmail

Workflow preview

Workflow preview
100%
Send portfolio risk reports with Google Sheets, GPT-4o-mini and Gmail preview
Open on n8n.io

1. Workflow Overview

Quick Overview This workflow receives a portfolio via webhook (uploaded CSV or Google Sheets), calculates allocation and concentration risk metrics, generates an OpenAI HTML risk report, emails it ...

Best for

  • Crypto Trading automation workflows
  • AI Summarization automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.webhook, n8n-nodes-base.if, n8n-nodes-base.code, n8n-nodes-base.spreadsheetfile, n8n-nodes-base.googlesheets, n8n-nodes-base.aggregate, n8n-nodes-base.set, @n8n/n8n-nodes-langchain.openai

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by WeblineIndia.

Original n8n.io source

1.1 Workflow description

Title
Send portfolio risk reports with Google Sheets, GPT-4o-mini and Gmail
Workflow name
Send portfolio risk reports with Google Sheets, GPT-4o-mini and Gmail

Quick Overview

This workflow receives a portfolio via webhook (uploaded CSV or Google Sheets), calculates allocation and concentration risk metrics, generates an OpenAI HTML risk report, emails it through Gmail, and returns a JSON API response with the report status.

How it works

  1. Receives a POST webhook request containing a portfolio source type plus user name and email.
  2. Loads holdings either by decoding an uploaded base64 CSV into rows or by reading rows from Google Sheets.
  3. Combines all holdings into a single dataset and attaches user and source metadata.
  4. Calculates portfolio totals, position weights, sector and asset-class breakdowns, concentration flags, top gainers/losers, and an overall risk score and label.
  5. If the portfolio is valid, sends the computed metrics to OpenAI to generate a client-ready HTML risk narrative.
  6. Builds a formatted HTML email that includes the AI analysis plus sector and top-holdings tables, then sends it to the user via Gmail and returns a success JSON response.
  7. If the portfolio is empty or invalid, emails a failure notice via Gmail (when an email is provided) and returns a 422 JSON error response.

Setup

  1. Create and connect credentials for Google Sheets OAuth2, OpenAI, and Gmail OAuth2.
  2. Configure the webhook endpoint by copying the production URL and sending POST requests to the /portfolio-analyze path.
  3. For CSV submissions, include base64 CSV content in body.fileData (or body.csvBase64/body.file) and ensure the columns include ticker, company, sector, quantity, avg_buy_price, current_price, and asset_class.
  4. For Google Sheets submissions, update the spreadsheet document ID and sheet (gid) to the holdings table you want to analyze.
  5. Ensure the request includes userEmail (body, query, or x-user-email header) so the workflow can deliver the report or validation error message.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Receive Portfolio Request

Type / Role
n8n-nodes-base.webhook - webhook
Config choices
Version 2

Block 2 - Choose Portfolio Data Source

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2

Block 3 - Prepare Uploaded CSV File

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 4 - Read Portfolio CSV Data

Type / Role
n8n-nodes-base.spreadsheetFile - spreadsheetFile
Config choices
Version 2

Block 5 - Load Portfolio from Google Sheets

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.5

Block 6 - Combine Portfolio Holdings

Type / Role
n8n-nodes-base.aggregate - aggregate
Config choices
Version 1

Block 7 - Set User & Source Details

Type / Role
n8n-nodes-base.set - set
Config choices
Version 2

Block 8 - Analyze Portfolio Risk

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 9 - Check Portfolio Data

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2

Block 10 - Generate AI Risk Insights

Type / Role
@n8n/n8n-nodes-langchain.openAi - openAi
Config choices
Version 1.8

Block 11 - Build Portfolio Email Report

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 12 - Send Portfolio Report Email

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.2

Block 13 - Return Success Response

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1.1

Block 14 - Check User Email for Error Alert

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2

Block 15 - Send Invalid Portfolio Alert

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.2

Block 16 - Return Validation Error

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1.1

Block 17 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 18 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 19 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 20 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 21 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 22 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Send portfolio risk reports with Google Sheets, GPT-4o-mini and Gmail
Complexity advanced
Nodes 22
Categories Crypto Trading, AI Summarization
Author WeblineIndia
Published 17 Jun 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/16443/16443.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Send portfolio risk reports with Google Sheets, GPT-4o-mini and Gmail do?

Quick Overview This workflow receives a portfolio via webhook (uploaded CSV or Google Sheets), calculates allocation and concentration risk metrics, generates an OpenAI HTML risk report, emails it ...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Crypto Trading, AI Summarization use case.