πŸ“ˆ Manage portfolio assets via webhook with Google Sheets and real-time totals

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

Description

Webhook-Based Portfolio Manager (n8n + Google Sheets + API)

This workflow turns your n8n instance into a portfolio management API using a webhook and Google Sheets. You can add, update or delete assets via a simple POST request and it automatically calculates your total portfolio value in real-time.

Quick Implementation Steps

  1. Import the workflow into your n8n account
  2. Connect your Google Sheets OAuth2 credentials
  3. Ensure your sheet has columns: Asset, Amount, Price, Value
  4. Activate the workflow
  5. Send a POST request to the webhook with:
{
  "asset": "BTC",
  "amount": 2,
  "price": 30000,
  "action": "add"
}

What This Workflow Does

This workflow acts as a REST-like API for managing investment portfolios using n8n. It receives data via a webhook, processes it and performs operations on a Google Sheet.

It supports three core operations:

Each request is validated to ensure correctness before execution. The workflow also prevents duplicate entries and invalid operations.

After performing any action, it fetches the full portfolio, calculates the total portfolio value and returns a structured JSON response with updated data.

Who It’s For

Requirements

To use this workflow, you need:

How It Works & Setup Instructions

1. Webhook Trigger

2. Normalize Input Data

3. Validate Input

Error Path: Invalid Amount/Price

If validation fails:

{
  "error": "value of amount or price is not correct it should be in positive number"
}

4. Route by Action

Error Path: Missing Action

{
  "error": "action field is required, add key in json called action and in value add, update or delete."
}

Error Path: Invalid Action Value

{
  "error": "action should contains only one of these three values ['add', 'update', 'delete']."
}

ADD Operation

Flow:

  1. Check Asset Exists (Add)
  2. Asset Exists? (Add)

Error Path: Asset Already Exists

{
  "error": "Asset: BTC is already in your portfolio"
}

Success:

UPDATE Operation

Flow:

  1. Update Existing Asset
  2. Asset Found?

Error Path: Asset Not Found (Update)

{
  "error": "Asset: BTC is not found in your portfolio"
}

Success:

DELETE Operation

Flow:

  1. Check Asset Exists (Delete)
  2. Asset Found? (Delete)

Error Path: Asset Not Found (Delete)

{
  "error": "Asset: BTC is not found in your portfolio"
}

Success:

Portfolio Calculation

After any operation:

  1. Combine All Operation Outputs
  2. Fetch Full Portfolio
  3. Calculate Portfolio Value

Logic:

Final Response

Returns:

{
  "message": "Asset: BTC is added, now your total portfolio value is: $60000",
  "Assets": [...]
}

How To Customize Nodes

Add-ons (Enhancements)

You can extend this workflow with:

Use Case Examples

  1. Personal crypto portfolio tracker
  2. Stock portfolio API backend
  3. Admin panel for investment tracking
  4. Automated trading journal
  5. SaaS MVP for portfolio management

And many more depending on your use case.

Troubleshooting Guide

IssuePossible CauseSolution
Webhook not workingWorkflow not activeActivate workflow in n8n
Invalid amount/price errorNegative or missing valuesEnsure positive numbers
Asset not updatingAsset not found in sheetCheck exact asset name
Duplicate asset errorAsset already existsUse update instead of add
Delete not workingRow not foundVerify asset exists
Empty responseMerge or calculation issueCheck node connections

Need Help?

If you need help with:

Reach out to n8n workflow developers at WeblineIndia for expert assistance.

We specialize in building scalable n8n workflows, automation systems and custom integrations tailored to your business needs.

πŸ”— Nodes Used

Google Sheets, Webhook

πŸ“₯ Import

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

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