This workflow follows the Chainllm → Google Sheets 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 →
{
"name": "Trading bot: News Sentiment",
"nodes": [
{
"parameters": {
"rule": {
"interval": [
{
"field": "minutes",
"minutesInterval": 20
}
]
}
},
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.3,
"position": [
-704,
-672
],
"id": "b3bde301-3758-4219-b5cf-fd8db9bec9cb",
"name": "Schedule Trigger"
},
{
"parameters": {
"url": "=https://cointelegraph.com/rss",
"options": {}
},
"type": "n8n-nodes-base.rssFeedRead",
"typeVersion": 1.2,
"position": [
-544,
-672
],
"id": "cae71aba-a36f-41bd-9eab-5a1de6afd3ec",
"name": "RSS Read"
},
{
"parameters": {
"fieldsToAggregate": {
"fieldToAggregate": [
{
"fieldToAggregate": "title",
"renameField": true,
"outputFieldName": "headlines"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.aggregate",
"typeVersion": 1,
"position": [
-320,
-672
],
"id": "8ab926b7-01dd-4c70-b4e1-d9f2630d27e2",
"name": "Aggregate"
},
{
"parameters": {
"promptType": "define",
"text": "=You are an expert quantitative financial analyst. \n\nTARGET ASSET TO ANALYZE: {{ $('Loop').item.json.ticker }}\n\n1. MACRO SENTIMENT (Latest Global News):\n{{ $('Aggregate').item.json.headlines }}\n\n2. QUANTITATIVE DATA ({{ $('Loop').item.json.ticker }} 24h Ticker):\nCurrent Price: ${{ $json.lastPrice }}\n24h Change: {{ $json.priceChangePercent }}%\n24h High: ${{ $json.highPrice }}\n24h Low: ${{ $json.lowPrice }}\n\nAnalyze the global macro sentiment and how it specifically impacts the TARGET ASSET, combining it with the quantitative data. \n- If global news is bullish but the specific asset is up 15% today, it might be overbought (BEARISH or NEUTRAL).\n- If global news is bearish but the asset is heavily discounted, it might be a buy (BULLISH).\n\nYou MUST output your response strictly as a JSON object with no markdown formatting.\nUse exactly this format:\n{\"sentiment\": \"BULLISH\", \"confidence\": 85, \"summary\": \"brief one sentence reason\"}\n\nSentiment must be either BULLISH, BEARISH, or NEUTRAL.\n",
"batching": {}
},
"type": "@n8n/n8n-nodes-langchain.chainLlm",
"typeVersion": 1.9,
"position": [
-640,
256
],
"id": "8abee576-d82e-40e0-9429-f20b986ee597",
"name": "Basic LLM Chain"
},
{
"parameters": {
"model": "gemma4:e2b",
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOllama",
"typeVersion": 1,
"position": [
-640,
352
],
"id": "4610c2db-6495-46cb-9e65-4f6de4771103",
"name": "Ollama Chat Model",
"credentials": {
"ollamaApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"jsCode": "// 1. Get the raw text output from the Basic LLM Chain node\nconst rawAiOutput = $input.first().json.text;\n\ntry {\n // 2. Use a non-greedy Regular Expression to find ALL JSON blocks {...} in the text\n const matches = rawAiOutput.match(/\\{[\\s\\S]*?\\}/g);\n\n if (matches && matches.length > 0) {\n // 3. The AI's final answer is almost always the LAST block in its output.\n // This safely ignores the format examples it repeats during its \"Thinking Process\".\n const finalJsonString = matches[matches.length - 1];\n const parsedData = JSON.parse(finalJsonString);\n\n return parsedData;\n } else {\n // If no { } brackets were found at all\n throw new Error(\"No JSON object found in the AI response.\");\n }\n} catch (error) {\n // 4. Fallback in case parsing fails entirely\n return { \n sentiment: \"ERROR\", \n confidence: 0, \n summary: \"Failed to parse AI output. Error: \" + error.message,\n raw_output: rawAiOutput // We output the raw text so you can debug what went wrong\n };\n}\n"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-304,
256
],
"id": "4826d069-5f01-41cd-89d7-7a3d3d05a9c6",
"name": "Code in JavaScript"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 3
},
"conditions": [
{
"id": "e07a9252-ba74-47d0-97f5-6f7b822ffa25",
"leftValue": "={{ $json.sentiment }}",
"rightValue": "BULLISH",
"operator": {
"type": "string",
"operation": "equals"
}
},
{
"id": "c42413c5-a4c9-4fe8-afaf-85c3208c2036",
"leftValue": "={{ $json.confidence }}",
"rightValue": 70,
"operator": {
"type": "number",
"operation": "gt"
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.3,
"position": [
48,
16
],
"id": "c2c4ce92-b1f5-4000-bb6b-c7e2bc5dc670",
"name": "If"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 3
},
"conditions": [
{
"id": "9b1edcba-00a7-4035-b41a-f04ad17dceef",
"leftValue": "={{ $json.sentiment }}",
"rightValue": "BEARISH",
"operator": {
"type": "string",
"operation": "equals"
}
},
{
"id": "e3add557-6108-4f95-8d96-025ebd52e9d8",
"leftValue": "={{ $json.confidence }}",
"rightValue": 70,
"operator": {
"type": "number",
"operation": "gt"
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.3,
"position": [
48,
256
],
"id": "46c54225-9bbc-46ed-b2b0-a6552ab301bc",
"name": "CheckBearish"
},
{
"parameters": {
"method": "POST",
"url": "https://paper-api.alpaca.markets/v2/orders",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "APCA-API-KEY-ID",
"value": "***"
},
{
"name": "APCA-API-SECRET-KEY",
"value": "***"
}
]
},
"sendBody": true,
"contentType": "raw",
"body": "={ \"symbol\": \"{{ $('Loop').item.json.ticker }}/USD\", \"qty\": {{ $json.qty }}, \"side\": \"sell\", \"type\": \"market\", \"time_in_force\": \"gtc\" }",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.4,
"position": [
224,
448
],
"id": "17bfd2bd-932e-4bf7-b8fb-216dfc186ae5",
"name": "Sell assets"
},
{
"parameters": {
"method": "POST",
"url": "https://paper-api.alpaca.markets/v2/orders",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "APCA-API-KEY-ID",
"value": "***"
},
{
"name": "APCA-API-SECRET-KEY",
"value": "***"
}
]
},
"sendBody": true,
"contentType": "raw",
"body": "={ \"symbol\": \"{{ $('Loop').item.json.ticker }}/USD\", \"qty\": {{ $('Loop').item.json.deal_qty }}, \"side\": \"buy\", \"type\": \"market\", \"time_in_force\": \"gtc\" }",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.4,
"position": [
224,
-160
],
"id": "8a65bf2f-c3bc-464f-8fdc-61250f184c61",
"name": "Buy assets"
},
{
"parameters": {
"url": "=https://paper-api.alpaca.markets/v2/positions/{{ $('Loop').item.json.ticker }}USD",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "APCA-API-KEY-ID",
"value": "***"
},
{
"name": "APCA-API-SECRET-KEY",
"value": "***"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.4,
"position": [
224,
176
],
"id": "71fc9513-d549-466d-84b7-70f41ac86a26",
"name": "Get Ballance",
"onError": "continueErrorOutput"
},
{
"parameters": {
"method": "POST",
"url": "https://chat.googleapis.com/v1/spaces/AAQA5Kc8w5o/messages?key=***",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"text\": \"\u26a0\ufe0f *TRADE ALERT: SELL EXECUTED* \u26a0\ufe0f\\n\\nAsset: {{ $('Loop').item.json.ticker }}/USD\\nAI Sentiment: {{ $('Code in JavaScript').item.json.sentiment }}\\nConfidence Score: {{ $('Code in JavaScript').item.json.confidence }}%\\n\\nReasoning: {{ $('Code in JavaScript').item.json.summary }}\"\n}\n",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.4,
"position": [
480,
448
],
"id": "f552f374-4060-463f-9729-ee4e9c505c10",
"name": "Google Chat message"
},
{
"parameters": {
"method": "POST",
"url": "https://chat.googleapis.com/v1/spaces/AAQA5Kc8w5o/messages?key=***",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"text\": \"\ud83d\udea8 *TRADE ALERT: BUY EXECUTED* \ud83d\udea8\\n\\nAsset: {{ $('Loop').item.json.ticker }}/USD\\nAI Sentiment: {{ $('Code in JavaScript').item.json.sentiment }}\\nConfidence Score: {{ $('Code in JavaScript').item.json.confidence }}%\\n\\nReasoning: {{ $('Code in JavaScript').item.json.summary }}\"\n}\n",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.4,
"position": [
480,
-160
],
"id": "918c912f-5a91-4e37-836e-005ce48b18dd",
"name": "Google Chat Message"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "loose",
"version": 3
},
"conditions": [
{
"id": "70db3285-0a67-40e7-8e3f-cf459791f36c",
"leftValue": "={{ $json.qty }}",
"rightValue": 0,
"operator": {
"type": "number",
"operation": "gt"
}
}
],
"combinator": "and"
},
"looseTypeValidation": true,
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.3,
"position": [
512,
160
],
"id": "25ae133d-3501-4603-9610-64debd4c314c",
"name": "Check Ballance"
},
{
"parameters": {
"url": "=https://api.binance.com/api/v3/ticker/24hr?symbol={{ $('Loop').item.json.ticker }}USDT",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.4,
"position": [
-48,
-272
],
"id": "16a1b235-17ec-4701-9b0c-e3ab1884ec17",
"name": "Binance Data"
},
{
"parameters": {
"authentication": "serviceAccount",
"operation": "append",
"documentId": {
"__rl": true,
"value": "https://docs.google.com/spreadsheets/d/1ohmljbixZh4Ua2uSqCi7zpTy7zI4ZvJO-bDdeuWF-ZM/edit?gid=0#gid=0",
"mode": "url"
},
"sheetName": {
"__rl": true,
"value": "Sheet1",
"mode": "name"
},
"columns": {
"mappingMode": "autoMapInputData",
"value": {},
"matchingColumns": [],
"schema": [
{
"id": "Date",
"displayName": "Date",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "Asset",
"displayName": "Asset",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "Action",
"displayName": "Action",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "Price",
"displayName": "Price",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "Sentiment",
"displayName": "Sentiment",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "Confidence",
"displayName": "Confidence",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.7,
"position": [
928,
-160
],
"id": "b71bcc15-baea-4585-ae49-422ccbbfb16c",
"name": "Append row in sheet",
"credentials": {
"googleApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "a6ee1b88-914f-4e2f-a886-9eb8055cdd8e",
"name": "Date",
"value": "={{ $now }}",
"type": "string"
},
{
"id": "282d64e4-9a11-41b7-9654-10412e69d975",
"name": "Asset",
"value": "={{ $('Loop').item.json.ticker }}/USD",
"type": "string"
},
{
"id": "27dd05e7-7964-41b3-be9c-70089600833f",
"name": "=Action",
"value": "BUY",
"type": "string"
},
{
"id": "ace39231-e4d1-4c38-9a0b-9c46d4d515de",
"name": "Price",
"value": "={{ $('Binance Data').item.json.lastPrice }}",
"type": "string"
},
{
"id": "b11a2e2a-da46-4195-a0e8-cfb1821b288c",
"name": "Sentiment",
"value": "={{ $('Code in JavaScript').item.json.sentiment }}",
"type": "string"
},
{
"id": "1f09adf4-549f-42c5-a6e9-17a402534f97",
"name": "Confidence",
"value": "={{ $('Code in JavaScript').item.json.confidence }}",
"type": "number"
},
{
"id": "9472a819-92db-4afd-ae23-d525fa83063c",
"name": "ShortSummary",
"value": "={{ $('Code in JavaScript').item.json.summary }}",
"type": "string"
},
{
"id": "cc0902c5-7c06-4160-8018-79272d016170",
"name": "Quantity",
"value": "={{ $('Loop').item.json.deal_qty }}",
"type": "number"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
688,
-160
],
"id": "ceff9232-b3bc-47f9-8b9e-904a60a417c4",
"name": "Set sheet fields"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "a6ee1b88-914f-4e2f-a886-9eb8055cdd8e",
"name": "Date",
"value": "={{ $now }}",
"type": "string"
},
{
"id": "282d64e4-9a11-41b7-9654-10412e69d975",
"name": "Asset",
"value": "={{ $('Loop').item.json.ticker }}/USD",
"type": "string"
},
{
"id": "27dd05e7-7964-41b3-be9c-70089600833f",
"name": "Action",
"value": "SELL",
"type": "string"
},
{
"id": "ace39231-e4d1-4c38-9a0b-9c46d4d515de",
"name": "Price",
"value": "={{ $('Binance Data').item.json.lastPrice }}",
"type": "string"
},
{
"id": "b11a2e2a-da46-4195-a0e8-cfb1821b288c",
"name": "Sentiment",
"value": "={{ $('Code in JavaScript').item.json.sentiment }}",
"type": "string"
},
{
"id": "1f09adf4-549f-42c5-a6e9-17a402534f97",
"name": "Confidence",
"value": "={{ $('Code in JavaScript').item.json.confidence }}",
"type": "number"
},
{
"id": "9472a819-92db-4afd-ae23-d525fa83063c",
"name": "ShortSummary",
"value": "={{ $('Code in JavaScript').item.json.summary }}",
"type": "string"
},
{
"id": "78c276f2-36eb-4ee2-99e8-a3062929c8ef",
"name": "Quantity",
"value": "={{ $json.qty }}",
"type": "number"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
704,
448
],
"id": "9a7826ca-6ad3-497a-b9e2-9e1747613fa5",
"name": "Set sheet fields1"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "a6ee1b88-914f-4e2f-a886-9eb8055cdd8e",
"name": "Date",
"value": "={{ $now }}",
"type": "string"
},
{
"id": "282d64e4-9a11-41b7-9654-10412e69d975",
"name": "Asset",
"value": "={{ $('Loop').item.json.ticker }}/USD",
"type": "string"
},
{
"id": "27dd05e7-7964-41b3-be9c-70089600833f",
"name": "Action",
"value": "NOTHING",
"type": "string"
},
{
"id": "ace39231-e4d1-4c38-9a0b-9c46d4d515de",
"name": "Price",
"value": "={{ $('Binance Data').item.json.lastPrice }}",
"type": "string"
},
{
"id": "b11a2e2a-da46-4195-a0e8-cfb1821b288c",
"name": "Sentiment",
"value": "={{ $('Code in JavaScript').item.json.sentiment }}",
"type": "string"
},
{
"id": "1f09adf4-549f-42c5-a6e9-17a402534f97",
"name": "Confidence",
"value": "={{ $('Code in JavaScript').item.json.confidence }}",
"type": "number"
},
{
"id": "9472a819-92db-4afd-ae23-d525fa83063c",
"name": "ShortSummary",
"value": "={{ $('Code in JavaScript').item.json.summary }}",
"type": "string"
},
{
"id": "2f92f6b1-42ce-4013-b24d-16b4dd49000e",
"name": "Quantity",
"value": 0,
"type": "number"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
704,
288
],
"id": "36c4a243-bd40-486d-a99a-7349f870f8f1",
"name": "Set sheet fields2"
},
{
"parameters": {
"jsCode": "// Define the assets you want to trade. \n// 'ticker' is for Binance/Alpaca, 'news_tag' is for the RSS feed.\nreturn [\n { \"ticker\": \"BTC\", \"news_tag\": \"bitcoin\", \"deal_qty\": 0.01 },\n { \"ticker\": \"ETH\", \"news_tag\": \"ethereum\", \"deal_qty\":0.1 },\n { \"ticker\": \"SOL\", \"news_tag\": \"solana\", \"deal_qty\":1 }\n];\n"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-560,
-288
],
"id": "79216caf-a709-424e-8e47-cc2bbf80a4e4",
"name": "Assets to work with"
},
{
"parameters": {
"options": {}
},
"type": "n8n-nodes-base.splitInBatches",
"typeVersion": 3,
"position": [
-336,
-288
],
"id": "f14a5d2a-e249-4133-9cb0-0a50fcfa2e16",
"name": "Loop"
}
],
"connections": {
"Schedule Trigger": {
"main": [
[
{
"node": "RSS Read",
"type": "main",
"index": 0
}
]
]
},
"RSS Read": {
"main": [
[
{
"node": "Aggregate",
"type": "main",
"index": 0
}
]
]
},
"Aggregate": {
"main": [
[
{
"node": "Assets to work with",
"type": "main",
"index": 0
}
]
]
},
"Ollama Chat Model": {
"ai_languageModel": [
[
{
"node": "Basic LLM Chain",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Basic LLM Chain": {
"main": [
[
{
"node": "Code in JavaScript",
"type": "main",
"index": 0
}
]
]
},
"Code in JavaScript": {
"main": [
[
{
"node": "If",
"type": "main",
"index": 0
}
]
]
},
"If": {
"main": [
[
{
"node": "Buy assets",
"type": "main",
"index": 0
}
],
[
{
"node": "CheckBearish",
"type": "main",
"index": 0
}
]
]
},
"CheckBearish": {
"main": [
[
{
"node": "Get Ballance",
"type": "main",
"index": 0
}
],
[
{
"node": "Set sheet fields2",
"type": "main",
"index": 0
}
]
]
},
"Buy assets": {
"main": [
[
{
"node": "Google Chat Message",
"type": "main",
"index": 0
}
]
]
},
"Sell assets": {
"main": [
[
{
"node": "Google Chat message",
"type": "main",
"index": 0
}
]
]
},
"Get Ballance": {
"main": [
[
{
"node": "Check Ballance",
"type": "main",
"index": 0
}
],
[
{
"node": "Set sheet fields2",
"type": "main",
"index": 0
}
]
]
},
"Google Chat Message": {
"main": [
[
{
"node": "Set sheet fields",
"type": "main",
"index": 0
}
]
]
},
"Check Ballance": {
"main": [
[
{
"node": "Sell assets",
"type": "main",
"index": 0
}
],
[
{
"node": "Set sheet fields2",
"type": "main",
"index": 0
}
]
]
},
"Binance Data": {
"main": [
[
{
"node": "Basic LLM Chain",
"type": "main",
"index": 0
}
]
]
},
"Set sheet fields": {
"main": [
[
{
"node": "Append row in sheet",
"type": "main",
"index": 0
}
]
]
},
"Google Chat message": {
"main": [
[
{
"node": "Set sheet fields1",
"type": "main",
"index": 0
}
]
]
},
"Set sheet fields1": {
"main": [
[
{
"node": "Append row in sheet",
"type": "main",
"index": 0
}
]
]
},
"Set sheet fields2": {
"main": [
[
{
"node": "Append row in sheet",
"type": "main",
"index": 0
}
]
]
},
"Assets to work with": {
"main": [
[
{
"node": "Loop",
"type": "main",
"index": 0
}
]
]
},
"Loop": {
"main": [
[],
[
{
"node": "Binance Data",
"type": "main",
"index": 0
}
]
]
},
"Append row in sheet": {
"main": [
[
{
"node": "Loop",
"type": "main",
"index": 0
}
]
]
}
},
"active": true,
"settings": {
"executionOrder": "v1",
"binaryMode": "separate"
},
"versionId": "10ed5da4-606d-49bb-8b01-0f7963550fa9",
"meta": {
"templateCredsSetupCompleted": true
},
"id": "FlkQpsti4QeTr3iE",
"tags": []
}
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.
googleApiollamaApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Trading bot: News Sentiment. Uses rssFeedRead, chainLlm, lmChatOllama, httpRequest. Scheduled trigger; 21 nodes.
Source: https://gist.github.com/AdamFlis/db20c5ae6fc8d8f7047a111790fdc8e1 — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
Categories Content Creation AI Automation Publishing Social Media
Check Legal Regulations: This workflow involves scraping, so ensure you comply with the legal regulations in your country before getting started. Better safe than sorry!
Automatically scan major financial newswires for biotech catalyst events, score them with AI sentiment analysis, and surface ranked trade candidates — all without manual monitoring.
This workflow automates the creation, rendering, approval, and posting of TikTok-style POV (Point of View) videos to Instagram, with cross-posting to Facebook and YouTube. It eliminates manual video p
This workflow is for solopreneurs, founders, creators, and marketers who want a consistent LinkedIn presence without spending hours writing posts. Ideal for anyone in tech, SaaS, or AI who wants trend