From b0b8cfbf64d30f7e4e5915179418f14db28a4881 Mon Sep 17 00:00:00 2001 From: nusquama Date: Wed, 12 Nov 2025 14:19:37 +0100 Subject: [PATCH] creation --- ...redictions_from_stripe_data_with_gpt-4_and_google_sheets.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 workflows/Automated Revenue Predictions from Stripe Data with GPT-4 and Google Sheets-4577/automated_revenue_predictions_from_stripe_data_with_gpt-4_and_google_sheets.json diff --git a/workflows/Automated Revenue Predictions from Stripe Data with GPT-4 and Google Sheets-4577/automated_revenue_predictions_from_stripe_data_with_gpt-4_and_google_sheets.json b/workflows/Automated Revenue Predictions from Stripe Data with GPT-4 and Google Sheets-4577/automated_revenue_predictions_from_stripe_data_with_gpt-4_and_google_sheets.json new file mode 100644 index 000000000..fc1c37f38 --- /dev/null +++ b/workflows/Automated Revenue Predictions from Stripe Data with GPT-4 and Google Sheets-4577/automated_revenue_predictions_from_stripe_data_with_gpt-4_and_google_sheets.json @@ -0,0 +1 @@ +{"id":"mHSoMMyypmRzfVZn","meta":{"instanceId":"84ad02d6104594179f43f1ce9cfe3a81637b2faedb57dafcb9e649b7542988db"},"name":"CFO forecasting Agent","tags":[],"nodes":[{"id":"b946638e-ba68-4d73-816e-00f3a63d138f","name":"Structured Output Parser","type":"@n8n/n8n-nodes-langchain.outputParserStructured","position":[1420,220],"parameters":{"jsonSchemaExample":"{\n \"forecast\": {\n \"June 2025\": \"$X,XXX.XX\",\n \"July 2025\": \"$X,XXX.XX\",\n \"August 2025\": \"$X,XXX.XX\"\n },\n \"trend\": \"Increasing / Decreasing / Stable\",\n \"confidence\": \"High / Medium / Low\",\n \"insights\": \"Short explanation of why this trend is predicted.\"\n}"},"typeVersion":1.2},{"id":"d80c3670-e8c8-43ee-ba12-2e0e18b99862","name":"OpenAI Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[1180,220],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"wYwTjEv45IzlAOAu","name":"OpenAi account 2"}},"typeVersion":1.2},{"id":"bb75cafb-9dad-4952-89af-0658c4d88aa4","name":"Pinecone Vector Store","type":"@n8n/n8n-nodes-langchain.vectorStorePinecone","position":[1200,400],"parameters":{"mode":"retrieve-as-tool","options":{},"toolName":"Sales_data","pineconeIndex":{"__rl":true,"mode":"list","value":"new","cachedResultName":"new"},"toolDescription":"The data about stripe sales"},"credentials":{"pineconeApi":{"id":"PSI5CiZnLRSkEgJg","name":"PineconeApi account"}},"typeVersion":1.1},{"id":"7d370700-89d9-4163-8070-4a0c643531ca","name":"Embeddings OpenAI","type":"@n8n/n8n-nodes-langchain.embeddingsOpenAi","position":[1140,600],"parameters":{"options":{}},"credentials":{"openAiApi":{"id":"wYwTjEv45IzlAOAu","name":"OpenAi account 2"}},"typeVersion":1.2},{"id":"81de1ecf-75de-44fd-9e62-c381e907c1e1","name":"Run Daily Forecast","type":"n8n-nodes-base.scheduleTrigger","position":[0,0],"parameters":{"rule":{"interval":[{"triggerAtHour":9}]}},"typeVersion":1.2},{"id":"9ce2e0e4-8784-4ed9-9499-b5f54241d04e","name":"Fetch Stripe Charges","type":"n8n-nodes-base.stripe","position":[220,0],"parameters":{"resource":"charge","operation":"getAll","returnAll":true},"typeVersion":1},{"id":"c115eb0c-6877-46db-bf03-55e48527dbc5","name":"Summarize Sales","type":"n8n-nodes-base.code","position":[440,0],"parameters":{"jsCode":"const charges = items.map(item => item.json);\nconst summary = charges.reduce((acc, charge) => {\n const date = new Date(charge.created * 1000).toISOString().split(\"T\")[0];\n acc[date] = (acc[date] || 0) + charge.amount / 100;\n return acc;\n}, {});\nreturn [{ json: { summary } }];\n"},"typeVersion":2},{"id":"fb33581a-9f41-49d7-a722-a68dfe5bc265","name":"Prepare data","type":"n8n-nodes-base.set","position":[660,0],"parameters":{"options":{},"assignments":{"assignments":[{"id":"6aa7f5d2-3aa4-4d4c-85df-0d56bb7b6c9e","name":"summary","type":"string","value":"={{ $json.summary }}"}]}},"typeVersion":3.4},{"id":"d3458681-2654-4e22-8b2d-1711b60ed592","name":"Forecaster agent","type":"@n8n/n8n-nodes-langchain.agent","position":[1240,0],"parameters":{"text":"=You are a CFO AI Agent. Based on the following Stripe sales data:\n\n{{ $json.summary }}\n\nAnalyze the trends, identify any patterns (growth, decline, seasonality), and forecast expected daily or weekly revenue for the next 3 months.","options":{},"promptType":"define","hasOutputParser":true},"typeVersion":1.9},{"id":"325e4952-868c-460a-aa78-2e718477cc78","name":"Save Forecast to Supabase","type":"n8n-nodes-base.supabase","position":[2100,-160],"parameters":{"dataToSend":"autoMapInputData"},"typeVersion":1},{"id":"9fd6efab-edc6-49be-9516-f2d36e1995b2","name":"Log Forecast in Google Sheets","type":"n8n-nodes-base.googleSheets","position":[2100,120],"parameters":{"columns":{"value":{"trend":"={{ $json.output.trend }}","forecast":"={{ $json.output.forecast }}","insights":"={{ $json.output.insights }}","confidence":"={{ $json.output.confidence }}"},"schema":[{"id":"forecast","type":"string","display":true,"required":false,"displayName":"forecast","defaultMatch":false,"canBeUsedToMatch":true},{"id":"trend","type":"string","display":true,"required":false,"displayName":"trend","defaultMatch":false,"canBeUsedToMatch":true},{"id":"confidence","type":"string","display":true,"required":false,"displayName":"confidence","defaultMatch":false,"canBeUsedToMatch":true},{"id":"insights","type":"string","display":true,"required":false,"displayName":"insights","defaultMatch":false,"canBeUsedToMatch":true}],"mappingMode":"defineBelow","matchingColumns":[],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{},"operation":"append","sheetName":{"__rl":true,"mode":"list","value":"gid=0","cachedResultUrl":"https://docs.google.com/spreadsheets/d/108tyyL--yUCbDk4drB__eztLSwjlxcmoRkqYsFnMLrY/edit#gid=0","cachedResultName":"Sheet1"},"documentId":{"__rl":true,"mode":"list","value":"108tyyL--yUCbDk4drB__eztLSwjlxcmoRkqYsFnMLrY","cachedResultUrl":"https://docs.google.com/spreadsheets/d/108tyyL--yUCbDk4drB__eztLSwjlxcmoRkqYsFnMLrY/edit?usp=drivesdk","cachedResultName":"CFO Forecasting"}},"credentials":{"googleSheetsOAuth2Api":{"id":"K5yYfUnKFTqaRn6A","name":"Google Sheets account"}},"typeVersion":4.5},{"id":"241e625d-7019-4919-9f93-137461ad94bf","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-40,-1820],"parameters":{"color":3,"width":840,"height":2120,"content":"## 1๏ธโƒฃ **๐Ÿ” Data Retrieval & Preprocessing**\n\n**Nodes:**\n\n* ๐Ÿ•’ `Run Daily Forecast`\n* ๐ŸŸฆ `Fetch Stripe Charges`\n* ๐Ÿงฉ `Summarize Daily Sales`\n* โœ๏ธ `Prepare Forecast Prompt`\n\n---\n\n### ๐Ÿ•’ `Run Daily Forecast`\n\n**Type:** Cron Trigger\n**Purpose:**\nAutomatically runs the workflow every day to keep forecasts updated with the latest sales data.\n\n๐Ÿ”ง **Configuration:**\n\n* Schedule: Daily at 6 AM UTC (or as needed)\n\n---\n\n### ๐ŸŸฆ `Fetch Stripe Charges`\n\n**Type:** Stripe Node\n**Purpose:**\nRetrieves all successful transactions from Stripe in a defined timeframe.\n\n๐Ÿ“ฅ **Details:**\n\n* Resource: `Charges`\n* Operation: `Get Many`\n* Filters:\n\n * `created[gte]` (e.g. last 30 days)\n * `status: succeeded`\n* Expansion (optional): `data.customer` for customer context\n\nโœ… **Output:** Raw Stripe sales data with timestamps and amounts\n\n---\n\n### ๐Ÿงฉ `Summarize Daily Sales`\n\n**Type:** Code Node\n**Purpose:**\nProcesses Stripe charges and summarizes revenue per day.\n\n๐Ÿง  **Logic:**\n\n* Converts Unix timestamps to `YYYY-MM-DD`\n* Aggregates total revenue per day\n* Converts cents to dollars\n\n๐Ÿ“ฆ **Output Sample:**\n\n```json\n{\n \"2025-05-01\": 1245.50,\n \"2025-05-02\": 980.00\n}\n```\n\n---\n\n### โœ๏ธ `Prepare Forecast Prompt`\n\n**Type:** Edit Fields / Function\n**Purpose:**\nFormats the summary into a natural language prompt for OpenAI.\n\n๐Ÿง  **Example Prompt:**\n\n```txt\nGiven the following sales data:\n{ \"2025-05-01\": 1245.50, ... }\n\nPredict trends and forecast sales for the next 3 months.\n```\n\n๐Ÿงพ **Output:** `prompt` (String) โ†’ sent to the AI Agent\n"},"typeVersion":1},{"id":"f60c6c15-8449-457a-aaad-2ebca8d75318","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[940,-1880],"parameters":{"color":6,"width":840,"height":2680,"content":"## 2๏ธโƒฃ **๐Ÿค– AI Agent Forecasting**\n\n**Nodes:**\n\n* ๐Ÿค– `Forecast with OpenAI Agent`\n* ๐Ÿง  `OpenAI GPT-4 Model`\n* ๐Ÿ“„ `Extract Forecast Output`\n* ๐ŸŒฒ `Store Context in Pinecone` *(Optional)*\n* ๐Ÿงฌ `Generate Embeddings` *(Optional)*\n\n---\n\n### ๐Ÿค– `Forecast with OpenAI Agent`\n\n**Type:** Tools Agent\n**Purpose:**\nActs as an intelligent agent that reads the sales summary and responds with forecasts and reasoning.\n\n๐Ÿง  **Prompt Input:**\nPassed from `Prepare Forecast Prompt`\n\n๐Ÿ’ฌ **Uses:**\n\n* Model: `GPT-4`\n* Output Parser: Structured JSON format\n\n๐Ÿ“ˆ **Forecast Intent:**\nPredicts next 3 months, identifies trends, and gives a confidence level\n\n---\n\n### ๐Ÿง  `OpenAI GPT-4 Model`\n\n**Type:** OpenAI Node\n**Purpose:**\nHandles the natural language generation based on the supplied prompt.\n\n๐Ÿงพ **Configuration:**\n\n* Model: `gpt-4` or `gpt-4-turbo`\n* Temperature: `0.2` (more deterministic)\n* Max Tokens: `1000`\n\n---\n\n### ๐Ÿ“„ `Extract Forecast Output`\n\n**Type:** Structured Output Parser\n**Purpose:**\nParses the GPT response into usable JSON format.\n\n๐Ÿ“ฆ **Expected Output:**\n\n```json\n{\n \"forecast\": {\n \"June\": \"$15,000.00\",\n \"July\": \"$16,500.00\",\n \"August\": \"$17,200.00\"\n },\n \"trend\": \"Increasing\",\n \"confidence\": \"High\",\n \"insights\": \"Sales show strong momentum...\"\n}\n```\n\n---\n\n### ๐ŸŒฒ `Store Context in Pinecone` *(optional)*\n\n**Type:** Vector Store\n**Purpose:**\nIndexes past data for retrieval-based prompting (RAG). Useful for long-term memory.\n\n---\n\n### ๐Ÿงฌ `Generate Embeddings` *(optional)*\n\n**Type:** Embeddings Node\n**Purpose:**\nConverts text into vector format before inserting into Pinecone."},"typeVersion":1},{"id":"8e9b2ea7-58bb-4f62-a69c-eed70032019c","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[1920,-1220],"parameters":{"color":5,"width":460,"height":1560,"content":"## 3๏ธโƒฃ **๐Ÿ“ฆ Storage & Reporting**\n\n**Nodes:**\n\n* ๐ŸŸฉ `Save Forecast to Supabase`\n* ๐Ÿ“Š `Log Forecast in Google Sheets`\n\n---\n\n### ๐ŸŸฉ `Save Forecast to Supabase`\n\n**Type:** Supabase Node\n**Purpose:**\nStores all forecast results for analytics, versioning, or historical comparisons.\n\n๐Ÿ›ข๏ธ **Table:** `forecasts`\n๐Ÿงพ **Columns Example:**\n\n| timestamp | raw\\_data | forecast\\_data |\n| ---------- | --------- | -------------- |\n| 2025-05-29 | {...} | {...} |\n\n---\n\n### ๐Ÿ“Š `Log Forecast in Google Sheets`\n\n**Type:** Google Sheets Node\n**Purpose:**\nPushes structured data into a visual format for reporting dashboards or human review.\n\n๐Ÿ“‹ **Column Format:**\n\n| Date | Forecast (USD) | Trend | Confidence | Insights |\n| ---------- | -------------- | ---------- | ---------- | -------------------------- |\n| 2025-05-29 | \\$15,000.00 | Increasing | High | Sales rising at 10% weekly |\n\n---\n\n## โœ… Summary Flow\n\n```txt\n๐Ÿ” Sales Data (Stripe) \n โ†’ ๐Ÿง  Forecast Agent (OpenAI) \n โ†’ ๐Ÿ“ฆ Stored in Supabase \n โ†’ ๐Ÿ“Š Reported in Google Sheets"},"typeVersion":1},{"id":"7d1186c9-cba1-4876-a405-fa67773b8dad","name":"Sticky Note9","type":"n8n-nodes-base.stickyNote","position":[-1840,-1800],"parameters":{"color":4,"width":1300,"height":320,"content":"=======================================\n WORKFLOW ASSISTANCE\n=======================================\nFor any questions or support, please contact:\n Yaron@nofluff.online\n\nExplore more tips and tutorials here:\n - YouTube: https://www.youtube.com/@YaronBeen/videos\n - LinkedIn: https://www.linkedin.com/in/yaronbeen/\n=======================================\n"},"typeVersion":1},{"id":"2b9e9108-8084-4e3f-a620-5bee07040bc3","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[-1840,-1460],"parameters":{"color":4,"width":1289,"height":4778,"content":"# ๐Ÿ“Š CFO Forecasting Agent โ€“ Workflow Documentation\n\n---\n\n## 1๏ธโƒฃ **๐Ÿ” Data Retrieval & Preprocessing**\n\n**Nodes:**\n\n* ๐Ÿ•’ `Run Daily Forecast`\n* ๐ŸŸฆ `Fetch Stripe Charges`\n* ๐Ÿงฉ `Summarize Daily Sales`\n* โœ๏ธ `Prepare Forecast Prompt`\n\n---\n\n### ๐Ÿ•’ `Run Daily Forecast`\n\n**Type:** Cron Trigger\n**Purpose:**\nAutomatically runs the workflow every day to keep forecasts updated with the latest sales data.\n\n๐Ÿ”ง **Configuration:**\n\n* Schedule: Daily at 6 AM UTC (or as needed)\n\n---\n\n### ๐ŸŸฆ `Fetch Stripe Charges`\n\n**Type:** Stripe Node\n**Purpose:**\nRetrieves all successful transactions from Stripe in a defined timeframe.\n\n๐Ÿ“ฅ **Details:**\n\n* Resource: `Charges`\n* Operation: `Get Many`\n* Filters:\n\n * `created[gte]` (e.g. last 30 days)\n * `status: succeeded`\n* Expansion (optional): `data.customer` for customer context\n\nโœ… **Output:** Raw Stripe sales data with timestamps and amounts\n\n---\n\n### ๐Ÿงฉ `Summarize Daily Sales`\n\n**Type:** Code Node\n**Purpose:**\nProcesses Stripe charges and summarizes revenue per day.\n\n๐Ÿง  **Logic:**\n\n* Converts Unix timestamps to `YYYY-MM-DD`\n* Aggregates total revenue per day\n* Converts cents to dollars\n\n๐Ÿ“ฆ **Output Sample:**\n\n```json\n{\n \"2025-05-01\": 1245.50,\n \"2025-05-02\": 980.00\n}\n```\n\n---\n\n### โœ๏ธ `Prepare Forecast Prompt`\n\n**Type:** Edit Fields / Function\n**Purpose:**\nFormats the summary into a natural language prompt for OpenAI.\n\n๐Ÿง  **Example Prompt:**\n\n```txt\nGiven the following sales data:\n{ \"2025-05-01\": 1245.50, ... }\n\nPredict trends and forecast sales for the next 3 months.\n```\n\n๐Ÿงพ **Output:** `prompt` (String) โ†’ sent to the AI Agent\n\n---\n\n## 2๏ธโƒฃ **๐Ÿค– AI Agent Forecasting**\n\n**Nodes:**\n\n* ๐Ÿค– `Forecast with OpenAI Agent`\n* ๐Ÿง  `OpenAI GPT-4 Model`\n* ๐Ÿ“„ `Extract Forecast Output`\n* ๐ŸŒฒ `Store Context in Pinecone` *(Optional)*\n* ๐Ÿงฌ `Generate Embeddings` *(Optional)*\n\n---\n\n### ๐Ÿค– `Forecast with OpenAI Agent`\n\n**Type:** Tools Agent\n**Purpose:**\nActs as an intelligent agent that reads the sales summary and responds with forecasts and reasoning.\n\n๐Ÿง  **Prompt Input:**\nPassed from `Prepare Forecast Prompt`\n\n๐Ÿ’ฌ **Uses:**\n\n* Model: `GPT-4`\n* Output Parser: Structured JSON format\n\n๐Ÿ“ˆ **Forecast Intent:**\nPredicts next 3 months, identifies trends, and gives a confidence level\n\n---\n\n### ๐Ÿง  `OpenAI GPT-4 Model`\n\n**Type:** OpenAI Node\n**Purpose:**\nHandles the natural language generation based on the supplied prompt.\n\n๐Ÿงพ **Configuration:**\n\n* Model: `gpt-4` or `gpt-4-turbo`\n* Temperature: `0.2` (more deterministic)\n* Max Tokens: `1000`\n\n---\n\n### ๐Ÿ“„ `Extract Forecast Output`\n\n**Type:** Structured Output Parser\n**Purpose:**\nParses the GPT response into usable JSON format.\n\n๐Ÿ“ฆ **Expected Output:**\n\n```json\n{\n \"forecast\": {\n \"June\": \"$15,000.00\",\n \"July\": \"$16,500.00\",\n \"August\": \"$17,200.00\"\n },\n \"trend\": \"Increasing\",\n \"confidence\": \"High\",\n \"insights\": \"Sales show strong momentum...\"\n}\n```\n\n---\n\n### ๐ŸŒฒ `Store Context in Pinecone` *(optional)*\n\n**Type:** Vector Store\n**Purpose:**\nIndexes past data for retrieval-based prompting (RAG). Useful for long-term memory.\n\n---\n\n### ๐Ÿงฌ `Generate Embeddings` *(optional)*\n\n**Type:** Embeddings Node\n**Purpose:**\nConverts text into vector format before inserting into Pinecone.\n\n---\n\n## 3๏ธโƒฃ **๐Ÿ“ฆ Storage & Reporting**\n\n**Nodes:**\n\n* ๐ŸŸฉ `Save Forecast to Supabase`\n* ๐Ÿ“Š `Log Forecast in Google Sheets`\n\n---\n\n### ๐ŸŸฉ `Save Forecast to Supabase`\n\n**Type:** Supabase Node\n**Purpose:**\nStores all forecast results for analytics, versioning, or historical comparisons.\n\n๐Ÿ›ข๏ธ **Table:** `forecasts`\n๐Ÿงพ **Columns Example:**\n\n| timestamp | raw\\_data | forecast\\_data |\n| ---------- | --------- | -------------- |\n| 2025-05-29 | {...} | {...} |\n\n---\n\n### ๐Ÿ“Š `Log Forecast in Google Sheets`\n\n**Type:** Google Sheets Node\n**Purpose:**\nPushes structured data into a visual format for reporting dashboards or human review.\n\n๐Ÿ“‹ **Column Format:**\n\n| Date | Forecast (USD) | Trend | Confidence | Insights |\n| ---------- | -------------- | ---------- | ---------- | -------------------------- |\n| 2025-05-29 | \\$15,000.00 | Increasing | High | Sales rising at 10% weekly |\n\n---\n\n## โœ… Summary Flow\n\n```txt\n๐Ÿ” Sales Data (Stripe) \n โ†’ ๐Ÿง  Forecast Agent (OpenAI) \n โ†’ ๐Ÿ“ฆ Stored in Supabase \n โ†’ ๐Ÿ“Š Reported in Google Sheets\n```\n"},"typeVersion":1}],"active":false,"pinData":{"Fetch Stripe Charges":[{"json":{"id":"ch_1NxXy2LzPp3ZhRAbCD123456","amount":3500,"object":"charge","status":"succeeded","created":1716940800,"currency":"usd","customer":{"id":"cus_N8U1xX5TVgB1vW","name":"Jane Doe","email":"jane.doe@example.com"},"description":"Pro plan subscription","amount_captured":3500,"amount_refunded":0,"payment_method_details":{"card":{"brand":"visa","last4":"4242"},"type":"card"}}},{"json":{"id":"ch_1NxXy3LzPp3ZhRAbCD654321","amount":1299,"object":"charge","status":"succeeded","created":1717027200,"currency":"usd","customer":{"id":"cus_N8U9YT5TWzA7LM","name":"John Smith","email":"john.smith@example.com"},"description":"Add-on purchase","amount_captured":1299,"amount_refunded":0,"payment_method_details":{"card":{"brand":"mastercard","last4":"5555"},"type":"card"}}}]},"settings":{"executionOrder":"v1"},"versionId":"56196260-ac1a-4ef1-87c1-d5a8e1eb438f","connections":{"Prepare data":{"main":[[{"node":"Forecaster agent","type":"main","index":0}]]},"Summarize Sales":{"main":[[{"node":"Prepare data","type":"main","index":0}]]},"Forecaster agent":{"main":[[{"node":"Save Forecast to Supabase","type":"main","index":0},{"node":"Log Forecast in Google Sheets","type":"main","index":0}]]},"Embeddings OpenAI":{"ai_embedding":[[{"node":"Pinecone Vector Store","type":"ai_embedding","index":0}]]},"OpenAI Chat Model":{"ai_languageModel":[[{"node":"Forecaster agent","type":"ai_languageModel","index":0}]]},"Run Daily Forecast":{"main":[[{"node":"Fetch Stripe Charges","type":"main","index":0}]]},"Fetch Stripe Charges":{"main":[[{"node":"Summarize Sales","type":"main","index":0}]]},"Pinecone Vector Store":{"ai_tool":[[{"node":"Forecaster agent","type":"ai_tool","index":0}]]},"Structured Output Parser":{"ai_outputParser":[[{"node":"Forecaster agent","type":"ai_outputParser","index":0}]]}}} \ No newline at end of file