{
  "name": "TweeterWriter",
  "nodes": [
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4.1",
          "mode": "list",
          "cachedResultName": "GPT-4.1"
        },
        "messages": {
          "values": [
            {
              "content": "=ROLE: You are a twiter post writer, you take an idea and turn it into a short and snappy twitter post.\n\nSTYLE: The twitter posts should not use any emojies, and they should be 1-2 sentances long. They should sound just like a tough blubed out from my head.\n\nEXAMPLE TWEETS: Use these tweets to see how I tweet and talk:\n- There is a new crazy AI Tool that can generate imagews from text, and even turn them into videos, check it out, it's called Kling.ai\n- I just build a new workflow that can completly automate your email inbox, from filtering emails, to autoamtically replying to them, check it out in our AI and Autoamtions community\n- Most people run their business doing everything manually, or hiring people and they wonder why it's so expensive and hard. By the time you spent 18$ on a VA and they spent their whole day replying and filtering emails, someone did all of that in under 2minutes using ai for 0.8 cents and moved on to more important things.\n",
              "role": "system"
            },
            {
              "content": "=Here is my tought:  {{ $json.choices[0].message.content }}"
            }
          ]
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        20,
        260
      ],
      "id": "c6286a9d-ca21-499c-9503-f78c372f3dd0",
      "name": "OpenAI"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.perplexity.ai/chat/completions",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "accept",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"model\": \"sonar-pro\",\n  \"messages\": [\n    {\n      \"role\": \"system\",\n      \"content\": \"Be precise and concise.\"\n    },\n    {\n      \"role\": \"user\",\n      \"content\": \"ROLE: \\n\\nuse this data: {{ $json.chatInput }}\\n\\nCreate only 1 Tweet, that is 80-150 words long, and sounds like a human tought writen down, don't use complex language, instead speak in simple 3rd grade reading level and make it sound liek a human just wrote this tweet.\\n\\nTONE: Talk in basic human like conversational tone, as if you are just having a deep tought and tweeting it out casually.\\n\\nKeep tweet's uniqe, valuable to rtarget readers. and natural \\n\\nThink and look at topics trough unique lenses providing our audience with unique insights from a unique point of view.\\n\\nOUTPUT: You must always return the output structured in a JSON format with 1 string elemt called \\\"Tweet\\\" that will have the 90-150 word tweet\"\n    }\n  ]\n}",
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -180,
        260
      ],
      "id": "0841e1ed-4d5e-4c09-8267-6c092cc55939",
      "name": "PerPlexity"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "11bb08fb-f575-4790-ae0a-81727151e676",
              "name": "input",
              "value": "={{ $json.text }}",
              "type": "string"
            },
            {
              "id": "469adacf-5504-4bc9-acd4-5085b3e0e5cb",
              "name": "memoryKey",
              "value": "={{ $('If').item.json.message.chat.id }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -380,
        260
      ],
      "id": "dafbb10a-f1d0-4687-9ae4-fa11203d4363",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.2,
      "position": [
        -400,
        20
      ],
      "id": "b1b17b8d-8e9e-4b8a-a3fe-7888ef892b88",
      "name": "Telegram Trigger"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "2f5f80a6-7b23-452e-96e1-212551af5cf1",
              "leftValue": "={{ $json.message.voice.file_id }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -200,
        20
      ],
      "id": "10bf5ab7-6082-4962-839a-6926ed21ee99",
      "name": "If"
    },
    {
      "parameters": {
        "resource": "file",
        "fileId": "={{ $json.message.voice.file_id }}"
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        0,
        0
      ],
      "id": "126e11ce-7890-4458-ae67-0e7547e1ab02",
      "name": "Telegram1"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.1,
      "position": [
        360,
        20
      ],
      "id": "50218578-22dd-4aa9-a70a-4e4054732c34",
      "name": "Merge"
    },
    {
      "parameters": {
        "resource": "audio",
        "operation": "transcribe",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        180,
        0
      ],
      "id": "2b5104ee-910f-4eba-9f27-0fce2aa7cf8b",
      "name": "OpenAI1"
    },
    {
      "parameters": {
        "operation": "sendAndWait",
        "chatId": "={{ $('Edit Fields').item.json.memoryKey }}",
        "message": "=Your Tweet:\n{{ $json.message.content }}",
        "approvalOptions": {
          "values": {
            "approvalType": "double"
          }
        },
        "options": {}
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        380,
        260
      ],
      "id": "6fa7a2f1-cd8a-4659-951b-16ad67fb743d",
      "name": "Telegram"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "41f686ff-0cce-4c5f-9f4b-02458a6607ac",
              "leftValue": "={{ $json.data.approved }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -380,
        520
      ],
      "id": "d35ad36c-115e-4fe5-96f4-14cda370fb50",
      "name": "If1"
    },
    {
      "parameters": {
        "text": "={{ $('OpenAI').item.json.message.content }}",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.twitter",
      "typeVersion": 2,
      "position": [
        -200,
        500
      ],
      "id": "3f39bd1d-745c-4b61-9ae6-acaf34dce7cc",
      "name": "X"
    }
  ],
  "pinData": {},
  "connections": {
    "OpenAI": {
      "main": [
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PerPlexity": {
      "main": [
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "PerPlexity",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Telegram1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Telegram1": {
      "main": [
        [
          {
            "node": "OpenAI1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI1": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram": {
      "main": [
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If1": {
      "main": [
        [
          {
            "node": "X",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "62fe4f05-4e6d-45ab-87d4-f638d94c92bc",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "4cdd21f1ff38f4567bbb777962a610435b87dc4ece3ad0e1e9e4e0e637b02a3b"
  },
  "id": "SmMI7iqR4wDpPjbF",
  "tags": []
}