JSON

{
  "name": "Image edits trand",
  "nodes": [
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        0
      ],
      "id": "216f6f50-f0d0-4168-ae3a-18cc5f7f2ef5",
      "name": "Telegram Trigger",
      "webhookId": "fddb337a-7cfd-4e5f-90a5-bdf697ac703e",
      "credentials": {
        "telegramApi": {
          "id": "IeRb7xO9XG0TzbvH",
          "name": "Telegram account 2"
        }
      }
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.message.photo[3].file_id }}",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "id": "946f5270-ca4f-40d1-9b45-9372966b8c42"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "image"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        200,
        0
      ],
      "id": "c2617e29-d4db-4243-86c9-6b8956a1b2a5",
      "name": "Switch"
    },
    {
      "parameters": {
        "resource": "file",
        "fileId": "={{ $('Telegram Trigger').item.json.message.photo[3].file_id }}"
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1120,
        -220
      ],
      "id": "5bbd8a3d-a7af-4147-a118-03e17b0bfe30",
      "name": "Telegram",
      "webhookId": "c1217bdd-738a-4bad-a3ce-0be7c9695013",
      "credentials": {
        "telegramApi": {
          "id": "IeRb7xO9XG0TzbvH",
          "name": "Telegram account 2"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "<https://api.openai.com/v1/images/edits>",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer $OpenAiAPI"
            }
          ]
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "name": "model",
              "value": "gpt-image-1"
            },
            {
              "name": "prompt",
              "value": "={{ $('Edit Fields').item.json.prompt }}"
            },
            {
              "parameterType": "formBinaryData",
              "name": "image[]",
              "inputDataFieldName": "data"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2040,
        -80
      ],
      "id": "1031f5f4-1c87-4202-a8e8-6c208672748d",
      "name": "HTTP Request1"
    },
    {
      "parameters": {
        "operation": "toBinary",
        "sourceProperty": "data[0].b64_json",
        "options": {}
      },
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        2200,
        -80
      ],
      "id": "b83c0b13-a70e-4df4-ba3c-a45e1ef14bb1",
      "name": "Convert to File1"
    },
    {
      "parameters": {
        "url": "=https://api.telegram.org/bot<..>/getFile?file_id={{ $json.result.file_id }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1320,
        -80
      ],
      "id": "58c289ed-0dca-4458-9c15-e8b7ea93cfe7",
      "name": "HTTP Request"
    },
    {
      "parameters": {
        "url": "=https://api.telegram.org/file/bot<..>/{{ $json.result.file_path }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1520,
        -80
      ],
      "id": "0ed02223-f667-40bd-9e36-8e7df967cb65",
      "name": "HTTP Request2"
    },
    {
      "parameters": {
        "name": "={{ $('Function').item.json.RandomNumber }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "value": "1u3lTRk4YQsmQKVTYpUFEMxJTf_JraGdh",
          "mode": "list",
          "cachedResultName": "n8n image ",
          "cachedResultUrl": "<https://drive.google.com/drive/folders/1u3lTRk4YQsmQKVTYpUFEMxJTf_JraGdh>"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        1720,
        -80
      ],
      "id": "22840a59-d13e-441e-8ed9-1d50577d2519",
      "name": "Google Drive",
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "U7ttwq1fLdQnziYY",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "operation": "download",
        "fileId": {
          "__rl": true,
          "value": "={{ $json.id }}",
          "mode": "id"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        1880,
        -80
      ],
      "id": "322b375c-7110-42a4-9b35-dadd4ab5d265",
      "name": "Google Drive1",
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "U7ttwq1fLdQnziYY",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "operation": "sendPhoto",
        "chatId": "={{ $('Telegram Trigger').item.json.message.from.id }}",
        "binaryData": true,
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        2380,
        -80
      ],
      "id": "ca384b18-8c85-43e5-ab55-6903179a2dd8",
      "name": "Telegram1",
      "webhookId": "3381faa5-71dc-455e-b7ad-be385ae9453f",
      "credentials": {
        "telegramApi": {
          "id": "IeRb7xO9XG0TzbvH",
          "name": "Telegram account 2"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "c4930be5-ee6f-4593-8390-4977ad72dc2b",
              "name": "prompt",
              "value": "=Take an extremely ordinary and unremarkable iPhone selfie, with no clear subject or sense of composition-just a quick accidental snapshot. The photo has slight motion blur and uneven lighting from streetlights or indoor lamps, causing mild overexposure in some areas. The angle is cute and giving the picture a deliberately mediocre feel, as if it was taken absentmindedly while pulling the phone from a pocket.\\nThe main character is [uploaded person], and [{{ $('Switch').item.json.message.caption }}] stands next to him/her as best friend, both caught in a casual, imperfect moment. The background shows a lively los angeles street light at night, with neon lights, traffic, and blurry figures passing by. The overall look is intentionally plain and random, capturing the authentic vibe of a poorly composed, spontaneous iPhone selfie.",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        960,
        -220
      ],
      "id": "37551b9a-70b7-40a2-a688-4c1ac234d737",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "functionCode": "items[0].json.RandomNumber = Math.floor(Math.random() * 1000000) + 1;\\nreturn items;\\n"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        800,
        -220
      ],
      "id": "c71b58c3-c7b5-40fc-92fb-bf341358a718"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "2b368085-8a47-499b-a6c9-6f2b6b06f607",
              "leftValue": "={{ $json.message.caption }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        420,
        60
      ],
      "id": "38be6208-a75e-4448-aff4-cbaceb3b4121",
      "name": "If"
    },
    {
      "parameters": {
        "chatId": "={{ $json.message.from.id }}",
        "text": "Please write a caption on the photo.",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        800,
        180
      ],
      "id": "6e56f469-e60b-4b25-b310-d765f0f9165c",
      "name": "Telegram2",
      "webhookId": "6a7cd0f4-8dbe-4048-b46f-f339d76b80bb",
      "credentials": {
        "telegramApi": {
          "id": "IeRb7xO9XG0TzbvH",
          "name": "Telegram account 2"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request1": {
      "main": [
        [
          {
            "node": "Convert to File1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "HTTP Request2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request2": {
      "main": [
        [
          {
            "node": "Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive": {
      "main": [
        [
          {
            "node": "Google Drive1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive1": {
      "main": [
        [
          {
            "node": "HTTP Request1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File1": {
      "main": [
        [
          {
            "node": "Telegram1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Function": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Telegram2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "6c5f4991-7e45-4d8e-aaef-b76c23348aee",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "e1485609e3a529ce19c0cba5673e3c7b6c6d678ebe8fc654240ac82d90258c36"
  },
  "id": "xv7Qqp74CIS8zGMf",
  "tags": [
    {
      "createdAt": "2025-06-17T00:51:04.407Z",
      "updatedAt": "2025-06-17T00:51:04.407Z",
      "id": "5eVXOF610yt5v980",
      "name": "youtube"
    },
    {
      "createdAt": "2025-06-23T05:43:47.962Z",
      "updatedAt": "2025-06-23T05:43:47.962Z",
      "id": "NZszbBLH7SZhgiU0",
      "name": "noor tech lab"
    },
    {
      "createdAt": "2025-06-16T01:51:54.189Z",
      "updatedAt": "2025-06-16T01:51:54.189Z",
      "id": "A7PIuKEsrNk2dSfr",
      "name": "test"
    }
  ]
}

Rarndom code:

items[0].json.RandomNumber = Math.floor(Math.random() * 1000000) + 1;
return items;

Get image Path:

[<https://api.telegram.org/bot>](<https://api.telegram.org/bot>)<..>/getFile?file_id={{ $json.result.file_id }}

downlod URL:

[<https://api.telegram.org/file/bot>](<https://api.telegram.org/file/bot>)<..>/{{ $json.result.file_path }}

prompt:

Take an extremely ordinary and unremarkable iPhone selfie, with no clear subject or sense of composition-just a quick accidental snapshot. The photo has slight motion blur and uneven lighting from streetlights or indoor lamps, causing mild overexposure in some areas. The angle is cute and giving the picture a deliberately mediocre feel, as if it was taken absentmindedly while pulling the phone from a pocket. The main character is [uploaded person], and [{{ $('Switch').item.json.message.caption }}] stands next to him/her as best friend, both caught in a casual, imperfect moment. The background shows a lively los angeles street light at night, with neon lights, traffic, and blurry figures passing by. The overall look is intentionally plain and random, capturing the authentic vibe of a poorly composed, spontaneous iPhone selfie.