{
  "nodes": [
    {
      "id": "1",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1,
      "position": [
        100,
        200
      ],
      "parameters": {
        "updateTypes": [
          "message"
        ]
      }
    },
    {
      "id": "2",
      "name": "Prepare Gemini Input",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        300,
        200
      ],
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "json": [
            {
              "name": "contents",
              "value": "= [{ \"parts\": [ { \"text\": \"{{$json[\"message\"][\"text\"]}}\" } ] }]"
            }
          ]
        }
      }
    },
    {
      "id": "3",
      "name": "Google Gemini",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        500,
        200
      ],
      "parameters": {
        "url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=YOUR_GEMINI_API_KEY",
        "method": "POST",
        "responseFormat": "json",
        "jsonParameters": true,
        "options": {},
        "bodyParametersJson": "={\"contents\": {{$json[\"contents\"]}}",
        "headerParametersJson": "{\"Content-Type\": \"application/json\"}"
      }
    },
    {
      "id": "4",
      "name": "Extract Gemini Response",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        700,
        200
      ],
      "parameters": {
        "functionCode": "const reply = $json[\"candidates\"][0][\"content\"][\"parts\"][0][\"text\"];\nreturn [{ json: { code: reply } }];"
      }
    },
    {
      "id": "5",
      "name": "Send to Hastebin",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        900,
        200
      ],
      "parameters": {
        "url": "https://hastebin.com/documents",
        "method": "POST",
        "responseFormat": "json",
        "jsonParameters": false,
        "options": {},
        "bodyContentType": "text/plain",
        "bodyContent": "={{$json[\"code\"]}}"
      }
    },
    {
      "id": "6",
      "name": "Format Link for Telegram",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        1100,
        200
      ],
      "parameters": {
        "functionCode": "const key = $json[\"key\"];\nreturn [{ json: { reply: `Here is your code: https://hastebin.com/${key}` } }];"
      }
    },
    {
      "id": "7",
      "name": "Reply via Telegram",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1,
      "position": [
        1300,
        200
      ],
      "parameters": {
        "chatId": "={{$json[\"chat\"][\"id\"]}}",
        "text": "={{$json[\"reply\"]}}"
      }
    }
  ],
  "connections": {
    "1": {
      "main": [
        [
          {
            "node": "Prepare Gemini Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2": {
      "main": [
        [
          {
            "node": "Google Gemini",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3": {
      "main": [
        [
          {
            "node": "Extract Gemini Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4": {
      "main": [
        [
          {
            "node": "Send to Hastebin",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5": {
      "main": [
        [
          {
            "node": "Format Link for Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6": {
      "main": [
        [
          {
            "node": "Reply via Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "name": "Gemini Telegram CodeBot",
  "active": false
}