{
  "name": "Project: HITL via Telegram",
  "nodes": [
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        0
      ],
      "id": "d4837de8-c5c8-4f87-bc24-9828c5022559",
      "name": "Telegram Trigger",
      "webhookId": "3820d7c0-5201-49bb-9fe4-7e11d5bb6e12",
      "credentials": {
        "telegramApi": {
          "id": "DA4UGj08LgRnRgDf",
          "name": "Catalin Telegram Bot"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.message.text }}",
        "options": {
          "systemMessage": "You are a tweet writer. Write a tweet based on the user input. Output only the tweet content and nothing else."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.2,
      "position": [
        208,
        0
      ],
      "id": "27afd5a3-7b22-4b58-9198-89a333dc93bb",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        400,
        400
      ],
      "id": "00592149-8949-4726-a03a-9461ad61817a",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "id": "xHWDVrLvQFklSodD",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "operation": "sendAndWait",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "message": "=This is the proposed tweet:\n\n{{ $json.output }}",
        "responseType": "freeText",
        "options": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        560,
        0
      ],
      "id": "bbdb8623-6546-46e3-bbc2-3d27f9fbe249",
      "name": "Send message and wait for response",
      "webhookId": "76591d26-1894-4caf-875a-0c6bd50c5706",
      "credentials": {
        "telegramApi": {
          "id": "DA4UGj08LgRnRgDf",
          "name": "Catalin Telegram Bot"
        }
      }
    },
    {
      "parameters": {
        "inputText": "={{ $json.data.text }}",
        "categories": {
          "categories": [
            {
              "category": "true",
              "description": "The user agrees with the tweet"
            },
            {
              "category": "end",
              "description": "The user wants to end the process"
            },
            {
              "category": "false",
              "description": "The user disagrees with the tweet and wants modifications"
            }
          ]
        },
        "options": {
          "systemPromptTemplate": "The user is deciding whether to send a tweet or not. They will provide you with a decision in the form of text.\n\nPlease classify the text provided by the user into one of the following categories: {categories}, and use the provided formatting instructions below. Don't explain, and only output the json."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.textClassifier",
      "typeVersion": 1.1,
      "position": [
        768,
        0
      ],
      "id": "c31ed995-2c1d-450c-8750-ebf8f342178c",
      "name": "Text Classifier"
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "text": "The tweet has bee sent",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1344,
        -256
      ],
      "id": "b0a4702d-9387-4c76-85bb-280a06ed0bdf",
      "name": "Send a text message",
      "webhookId": "0798b0ae-500d-4441-b040-05ddda5e3bce",
      "credentials": {
        "telegramApi": {
          "id": "DA4UGj08LgRnRgDf",
          "name": "Catalin Telegram Bot"
        }
      }
    },
    {
      "parameters": {
        "content": "## Send tweet",
        "height": 144,
        "width": 192
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1088,
        -240
      ],
      "typeVersion": 1,
      "id": "528a3fda-6173-4f90-90d0-4e0bdd1d0508",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "text": "Tweet discarded",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1344,
        -32
      ],
      "id": "6d67761c-f5a1-459b-9e95-6096847f1506",
      "name": "Send a text message1",
      "webhookId": "9106557d-fe7d-40f7-b749-ae7aa0ed299d",
      "credentials": {
        "telegramApi": {
          "id": "DA4UGj08LgRnRgDf",
          "name": "Catalin Telegram Bot"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Original tweet:\n{{ $('AI Agent').item.json.output }}\n\n{{ $json.data.text }}",
        "options": {
          "systemMessage": "You are a reviewer agent. You take the initial tweet and the user input, and update the tweet accordingly"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.2,
      "position": [
        1120,
        112
      ],
      "id": "a76c3743-ac96-4a7f-a1bb-7d69c1886d5b",
      "name": "AI Agent1"
    }
  ],
  "pinData": {},
  "connections": {
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Text Classifier",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Send message and wait for response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send message and wait for response": {
      "main": [
        [
          {
            "node": "Text Classifier",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Text Classifier": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send a text message1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent1": {
      "main": [
        [
          {
            "node": "Send message and wait for response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "79c2e8fe-a2a2-4766-a5bb-90fdfd7bc71d",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "281c34c03b9c41f054c536eeb966e9e503918cf7f00e3bc32a5ff9cca85ca255"
  },
  "id": "o7mGAojMKddeE4cS",
  "tags": []
}