{
  "name": "Telegram bot with Supabase memory and OpenAI assistant integration",
  "nodes": [
    {
      "id": "9cc26a42-eb43-40c4-b507-cbaf187a5e15",
      "name": "Get New Message",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        1120,
        500
      ]
    },
    {
      "id": "098b6fcf-7cb6-4730-8892-949fedc946b3",
      "name": "OPENAI - Create thread",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1740,
        640
      ]
    },
    {
      "id": "fa157f8c-b776-4b20-bfaf-c17460383505",
      "name": "Create User",
      "type": "n8n-nodes-base.supabase",
      "position": [
        1900,
        640
      ]
    },
    {
      "id": "115e417f-5962-409b-8adf-ff236eb9ce2e",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        2080,
        500
      ]
    },
    {
      "id": "ba5c7385-8c80-43c8-9de2-430175bda70b",
      "name": "OPENAI - Send message",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2240,
        500
      ]
    },
    {
      "id": "024832bc-3d42-4879-a57f-b23e962b4c69",
      "name": "OPENAI - Run assistant",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2440,
        500
      ]
    },
    {
      "id": "bc191e2b-15f4-45b7-af2e-19ed1639b7f5",
      "name": "OPENAI - Get messages",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2640,
        500
      ]
    },
    {
      "id": "c22e05e5-f0a7-4a09-a864-acfc58469b30",
      "name": "Send Message to User",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2840,
        500
      ]
    },
    {
      "id": "0673be1f-3cae-42a0-9c62-1ed570859043",
      "name": "If User exists",
      "type": "n8n-nodes-base.if",
      "position": [
        1560,
        500
      ]
    },
    {
      "id": "a4916f54-ae6b-495d-979b-92dca965e3bb",
      "name": "Find User",
      "type": "n8n-nodes-base.supabase",
      "position": [
        1360,
        500
      ]
    },
    {
      "id": "6d01d7ed-e96b-47cf-9a5f-46608031baa2",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1300,
        800
      ],
      "parameters": {
        "width": 600.723278204605,
        "height": 213.15921994594194,
        "content": "SQL query to create table in Supabase:\n\n```\ncreate table\n  public.telegram_users (\n    id uuid not null default gen_random_uuid (),\n    date_created timestamp with time zone not null default (now() at"
      }
    },
    {
      "id": "1a996da0-6022-48d7-ba40-1d137547a3d7",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2340,
        360
      ],
      "parameters": {
        "width": 282.075050779723,
        "height": 80,
        "content": "Create assistant in [OpenAI](https://platform.openai.com/assistants).\n\n**Specify own assistant id here**\n"
      }
    },
    {
      "id": "b24d2008-7950-41f0-a7fa-50360c0c6854",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1040,
        380
      ],
      "parameters": {
        "width": 235.09282368774151,
        "height": 80,
        "content": "Create own Telegram bot in [Botfather bot](https://t.me/botfather)"
      }
    },
    {
      "id": "9eb2491e-5ad9-4015-8ed9-611e72924503",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1300,
        680
      ],
      "parameters": {
        "width": null,
        "height": 80,
        "content": "Create table in [Supabase](https://supabase.com) with SQL query"
      }
    },
    {
      "id": "884b5a1b-007c-4752-becc-46c8fc58db92",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        200,
        120
      ],
      "parameters": {
        "width": 280.2462120317618,
        "height": 438.5821431288714,
        "content": "### Set up steps\n1. **Create a Telegram Bot** using the [Botfather](https://t.me/botfather) and obtain the bot token.\n2. **Set up Supabase:**\n\t1. Create a new project and generate a ```SUPABASE_URL```"
      }
    },
    {
      "id": "02db77ac-4909-4a56-a558-03c86d8b8552",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        200,
        -400
      ],
      "parameters": {
        "width": 636.2128494576581,
        "height": 494.9629292914819,
        "content": "![5min Logo](https://cflobdhpqwnoisuctsoc.supabase.co/storage/v1/object/public/my_storage/Untitled%20(1500%20x%20300%20px).png)\n## AI Telegram Bot with Supabase memory\n**Made by [Mark Shcherbakov](htt"
      }
    },
    {
      "id": "a991a7c9-ea5f-4a25-aa92-6dc2fce11b05",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        500,
        120
      ],
      "parameters": {
        "width": 330.5152611046425,
        "height": 240.6839895136402,
        "content": "### ... or watch set up video [5 min]\n[![Youtube Thumbnail](https://cflobdhpqwnoisuctsoc.supabase.co/storage/v1/object/public/my_storage/Youtube%20thumb%20(3).png)](https://www.youtube.com/watch?v=kS4"
      }
    }
  ],
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "OPENAI - Send message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find User": {
      "main": [
        [
          {
            "node": "If User exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create User": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "If User exists": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "OPENAI - Create thread",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get New Message": {
      "main": [
        [
          {
            "node": "Find User",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OPENAI - Get messages": {
      "main": [
        [
          {
            "node": "Send Message to User",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OPENAI - Send message": {
      "main": [
        [
          {
            "node": "OPENAI - Run assistant",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OPENAI - Create thread": {
      "main": [
        [
          {
            "node": "Create User",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OPENAI - Run assistant": {
      "main": [
        [
          {
            "node": "OPENAI - Get messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}