{
  "id": "PaBCdf2iwHq0QFoU",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Bitcoin Price Spike Detector",
  "tags": [],
  "nodes": [
    {
      "id": "d659d0be-3454-411d-948d-1502b337b3f5",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1568,
        1312
      ],
      "parameters": {
        "text": "=Bitcoin price increased by 3% in the last 30 minutes.\nbelow is the recent news from various sources:\n\n---\n\n{{ $json.description }}\n\n---\n\nYour Task:\n- Create a summary of news\n- Keep it concise\n- Explain the likely reason for the price change based on news.\n- Decide email subject on your own.\n- Use email tool to send email\n- You have to send email to: errorcommits@mailinator.com\n- Do not add \"Best regards\" at the end of email",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "5a0675cc-e966-4d43-9ff1-fc122c18c8c4",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1568,
        1536
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "1ca51f83-1ba5-4cec-82f5-3c8b025b2afa",
      "name": "Send a message in Gmail",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        1744,
        1536
      ],
      "parameters": {
        "sendTo": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('To', ``, 'string') }}",
        "message": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message', ``, 'string') }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Subject', ``, 'string') }}",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "21f733f2-163a-4fce-8389-8048d2accca4",
      "name": "AI Agent1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1568,
        1824
      ],
      "parameters": {
        "text": "=Bitcoin price decreased by 3% in the last 30 minutes.\nbelow is the recent news from various sources:\n\n---\n\n{{ $json.description }}\n\n---\n\nYour Task:\n- Create a summary of news\n- Keep it concise\n- Explain the likely reason for the price change based on news.\n- Decide email subject on your own.\n- Use email tool to send email\n- You have to send email to: errorcommits@mailinator.com\n- Do not add \"Best regards\" at the end of email",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "502c8b0f-eaf5-44c5-8735-2338f949c3b6",
      "name": "Google Gemini Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1568,
        2048
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "21592635-f014-4696-a714-e8daec712347",
      "name": "Send a message in Gmail1",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        1760,
        2048
      ],
      "parameters": {
        "sendTo": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('To', ``, 'string') }}",
        "message": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message', ``, 'string') }}",
        "options": {},
        "subject": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Subject', ``, 'string') }}",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "35be9141-9e53-470d-917a-0df4197a80e0",
      "name": "Fetch BitCoin Price",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -384,
        1616
      ],
      "parameters": {
        "url": "https://api.coingecko.com/api/v3/simple/price",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "ids",
              "value": "bitcoin"
            },
            {
              "name": "vs_currencies",
              "value": "usd"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "53479243-59a9-4364-a8a8-860654404f02",
      "name": "Add bitcoin price to sheet",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        -192,
        1616
      ],
      "parameters": {
        "columns": {
          "value": {
            "usd": "={{ Number($json.bitcoin.usd) }}"
          },
          "schema": [
            {
              "id": "usd",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "usd",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "usd"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "7z47i7n6XYYVSDJ3",
          "cachedResultUrl": "/projects/XkgejKSYcPusPWyB/datatables/7z47i7n6XYYVSDJ3",
          "cachedResultName": "crypto_price_db"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "afaf85a4-0fc1-4242-ac0f-e46872a42a72",
      "name": "Get all prices from sheet",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        0,
        1616
      ],
      "parameters": {
        "matchType": "=anyCondition",
        "operation": "get",
        "returnAll": true,
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "7z47i7n6XYYVSDJ3",
          "cachedResultUrl": "/projects/XkgejKSYcPusPWyB/datatables/7z47i7n6XYYVSDJ3",
          "cachedResultName": "crypto_price_db"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "5dbf1de0-d603-4bef-aaaa-4bce2ef27857",
      "name": "Get last two prices from sheet",
      "type": "n8n-nodes-base.limit",
      "position": [
        224,
        1616
      ],
      "parameters": {
        "keep": "lastItems",
        "maxItems": "=2"
      },
      "typeVersion": 1
    },
    {
      "id": "e5793657-5774-4347-ae79-431d12beae54",
      "name": "If new price is dropped by 3%",
      "type": "n8n-nodes-base.if",
      "position": [
        672,
        1840
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "dfac5dc5-e435-420a-a1b6-8d277a4cfb7e",
              "operator": {
                "type": "number",
                "operation": "lt"
              },
              "leftValue": "={{ Number(Math.floor(Number($input.last().json.usd) * 1.05)) }} ",
              "rightValue": "={{ Number(Math.floor((Number($input.first().json.usd)))) }}"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.3
    },
    {
      "id": "fd8364a8-3863-4ef6-ba72-d97e870161f9",
      "name": "If new price is increased by 3%",
      "type": "n8n-nodes-base.if",
      "position": [
        672,
        1328
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "01c4f55e-62b2-4e22-877b-ee20ef30b387",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ Number(Math.floor(Number($input.last().json.usd))) }} ",
              "rightValue": "={{ Number(Math.floor((Number($input.first().json.usd) * 1.03))) }}"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.3,
      "alwaysOutputData": false
    },
    {
      "id": "26e2ec86-00f4-4e75-ac5d-64647add8731",
      "name": "Fetch news about bitcoin",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        896,
        1824
      ],
      "parameters": {
        "url": "https://newsapi.org/v2/everything",
        "options": {},
        "sendQuery": true,
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "q",
              "value": "bitcoin"
            }
          ]
        },
        "nodeCredentialType": "httpMultipleHeadersAuth"
      },
      "credentials": {
        "httpMultipleHeadersAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "fcaa4879-a59f-49c2-bbb8-a5a54ae6afbb",
      "name": "Fetch news about bitcoin1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        928,
        1312
      ],
      "parameters": {
        "url": "https://newsapi.org/v2/everything",
        "options": {},
        "sendQuery": true,
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "q",
              "value": "bitcoin"
            }
          ]
        },
        "nodeCredentialType": "httpMultipleHeadersAuth"
      },
      "credentials": {
        "httpQueryAuth": {
          "name": "<your credential>"
        },
        "httpHeaderAuth": {
          "name": "<your credential>"
        },
        "httpMultipleHeadersAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "40d46312-0987-408c-9908-ce3fa6e11ec6",
      "name": "Filter all news",
      "type": "n8n-nodes-base.code",
      "position": [
        1120,
        1312
      ],
      "parameters": {
        "jsCode": "let arr = $input.first().json.articles\n// return arr.map((art) => art.description)\nreturn arr.map(art => {\n  return { json: { description: art.description } };\n});"
      },
      "typeVersion": 2
    },
    {
      "id": "a2458788-2a7c-4328-a544-de5c7a09fed0",
      "name": "Filter all news1",
      "type": "n8n-nodes-base.code",
      "position": [
        1120,
        1824
      ],
      "parameters": {
        "jsCode": "let arr = $input.first().json.articles\n// return arr.map((art) => art.description)\nreturn arr.map(art => {\n  return { json: { description: art.description } };\n});"
      },
      "typeVersion": 2
    },
    {
      "id": "0c35994a-49db-4b5e-be46-d9245a7e4d6e",
      "name": "Aggregate filtered news",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1328,
        1312
      ],
      "parameters": {
        "options": {},
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "description"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "7b442eb0-249c-475c-ac9e-ec9d64d8d5c2",
      "name": "Aggregate filtered news1",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1344,
        1824
      ],
      "parameters": {
        "options": {},
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "description"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c89bd997-8e98-483c-8800-062dc7d504d3",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -672,
        1472
      ],
      "parameters": {
        "color": 7,
        "width": 1232,
        "height": 320,
        "content": "## Bitcoin Price Collection\n- Fetch bitcoin price at every 30 minutes\n- Add price to sheet\n- Get last prices from sheet\n- Combine prices for comparison"
      },
      "typeVersion": 1
    },
    {
      "id": "6d823ac1-2a11-459a-8eb5-224bea7d639d",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        624,
        1120
      ],
      "parameters": {
        "color": 7,
        "width": 1264,
        "height": 576,
        "content": "## Bitcoin Surge\n#### If bitcoin price is increased by 3% then\n- Fetch recent news about bitcoin\n- Filter all the news\n- Send email alert"
      },
      "typeVersion": 1
    },
    {
      "id": "96a2df6d-1fc3-4886-8b5f-855ba1e1f65d",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        624,
        1776
      ],
      "parameters": {
        "color": 7,
        "width": 1264,
        "height": 560,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Bitcoin Drop Alert & News\n#### If bitcoin price is decreased by 3% then\n- Fetch recent news about bitcoin\n- Filter all the news\n- Send email alert"
      },
      "typeVersion": 1
    },
    {
      "id": "05589244-71ea-4b39-b057-769393c64b1c",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1312,
        1040
      ],
      "parameters": {
        "width": 624,
        "height": 416,
        "content": "# Price Spike Detector - Overview\n\nHow it works:\nThis workflow runs every 30 minutes to monitor Bitcoin price changes. It fetches the latest price, stores it in a sheet and compares it with recent entries to calculate percentage change. If the price increases or decreases by 3% or more, it triggers an alert flow. The workflow then fetches recent Bitcoin-related news, filters relevant updates and sends an email alert with both the price movement and supporting news context.\n\n**Setup steps:**\n\n1. Configure a schedule trigger (every 30 minutes).\n2. Connect a Bitcoin price API (e.g., CoinGecko).\n3. Set up a sheet (Google Sheets or similar) to log prices.\n4. Add logic to retrieve and compare recent prices.\n5. Create conditions for \u00b13% price change.\n6. Integrate a news API to fetch Bitcoin news.\n7. Add filtering logic for meaningful news.\n8. Configure email node for sending alerts."
      },
      "typeVersion": 1
    },
    {
      "id": "1d002668-34e5-44c6-a159-920fb383b96d",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        432,
        1616
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "4a6d5e6a-5d1e-4d43-999a-cc4db70f9952",
              "name": "usd",
              "type": "string",
              "value": "={{ $json.usd }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "53826c82-a198-4abf-a874-aa9daa485762",
      "name": "Execute at every 30 minutes",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -608,
        1616
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 30
            }
          ]
        }
      },
      "typeVersion": 1.3
    }
  ],
  "active": false,
  "settings": {
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "2b20186a-9f02-460d-8504-2dd59755781d",
  "connections": {
    "Edit Fields": {
      "main": [
        [
          {
            "node": "If new price is increased by 3%",
            "type": "main",
            "index": 0
          },
          {
            "node": "If new price is dropped by 3%",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter all news": {
      "main": [
        [
          {
            "node": "Aggregate filtered news",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter all news1": {
      "main": [
        [
          {
            "node": "Aggregate filtered news1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch BitCoin Price": {
      "main": [
        [
          {
            "node": "Add bitcoin price to sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate filtered news": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a message in Gmail": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate filtered news1": {
      "main": [
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch news about bitcoin": {
      "main": [
        [
          {
            "node": "Filter all news1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Send a message in Gmail1": {
      "ai_tool": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Fetch news about bitcoin1": {
      "main": [
        [
          {
            "node": "Filter all news",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get all prices from sheet": {
      "main": [
        [
          {
            "node": "Get last two prices from sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Add bitcoin price to sheet": {
      "main": [
        [
          {
            "node": "Get all prices from sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute at every 30 minutes": {
      "main": [
        [
          {
            "node": "Fetch BitCoin Price",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If new price is dropped by 3%": {
      "main": [
        [
          {
            "node": "Fetch news about bitcoin",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Get last two prices from sheet": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If new price is increased by 3%": {
      "main": [
        [
          {
            "node": "Fetch news about bitcoin1",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    }
  }
}