{
  "name": "Telegram giveaways among channel subscribers (Module \"Giveaway\")",
  "nodes": [
    {
      "id": "a88a431f-4277-4ed0-91eb-17560a31b832",
      "name": "Sticky Note14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        700,
        560
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "0824d027-e77d-40a8-a8ce-0cbe035e1328",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1160,
        560
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "6b98af66-355c-417f-b0da-524c29fdd448",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -500,
        1340
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "e08ddd2f-02b7-4b66-b701-7e9af06907e4",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1840,
        1560
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "09741b6c-9357-4008-ad12-9f00ccec4338",
      "name": "Initialization",
      "type": "n8n-nodes-base.set",
      "position": [
        -40,
        980
      ]
    },
    {
      "id": "fffb74ce-86dc-4287-bbb6-a8f2ddafe091",
      "name": "Welcome message Referal",
      "type": "n8n-nodes-base.telegram",
      "position": [
        740,
        580
      ]
    },
    {
      "id": "187122c5-8089-4745-8f3e-7cae49fea60f",
      "name": "Welcome message Manager",
      "type": "n8n-nodes-base.telegram",
      "position": [
        740,
        780
      ]
    },
    {
      "id": "7a4135f6-fb98-43ca-b85a-a95f19a84de9",
      "name": "Upsert bot status on START",
      "type": "n8n-nodes-base.postgres",
      "position": [
        940,
        780
      ]
    },
    {
      "id": "2483ca3f-7158-455c-9250-65121bb16387",
      "name": "Add participant in Giveaway",
      "type": "n8n-nodes-base.postgres",
      "position": [
        1220,
        580
      ]
    },
    {
      "id": "cf7bc2c4-4d6c-42aa-a53a-8f3cf9b60079",
      "name": "Get Bot Status",
      "type": "n8n-nodes-base.postgres",
      "position": [
        740,
        980
      ]
    },
    {
      "id": "9bbf4db8-33e3-4cc1-9e6c-59f4552cd62e",
      "name": "Start?",
      "type": "n8n-nodes-base.if",
      "position": [
        160,
        980
      ]
    },
    {
      "id": "7b56225d-eab4-42d8-bb75-11afda52f1d2",
      "name": "Button?",
      "type": "n8n-nodes-base.if",
      "position": [
        340,
        980
      ]
    },
    {
      "id": "a5b60598-b688-467c-822b-6dc28a1ba4f2",
      "name": "Referal?",
      "type": "n8n-nodes-base.if",
      "position": [
        560,
        780
      ]
    },
    {
      "id": "ad57cb94-9804-4296-82b4-4b683c02295e",
      "name": "Define flow",
      "type": "n8n-nodes-base.switch",
      "position": [
        940,
        980
      ]
    },
    {
      "id": "7dd5490c-633b-4727-8205-6b2945ec8ddc",
      "name": "Commands",
      "type": "n8n-nodes-base.switch",
      "position": [
        1220,
        980
      ]
    },
    {
      "id": "60748e12-5dc3-4d5f-aa1f-f4c3a904eac9",
      "name": "List Channels",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1440,
        980
      ]
    },
    {
      "id": "9ddfacd6-c3e3-4c01-91a5-8752b3bd8b31",
      "name": "Add channel",
      "type": "n8n-nodes-base.postgres",
      "position": [
        1220,
        1160
      ]
    },
    {
      "id": "bb74bc42-ef8b-4012-b7df-4bd12044652f",
      "name": "Buttons",
      "type": "n8n-nodes-base.switch",
      "position": [
        940,
        1820
      ]
    },
    {
      "id": "d7dff496-0cb0-4621-bb6e-08655f52829d",
      "name": "Create Giveaway",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1440,
        1820
      ]
    },
    {
      "id": "4d86846a-9ace-47c7-8147-9520e7ecdb8f",
      "name": "Request New Channel",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1440,
        1160
      ]
    },
    {
      "id": "6bd742a7-3d4f-4fd3-96f1-11919be7ea00",
      "name": "Channel Exists",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1440,
        1360
      ]
    },
    {
      "id": "38eacfc8-96d8-4ad9-8e3f-acd9b830467b",
      "name": "Define Step Giveaway",
      "type": "n8n-nodes-base.switch",
      "position": [
        1220,
        1580
      ]
    },
    {
      "id": "181f2e2e-e8c6-4b38-91c9-9a81238ef12a",
      "name": "Get Participants",
      "type": "n8n-nodes-base.postgres",
      "position": [
        1660,
        1580
      ]
    },
    {
      "id": "8355aa35-1d3a-4a88-8b54-4639e1f095be",
      "name": "Random Participants",
      "type": "n8n-nodes-base.sort",
      "position": [
        1880,
        1580
      ]
    },
    {
      "id": "3af0984f-f383-4fe1-bad1-4841b792c499",
      "name": "Get Channels",
      "type": "n8n-nodes-base.postgres",
      "position": [
        2080,
        1580
      ]
    },
    {
      "id": "32508ab0-b317-45f5-a683-217d2892b9ac",
      "name": "Union Statuses",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        2500,
        1580
      ]
    },
    {
      "id": "34162676-517d-40c8-af24-280d521a2fc1",
      "name": "Check Success?",
      "type": "n8n-nodes-base.if",
      "position": [
        2700,
        1580
      ]
    },
    {
      "id": "8ee97c98-5286-4850-912f-f4516e37d733",
      "name": "Check Success",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2920,
        1160
      ]
    },
    {
      "id": "bcf02704-7d88-49a1-8c33-024d99131ec5",
      "name": "Check Failed",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2920,
        1360
      ]
    },
    {
      "id": "0df05a53-83e5-4a39-9d68-a4d4cd22414d",
      "name": "SMS for Winner",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2920,
        1580
      ]
    },
    {
      "id": "7a161f59-7603-4074-9e9d-2ff8b99b7b73",
      "name": "SMS for Manager",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3100,
        1580
      ]
    },
    {
      "id": "97d03ad2-9adb-4364-9e50-bd1d53529a20",
      "name": "Delete Channels",
      "type": "n8n-nodes-base.postgres",
      "position": [
        3300,
        1160
      ]
    },
    {
      "id": "cbdda4cb-879f-472b-8de7-9f374fa690ef",
      "name": "Delete Participants",
      "type": "n8n-nodes-base.postgres",
      "position": [
        3300,
        1360
      ]
    },
    {
      "id": "5b72da60-2a11-44f9-a59a-2f702eeaec38",
      "name": "End Message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3480,
        1580
      ]
    },
    {
      "id": "3bc4e559-c026-4096-860e-ae7aa6045647",
      "name": "Update bot status on GIVEAWAY RUN",
      "type": "n8n-nodes-base.postgres",
      "position": [
        1220,
        1820
      ]
    },
    {
      "id": "6e137946-d9a6-43e9-bb12-3f9d3f13424b",
      "name": "Update bot status on GIVEAWAY REQUEST CHANNEL",
      "type": "n8n-nodes-base.postgres",
      "position": [
        1660,
        980
      ]
    },
    {
      "id": "5d00b729-3c03-4ca3-8a58-b9338d736742",
      "name": "Update bot status and referal",
      "type": "n8n-nodes-base.postgres",
      "position": [
        940,
        580
      ]
    },
    {
      "id": "83c8e09c-9f46-4bf5-9401-744c4e229338",
      "name": "Update bot status on START ",
      "type": "n8n-nodes-base.postgres",
      "position": [
        3300,
        1580
      ]
    },
    {
      "id": "b417847e-480c-485b-b19c-f06c98cb43cd",
      "name": "Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2300,
        1580
      ]
    },
    {
      "id": "4b585aea-96f3-4745-a821-736ff0525387",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -960,
        680
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "3fdb6f7f-7bfc-4184-b5e9-a93be2ca44c8",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -960,
        1000
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "d587af11-5501-4853-8ca7-4a5834a896f9",
      "name": "Variables TG",
      "type": "n8n-nodes-base.set",
      "position": [
        -280,
        980
      ]
    },
    {
      "id": "26b42428-0d68-4760-a9ec-e62c505a995f",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -500,
        980
      ]
    },
    {
      "id": "ddd0b0a5-ce75-4ed4-800b-7e118b7a507d",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -960,
        1340
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    }
  ],
  "connections": {
    "Start?": {
      "main": [
        [
          {
            "node": "Referal?",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Button?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Button?": {
      "main": [
        [
          {
            "node": "Buttons",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Bot Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Buttons": {
      "main": [
        [
          {
            "node": "Update bot status on GIVEAWAY RUN",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Commands": {
      "main": [
        [
          {
            "node": "List Channels",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Referal?": {
      "main": [
        [
          {
            "node": "Welcome message Referal",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Welcome message Manager",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram": {
      "main": [
        [
          {
            "node": "Union Statuses",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add channel": {
      "main": [
        [
          {
            "node": "Request New Channel",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Channel Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Define flow": {
      "main": [
        [
          {
            "node": "Commands",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Add channel",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Define Step Giveaway",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Channels": {
      "main": [
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Variables TG": {
      "main": [
        [
          {
            "node": "Initialization",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Success": {
      "main": [
        []
      ]
    },
    "List Channels": {
      "main": [
        [
          {
            "node": "Update bot status on GIVEAWAY REQUEST CHANNEL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Success?": {
      "main": [
        [
          {
            "node": "Check Success",
            "type": "main",
            "index": 0
          },
          {
            "node": "SMS for Winner",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Check Failed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Bot Status": {
      "main": [
        [
          {
            "node": "Define flow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Initialization": {
      "main": [
        [
          {
            "node": "Start?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SMS for Winner": {
      "main": [
        [
          {
            "node": "SMS for Manager",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Union Statuses": {
      "main": [
        [
          {
            "node": "Check Success?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Delete Channels": {
      "main": [
        []
      ]
    },
    "SMS for Manager": {
      "main": [
        [
          {
            "node": "Delete Channels",
            "type": "main",
            "index": 0
          },
          {
            "node": "Delete Participants",
            "type": "main",
            "index": 0
          },
          {
            "node": "Update bot status on START ",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Participants": {
      "main": [
        [
          {
            "node": "Random Participants",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Variables TG",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Delete Participants": {
      "main": [
        []
      ]
    },
    "Random Participants": {
      "main": [
        [
          {
            "node": "Get Channels",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Define Step Giveaway": {
      "main": [
        [
          {
            "node": "List Channels",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Participants",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Welcome message Manager": {
      "main": [
        [
          {
            "node": "Upsert bot status on START",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Welcome message Referal": {
      "main": [
        [
          {
            "node": "Update bot status and referal",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upsert bot status on START": {
      "main": [
        []
      ]
    },
    "Add participant in Giveaway": {
      "main": [
        []
      ]
    },
    "Update bot status on START ": {
      "main": [
        [
          {
            "node": "End Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update bot status and referal": {
      "main": [
        [
          {
            "node": "Add participant in Giveaway",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update bot status on GIVEAWAY RUN": {
      "main": [
        [
          {
            "node": "Create Giveaway",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update bot status on GIVEAWAY REQUEST CHANNEL": {
      "main": [
        []
      ]
    }
  }
}