AutomationFlowsAI & RAG › Analyze Inflation Hedges with Openai Gpt-4.1-mini and Gmail

Analyze Inflation Hedges with Openai Gpt-4.1-mini and Gmail

ByWeblineIndia @weblineindia on n8n.io

This workflow runs manually to calculate inflation-adjusted (real) returns for a set of commodities versus a savings rate, then uses OpenAI to generate a structured analysis and emails the final report via Gmail. Starts when you run the workflow manually. Loads the provided…

Event trigger★★★★☆ complexityAI-powered18 nodesOpenAIGmail
AI & RAG Trigger: Event Nodes: 18 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #16432 — we link there as the canonical source.

This workflow follows the Gmail → OpenAI recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "FkJHxcCpwUk5q1eG",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Advanced Inflation Hedge Analyzer",
  "tags": [],
  "nodes": [
    {
      "id": "b0e7de75-10f7-405f-abce-77ff6f949d08",
      "name": "Validate Input",
      "type": "n8n-nodes-base.if",
      "position": [
        448,
        64
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "2ec6cb41-3752-418d-b0e1-e9e70922162b",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $json.inflation }}",
              "rightValue": 0
            },
            {
              "id": "e8b9f942-a127-4142-8e03-e7cbc78bb571",
              "operator": {
                "type": "number",
                "operation": "gte"
              },
              "leftValue": "={{ $json.savings_return }}",
              "rightValue": 0
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.3
    },
    {
      "id": "8410c907-b5da-48b8-94b1-e84b8d455d2c",
      "name": "Label as GOOD",
      "type": "n8n-nodes-base.set",
      "position": [
        1344,
        -128
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "df15ea86-e088-41d4-a703-404e03603b06",
              "name": "category",
              "type": "string",
              "value": "=Good Inflation Hedge"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "80b8f32f-b0d5-4b4c-9463-f59c285ee770",
      "name": "Label as BAD",
      "type": "n8n-nodes-base.set",
      "position": [
        1344,
        64
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "c13043d4-80c9-44af-b43c-7075b535be49",
              "name": "category",
              "type": "string",
              "value": "=Bad Inflation Hedge"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "3266d918-ad85-41d3-bc34-55948047605d",
      "name": "Input: Inflation & Returns",
      "type": "n8n-nodes-base.set",
      "position": [
        224,
        64
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "{\n  \"inflation\": 6,\n  \"savings_return\": 4,\n  \"commodities\": [\n    { \"name\": \"Gold\", \"return\": 10 },\n    { \"name\": \"Silver\", \"return\": 8 },\n    { \"name\": \"Oil\", \"return\": 5 }\n  ]\n}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "dccb6682-f7d3-45be-82b1-f6fb7e0dc091",
      "name": "Compute Real Returns",
      "type": "n8n-nodes-base.code",
      "position": [
        672,
        -32
      ],
      "parameters": {
        "jsCode": "const inflation = $json.inflation;\nconst savings = $json.savings_return;\nconst commodities = $json.commodities;\n\nconst savingsReal = savings - inflation;\n\nconst result = commodities.map(c => {\n  return {\n    name: c.name,\n    nominal: c.return,\n    real: c.return - inflation,\n    savings_real: savingsReal, \n    better_than_savings: (c.return - inflation) > savingsReal\n  };\n});\n\nreturn [\n  {\n    json: {\n      inflation: inflation,\n      savings_real: savingsReal,\n      commodities: result\n    }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "1e072cce-15d4-41fb-8f2c-e37e2b578105",
      "name": "Split Commodities",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        896,
        -32
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "=commodities"
      },
      "typeVersion": 1
    },
    {
      "id": "3db1bc19-6110-4d03-98b0-52b5afe01180",
      "name": "Check Invalid Inputs",
      "type": "n8n-nodes-base.set",
      "position": [
        672,
        160
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "fbf6703d-0627-4666-a515-c947e47d16b8",
              "name": "Error",
              "type": "string",
              "value": "\"Invalid Input\""
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "276d2344-efb6-4293-895b-ebeb7a461d2f",
      "name": "Check Better Than Savings",
      "type": "n8n-nodes-base.if",
      "position": [
        1120,
        -32
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "04eb0bc5-5ed0-4f3d-887f-c0f8276e2051",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.better_than_savings }}",
              "rightValue": "={{ $item(0).$node[\"Compute Real Returns\"].json[\"savings_real\"] }}"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.3
    },
    {
      "id": "b174c941-f8cf-4813-a038-8b1fdc058d11",
      "name": "Merge Results",
      "type": "n8n-nodes-base.merge",
      "position": [
        1568,
        -32
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "ce15f42e-aa8b-45d5-ae23-9c0b60502fc1",
      "name": "Aggregate Data for AI",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1792,
        -32
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "fa8565bf-2b59-4cfd-959d-93226edf1de6",
      "name": "Generate AI Insights",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        2016,
        -32
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini",
          "cachedResultName": "GPT-4.1-MINI"
        },
        "options": {},
        "responses": {
          "values": [
            {
              "content": "=You are a financial advisor.\n\nHere is inflation-adjusted data of different commodities:\n\n{{ JSON.stringify($json) }}\n\nTasks:\n1. Identify which commodity is the best inflation hedge\n2. Explain why it performed better than others\n3. Compare commodities with savings (negative real return)\n4. Give simple investment advice for a beginner\n\nKeep the answer simple, clear, and professional.\n\nReturn output in this structured format:\n\n{\n  \"best_hedge\": \"...\",\n  \"reason\": \"...\",\n  \"comparison\": \"...\",\n  \"advice\": \"...\"\n}"
            }
          ]
        },
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "317c12a7-4ff1-4bc1-a9f6-4e03db80ddad",
      "name": "Format Final Report",
      "type": "n8n-nodes-base.set",
      "position": [
        2368,
        -32
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={\n  \"parsed\": {{ JSON.parse($json.output[0].content[0].text) }}\n}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "7ea650e5-6b92-4c82-b083-4208460680b1",
      "name": "Send Email Report",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2592,
        -32
      ],
      "parameters": {
        "sendTo": "",
        "message": "=<h2> Inflation Hedge Analysis Report</h2>  <p><strong> Best Hedge:</strong><br>{{ $json.parsed.best_hedge }}</p>  <p><strong> Reason:</strong><br>{{ $json.parsed.reason }}</p>  <p><strong> Comparison:</strong><br> {{ $json.parsed.comparison }}</p>  <p><strong> Investment Advice:</strong><br></p>{{ $json.parsed.advice }}  <hr>  <p><em>This report is generated automatically using AI.</em></p>",
        "options": {},
        "subject": "Inflation Hedge Analysis Report"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "64c4c981-0936-4599-bc78-2c5861c7f7c4",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -640,
        -544
      ],
      "parameters": {
        "width": 528,
        "height": 544,
        "content": "## Inflation Hedge Analyzer Workflow \nThis workflow analyzes whether commodities like gold, silver, and oil can act as effective inflation hedges compared to a savings account.\n\n### How it works:\nIt takes user input such as inflation rate, commodity returns, and savings rate. The system calculates real returns (return minus inflation), splits each commodity, and checks if it outperforms savings. Each commodity is tagged as a good or poor hedge. The results are merged and passed to an AI model, which generates a clear, human-readable financial report.\n\n### Setup steps:\n1. Enter inflation rate and returns in the input node\n2. Configure OpenAI API credentials\n3. Set up email (SMTP or Gmail app password)\n4. Execute workflow to receive AI-generated insights\n\nThis workflow helps users make smarter financial decisions by converting raw data into meaningful insights automatically."
      },
      "typeVersion": 1
    },
    {
      "id": "3f069f4a-7114-4e41-8ada-cb49f16c5c7b",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -64,
        -160
      ],
      "parameters": {
        "color": 7,
        "width": 640,
        "height": 416,
        "content": "## Data Input & Validation\nHandles user input for inflation and returns.\nValidates data before processing to avoid incorrect calculations."
      },
      "typeVersion": 1
    },
    {
      "id": "0eca226d-dbc6-44e9-acb6-da2f67a8cbb7",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        608,
        -208
      ],
      "parameters": {
        "color": 7,
        "width": 1104,
        "height": 528,
        "content": "## Processing & Decision Logic\nCalculates real returns, splits commodities, and classifies them as good or poor inflation hedges."
      },
      "typeVersion": 1
    },
    {
      "id": "bf9cf54f-06a6-41ca-8b3e-46ef4c821304",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1744,
        -208
      ],
      "parameters": {
        "color": 7,
        "width": 1072,
        "height": 400,
        "content": "## AI Analysis & Output \nAggregates results, generates AI insights, formats report, and sends email to user."
      },
      "typeVersion": 1
    },
    {
      "id": "554b6047-d151-451b-9889-c62f374605f6",
      "name": "Start Workflow Manually",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        0,
        64
      ],
      "parameters": {},
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "02a41e92-ac59-46f9-bdc4-7a4ab465fbfe",
  "connections": {
    "Label as BAD": {
      "main": [
        [
          {
            "node": "Merge Results",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Label as GOOD": {
      "main": [
        [
          {
            "node": "Merge Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Results": {
      "main": [
        [
          {
            "node": "Aggregate Data for AI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Input": {
      "main": [
        [
          {
            "node": "Compute Real Returns",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Check Invalid Inputs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Commodities": {
      "main": [
        [
          {
            "node": "Check Better Than Savings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Final Report": {
      "main": [
        [
          {
            "node": "Send Email Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Compute Real Returns": {
      "main": [
        [
          {
            "node": "Split Commodities",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate AI Insights": {
      "main": [
        [
          {
            "node": "Format Final Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Data for AI": {
      "main": [
        [
          {
            "node": "Generate AI Insights",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start Workflow Manually": {
      "main": [
        [
          {
            "node": "Input: Inflation & Returns",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Better Than Savings": {
      "main": [
        [
          {
            "node": "Label as GOOD",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Label as BAD",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Input: Inflation & Returns": {
      "main": [
        [
          {
            "node": "Validate Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This workflow runs manually to calculate inflation-adjusted (real) returns for a set of commodities versus a savings rate, then uses OpenAI to generate a structured analysis and emails the final report via Gmail. Starts when you run the workflow manually. Loads the provided…

Source: https://n8n.io/workflows/16432/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

This intelligent email automation workflow helps you maximize engagement through domain-based outreach. It utilizes AI-powered personalization and strategic follow-ups to increase response rates. The

Gmail, HTTP Request, Google Sheets +1
AI & RAG

Complete AI-powered sales system Automates lead capture, qualification, and follow-up from multiple channels. AI INTELLIGENCE:

Gmail Trigger, Google Sheets, OpenAI +3
AI & RAG

An automated quote generation system that monitors your inbox, classifies quote requests using AI, calculates intelligent pricing based on historical data, and provides a professional dashboard for re

Gmail Trigger, OpenAI, Supabase +2
AI & RAG

Send a target niche and location via Telegram message Workflow discovers businesses via Google Maps API AI enriches contacts with email and LinkedIn data via Serper GPT-4o scores and qualifies each le

Telegram Trigger, OpenAI, Google Sheets +3
AI & RAG

LeadInboxTriageBot_GT. Uses gmailTrigger, openAi, googleSheets, gmail. Event-driven trigger; 36 nodes.

Gmail Trigger, OpenAI, Google Sheets +2