{
  "name": "Automate testing and collect responses via Telegram in Postgres (module \"Quiz\")",
  "nodes": [
    {
      "id": "c6772c56-7373-46f6-b550-106b0912f725",
      "name": "For Tests",
      "type": "n8n-nodes-base.switch",
      "position": [
        1560,
        -380
      ]
    },
    {
      "id": "8bc83292-4eb2-4580-aedb-14ff3f66c40a",
      "name": "Test",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2040,
        -580
      ]
    },
    {
      "id": "57fe6fd6-476c-4516-b230-c8e01d0c9ffb",
      "name": "Randomize questions",
      "type": "n8n-nodes-base.sort",
      "position": [
        2260,
        -580
      ]
    },
    {
      "id": "8c36a7a3-c912-4d3f-87a6-6b700795c8ef",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        3140,
        -580
      ]
    },
    {
      "id": "69461198-edcf-451c-9847-1f359d109c7a",
      "name": "Variables",
      "type": "n8n-nodes-base.set",
      "position": [
        2480,
        -780
      ]
    },
    {
      "id": "0c9b0b8d-70af-4716-b675-9bb3dd426466",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        2700,
        -580
      ]
    },
    {
      "id": "7d5994d0-fb8b-45f3-ae5a-515075b5228d",
      "name": "Question",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2920,
        -580
      ]
    },
    {
      "id": "f277d6f3-8fa0-4704-b82e-e9508cfe92b0",
      "name": "Commands",
      "type": "n8n-nodes-base.switch",
      "position": [
        1180,
        20
      ]
    },
    {
      "id": "465e22be-5d23-4889-8a5e-aca17c4b9a11",
      "name": "Buttons",
      "type": "n8n-nodes-base.switch",
      "position": [
        1180,
        -380
      ]
    },
    {
      "id": "f972e09f-4a96-45e8-977f-62ac6e479613",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        900,
        -180
      ]
    },
    {
      "id": "00300fed-0dfc-469f-a58e-6428f7f97141",
      "name": "List tests",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2480,
        -40
      ]
    },
    {
      "id": "091321f2-80e4-4fe0-8118-b7b0464989d9",
      "name": "Main Menu",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1560,
        -780
      ]
    },
    {
      "id": "4b372e39-86dc-494d-9479-1416564e450a",
      "name": "Update Bot Status on start",
      "type": "n8n-nodes-base.postgres",
      "position": [
        1820,
        -780
      ]
    },
    {
      "id": "b760dbfd-6415-4099-baa0-2d65c6107882",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        0,
        -180
      ]
    },
    {
      "id": "d517ac45-bfc1-4499-92b0-ebd884ccaf95",
      "name": "Initialization",
      "type": "n8n-nodes-base.set",
      "position": [
        460,
        -180
      ]
    },
    {
      "id": "faa1c338-6312-4bfe-a94e-f19dc021bf79",
      "name": "Any questions?",
      "type": "n8n-nodes-base.if",
      "position": [
        2260,
        -380
      ]
    },
    {
      "id": "881939f8-27e9-4b76-8bf0-bb827b058aa6",
      "name": "Delete message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3360,
        -580
      ]
    },
    {
      "id": "d1142c38-0438-4b00-ae0f-edfc9d40b339",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        2480,
        -580
      ]
    },
    {
      "id": "b7ef9d15-b4ba-437a-b1ce-c6c91620366b",
      "name": "Get Questions AND Answers",
      "type": "n8n-nodes-base.postgres",
      "position": [
        2040,
        -780
      ]
    },
    {
      "id": "b76407ba-058d-47a2-9e34-4e934baf9a24",
      "name": "Update Answer",
      "type": "n8n-nodes-base.postgres",
      "position": [
        1820,
        -380
      ]
    },
    {
      "id": "de961e0f-cfc8-4d3d-a22c-bd60bbaeea93",
      "name": "Get Non-Answered Questions",
      "type": "n8n-nodes-base.postgres",
      "position": [
        2040,
        -380
      ]
    },
    {
      "id": "4b242a0a-96b3-4e68-901f-5a51203a1aab",
      "name": "Get Tests",
      "type": "n8n-nodes-base.postgres",
      "position": [
        1820,
        -40
      ]
    },
    {
      "id": "d4578eb5-351e-42da-b8aa-dd7b31cd273a",
      "name": "Union Number with Question",
      "type": "n8n-nodes-base.set",
      "position": [
        2040,
        -40
      ]
    },
    {
      "id": "c41aad19-b64d-4b65-9897-9db4dbe4d173",
      "name": "Union list",
      "type": "n8n-nodes-base.summarize",
      "position": [
        2260,
        -40
      ]
    },
    {
      "id": "34ce463e-0a46-4c18-ad0c-93eb27451d1a",
      "name": "Get Test",
      "type": "n8n-nodes-base.postgres",
      "position": [
        1820,
        -580
      ]
    },
    {
      "id": "c352c16b-c407-4a66-9157-26b8b7ccf2e2",
      "name": "Result Test",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2700,
        -380
      ]
    },
    {
      "id": "3cd53065-2bb5-42e6-8052-e0d8145a6d33",
      "name": "Calculate answers",
      "type": "n8n-nodes-base.postgres",
      "position": [
        2480,
        -380
      ]
    },
    {
      "id": "fd55a57b-e510-4f5e-9739-a83a7eca457b",
      "name": "Upsert pred Answer",
      "type": "n8n-nodes-base.postgres",
      "position": [
        2920,
        -780
      ]
    },
    {
      "id": "0fcc8a1d-f643-4999-9508-6992149d913b",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -20,
        160
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "abdcb075-fe51-4ae0-b7c5-14c42b8db097",
      "name": "Variables TG",
      "type": "n8n-nodes-base.set",
      "position": [
        220,
        -180
      ]
    },
    {
      "id": "d8ed0d39-d250-436f-b5fb-ef727d4e4fb0",
      "name": "Is Start?",
      "type": "n8n-nodes-base.if",
      "position": [
        680,
        -180
      ]
    },
    {
      "id": "b9db0964-0e46-4335-859e-5a9d11b2132c",
      "name": "Welcome Message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        680,
        -380
      ]
    },
    {
      "id": "f3319cfd-6d30-4efd-b322-1c8eb46302a3",
      "name": "Error",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1560,
        160
      ]
    },
    {
      "id": "5cf3c126-a6a9-4d25-98d2-191af91b12d9",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -440,
        -420
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "40325b66-5ac3-4275-b00b-d097834dfe15",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -440,
        -180
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "f31c4ec7-3651-4c02-8c3c-8dd2f135a291",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -440,
        160
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    }
  ],
  "connections": {
    "Code": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Test": {
      "main": [
        [
          {
            "node": "Get Questions AND Answers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Delete message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Upsert pred Answer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Buttons",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Commands",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Buttons": {
      "main": [
        [
          {
            "node": "Main Menu",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "For Tests",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Commands": {
      "main": [
        [
          {
            "node": "Get Tests",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Test": {
      "main": [
        [
          {
            "node": "Test",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Question": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "For Tests": {
      "main": [
        [
          {
            "node": "Get Tests",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Test",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Update Answer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Tests": {
      "main": [
        [
          {
            "node": "Union Number with Question",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Start?": {
      "main": [
        [
          {
            "node": "Welcome Message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Main Menu": {
      "main": [
        [
          {
            "node": "Update Bot Status on start",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Variables": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Union list": {
      "main": [
        [
          {
            "node": "List tests",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Variables TG": {
      "main": [
        [
          {
            "node": "Initialization",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Answer": {
      "main": [
        [
          {
            "node": "Get Non-Answered Questions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Any questions?": {
      "main": [
        [
          {
            "node": "Randomize questions",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Calculate answers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Initialization": {
      "main": [
        [
          {
            "node": "Is Start?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Variables TG",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate answers": {
      "main": [
        [
          {
            "node": "Result Test",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upsert pred Answer": {
      "main": [
        [
          {
            "node": "Question",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Randomize questions": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          },
          {
            "node": "Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Questions AND Answers": {
      "main": [
        [
          {
            "node": "Randomize questions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Non-Answered Questions": {
      "main": [
        [
          {
            "node": "Any questions?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Union Number with Question": {
      "main": [
        [
          {
            "node": "Union list",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}