{
  "name": "Satoshi Signal",
  "nodes": [
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "select * from get_weekly_btc_price_range()",
        "options": {}
      },
      "id": "276e6b77-486d-44d1-a5a4-fa43287a0c9d",
      "name": "Postgres",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        820,
        420
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "url": "https://api.coinbase.com/v2/prices/spot?currency=USD",
        "options": {}
      },
      "id": "88b7db2c-b7fc-467d-a521-dcc16df828a2",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        480,
        420
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "9e6b6325-bde2-4b63-b65c-41892b1f17b8",
              "leftValue": "={{ $('Parse Fields').item.json.price_now }}",
              "rightValue": "={{ $json.max_price }}",
              "operator": {
                "type": "number",
                "operation": "gt"
              }
            }
          ],
          "combinator": "and"
        },
        "looseTypeValidation": true,
        "options": {}
      },
      "id": "78125e6a-3ed5-4ef0-8c6a-7c1cedace171",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        980,
        420
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "c726796f-625f-4672-b61a-8d5d4c9caf09",
              "name": "price_now",
              "value": "={{ $json.data.amount }}",
              "type": "string"
            },
            {
              "id": "e2921adf-5e94-4f05-aa50-598c21113f6c",
              "name": "base",
              "value": "={{ $json.data.base }}",
              "type": "string"
            },
            {
              "id": "8089bb1d-a151-499e-8f1b-b5f8f963d605",
              "name": "currency",
              "value": "={{ $json.data.currency }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "be4d2f72-4451-440f-a029-d870b62ecf87",
      "name": "Parse Fields",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        660,
        420
      ]
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "f25ceefa-868f-4ea1-b71b-3306e15433f4",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        1740,
        400
      ]
    },
    {
      "parameters": {
        "path": "776b67bf-2b49-45aa-b552-94573f21b80d",
        "options": {}
      },
      "id": "a228b756-363c-42d7-b957-be1f1fc4dc09",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        280,
        420
      ]
    },
    {
      "parameters": {
        "chatId": "6852371789",
        "text": "={{ $json.message.content.mensagem }}",
        "additionalFields": {}
      },
      "id": "78c350a5-625a-4f72-b114-2e476416e66d",
      "name": "Telegram",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1520,
        300
      ],
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "9f813754-962f-47df-81c8-9e34b2b2e471",
      "name": "Less than ATH",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1220,
        520
      ]
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "GPT-4O-MINI"
        },
        "messages": {
          "values": [
            {
              "content": "=Voc\u00ea \u00e9 um especialista em Cripto e Investimentos. Utilizando as informa\u00e7\u00f5es a seguir, gere um copy para uma mensagem ao telegram e whatstapp para engajar o cliente a comprar ou vender BTC. Voc\u00ea tem a regra de gerar um copy com at\u00e9 400 caracteres, e tamb\u00e9m pode usar emojis:\n- Pre\u00e7o atual do BTC/USD: {{ Math.round($('Parse Fields').item.json.price_now) }}\n- Pre\u00e7o Maximo da Semana: {{ $json.max_price }}"
            }
          ]
        },
        "jsonOutput": true,
        "options": {}
      },
      "id": "5730a9a3-d3ca-4f59-9105-9dfd13aa2a13",
      "name": "OpenAI - Copy Cripto",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.7,
      "position": [
        1200,
        300
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Postgres": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Parse Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Fields": {
      "main": [
        [
          {
            "node": "Postgres",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "OpenAI - Copy Cripto",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Less than ATH",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI - Copy Cripto": {
      "main": [
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "8c2af29c-c899-46b4-a082-fe846f2b339d",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "NpusZgGYJ8EBgqE9",
  "tags": []
}