{
  "name": "Telegram Image Generation Bot",
  "nodes": [
    {
      "parameters": {
        "updates": ["message"],
        "additionalFields": {}
      },
      "id": "tigb0001-0001-4000-8000-000000000001",
      "name": "Telegram Message Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1,
      "position": [240, 300]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "field1",
              "name": "prompt",
              "value": "={{ $json.message.text }}",
              "type": "string"
            },
            {
              "id": "field2",
              "name": "chatId",
              "value": "={{ $json.message.chat.id }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "tigb0001-0002-4000-8000-000000000002",
      "name": "Extract Prompt and Chat",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3,
      "position": [460, 300]
    },
    {
      "parameters": {
        "url": "https://api.openai.com/v1/images/generations",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "openAiApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [{ "name": "Content-Type", "value": "application/json" }]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            { "name": "model", "value": "dall-e-3" },
            { "name": "prompt", "value": "={{ $json.prompt }}" },
            { "name": "n", "value": "1" },
            { "name": "size", "value": "1024x1024" }
          ]
        },
        "options": {}
      },
      "id": "tigb0001-0003-4000-8000-000000000003",
      "name": "Generate Image via DALL-E",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [680, 300]
    },
    {
      "parameters": {
        "chatId": "={{ $('Extract Prompt and Chat').item.json.chatId }}",
        "operation": "sendPhoto",
        "photoUrl": "={{ $json.data[0].url }}",
        "additionalFields": {
          "caption": "=Generated for: {{ $('Extract Prompt and Chat').item.json.prompt }}"
        }
      },
      "id": "tigb0001-0004-4000-8000-000000000004",
      "name": "Send Image to Telegram",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1,
      "position": [900, 300]
    }
  ],
  "connections": {
    "Telegram Message Trigger": {
      "main": [[{ "node": "Extract Prompt and Chat", "type": "main", "index": 0 }]]
    },
    "Extract Prompt and Chat": {
      "main": [[{ "node": "Generate Image via DALL-E", "type": "main", "index": 0 }]]
    },
    "Generate Image via DALL-E": {
      "main": [[{ "node": "Send Image to Telegram", "type": "main", "index": 0 }]]
    }
  },
  "active": false,
  "settings": { "executionOrder": "v1" },
  "meta": {},
  "pinData": {}
}
