{
  "id": "cwQ0qCmS7slatyQr",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "2 Email to Long-Form Thread",
  "tags": [],
  "nodes": [
    {
      "id": "e9dedaa0-bdb0-4af4-b406-aea281223332",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -32,
        192
      ],
      "parameters": {
        "color": 6,
        "width": 1008,
        "height": 1104,
        "content": "# Email to Long-Form Thread\nYou can post text, images, and videos, embedded within your long-form thread. \nThis simple template shows text-only long-form threads, but it's easy to add images/videos.\nSimply fill in the `mediaUrls` parameter with a publicly accessible link to your image/video.\n\n## How this template works\n- Send yourself an email with title `thread` with your idea\n- This automation detects the email\n- AI writes a long-form thread expanding on your idea\n- Blotato posts to Twitter, Threads, and Bluesky\n- (Optional) you can also post to many other social platforms via Blotato\n\n## Setup\n- Sign up for Blotato.com\n- Generate Blotato API Key by going to Settings > API > Generate API Key (paid feature only)\n- Ensure you have \"Verified Community Nodes\" enabled in your n8n Admin Panel. Install \"Blotato\" community node.\n- Create credential for Blotato.\n- Connect your Google Drive to n8n: https://docs.n8n.io/integrations/builtin/credentials/google/oauth-single-service\n- Complete the 3 setup steps shown in BROWN sticky notes in this template"
      },
      "typeVersion": 1
    },
    {
      "id": "5b192c80-77ed-40ab-8ffb-0a867af411d2",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        32,
        960
      ],
      "parameters": {
        "color": 2,
        "width": 224,
        "height": 112,
        "content": "# Setup 1\nSelect your Gmail credential"
      },
      "typeVersion": 1
    },
    {
      "id": "d891b0a9-e71c-4928-9488-a338e360069a",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        336,
        1088
      ],
      "parameters": {
        "color": 2,
        "width": 224,
        "height": 112,
        "content": "# Setup 2\nSelect your OpenAI credential"
      },
      "typeVersion": 1
    },
    {
      "id": "97b75259-0519-4b1f-87ce-db3b8d3a7b0d",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2192,
        352
      ],
      "parameters": {
        "color": 7,
        "width": 608,
        "height": 624,
        "content": "# Platform Specific Notes\n\n## Twitter\nYou can post text, images, and videos. You can post a long-form thread by clicking \"Show Advanced Settings\". Check out best practices and troubleshooting FAQs:\nhttps://help.blotato.com/platforms/twitter\n\n## Threads\nYou can post text, images, and videos. You can post a long-form thread by clicking \"Show Advanced Settings\". Check out best practices and troubleshooting FAQs:\nhttps://help.blotato.com/platforms/threads\n\n## Bluesky\nYou can post text, images, and videos. You can post a long-form thread by clicking \"Show Advanced Settings\". Check out best practices and troubleshooting FAQs:\nhttps://help.blotato.com/platforms/bluesky\n\n## Need More Help?\n\nLog into Blotato.com\nClick support button in bottom right corner.\nSabrina Ramonov\ud83c\udf44 replies within 24 hours most weekdays."
      },
      "typeVersion": 1
    },
    {
      "id": "21af5f13-9d5c-40e1-ace5-e630c4886683",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        784,
        1072
      ],
      "parameters": {
        "color": 3,
        "width": 150,
        "height": 112,
        "content": "# Don't Touch"
      },
      "typeVersion": 1
    },
    {
      "id": "63f02f26-0b3b-46dc-8995-1a5bfd222844",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        704,
        960
      ],
      "parameters": {
        "autoFix": true,
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"additionalProperties\": false,\n  \"required\": [\"text\", \"mediaUrls\", \"additionalPosts\"],\n  \"properties\": {\n    \"text\": { \"type\": \"string\" },\n    \"mediaUrls\": {\n      \"type\": \"array\",\n      \"items\": { \"type\": \"string\" }\n    },\n    \"additionalPosts\": {\n      \"type\": \"array\",\n      \"items\": {\n        \"type\": \"object\",\n        \"additionalProperties\": false,\n        \"required\": [\"text\", \"mediaUrls\"],\n        \"properties\": {\n          \"text\": { \"type\": \"string\" },\n          \"mediaUrls\": {\n            \"type\": \"array\",\n            \"items\": { \"type\": \"string\" }\n          }\n        }\n      }\n    }\n  }\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "290566ee-24ce-4dca-9993-1822ec6f8305",
      "name": "OpenAI Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        352,
        944
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1",
          "cachedResultName": "gpt-4.1"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "865c6017-5092-46a3-8302-627868d24fe7",
      "name": "OpenAI Backup",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        496,
        944
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "chatgpt-4o-latest",
          "cachedResultName": "chatgpt-4o-latest"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "972d51b1-9ccf-47fa-a4a3-1d3b2a408169",
      "name": "Mark email as read",
      "type": "n8n-nodes-base.gmail",
      "onError": "continueErrorOutput",
      "position": [
        1392,
        1232
      ],
      "parameters": {
        "messageId": "={{ $('New Email Subject \"Thread\"').item.json.id }}",
        "operation": "markAsRead"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "02653ad7-2cef-49bd-b8ac-6ce5c1378e66",
      "name": "OpenAI Fixer",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        576,
        1104
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c5e119bd-43de-4d6b-9d82-81d40eb0dd53",
      "name": "New Email Subject \"Thread\"",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        96,
        768
      ],
      "parameters": {
        "filters": {
          "q": "subject:thread",
          "sender": "",
          "readStatus": "unread"
        },
        "pollTimes": {
          "item": [
            {
              "mode": "everyHour"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "902edcae-fe4a-471f-8fd7-af6f658dd81e",
      "name": "AI Writes Thread",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        528,
        768
      ],
      "parameters": {
        "text": "=# WRITING STYLE\n\nHere\u2019s how you always write:\n\n<writing_style>\n\n- Your writing style is spartan and informative.\n- Use clear, simple language.\n- Employ short, impactful sentences.\n- Incorporate bullet points for easy readability.\n- Use frequent line breaks to separate ideas.\n- Use active voice; avoid passive voice.\n- Focus on practical, actionable insights.\n- Use specific examples and personal experiences to illustrate points.\n- Incorporate data or statistics to support claims when possible.\n- Ask thought-provoking questions to encourage reader reflection.\n- Use \"\"you\"\" and \"\"your\"\" to directly address the reader.\n- Avoid metaphors and clich\u00e9s.\n- Avoid generalizations.\n- Do not include common setup language in any sentence, including: in conclusion, in closing, etc.\n- Do not output warnings or notes\u2014just the output requested.\n- Do not use hashtags.\n- Do not use semicolons.\n- Do not use asterisks.\n- Do NOT use these words:\n\"\"\"\"\"\"can, may, just, that, very, really, literally, actually, certainly, probably, basically, could, maybe, delve, embark, enlightening, esteemed, shed light, craft, crafting, imagine, realm, game-changer, unlock, discover, skyrocket, abyss, you're not alone, in a world where, revolutionize, disruptive, utilize, utilizing, dive deep, tapestry, illuminate, unveil, pivotal, enrich, intricate, elucidate, hence, furthermore, realm, however, harness, exciting, groundbreaking, cutting-edge, remarkable, it. remains to be seen, glimpse into, navigating, landscape, stark, testament, in summary, in conclusion, moreover, boost, bustling, opened up, powerful, inquiries, ever-evolving\"\"\"\"\"\"\n\n</writing_style>\n\n# EXAMPLE VIRAL THREAD\n\nBelow you will be given an EXAMPLE viral thread template and examples.\nEmulate the EXAMPLE, especially its hooks, breakpoints, structure, formatting, etc.\nIMPORTANT: Each post in a thread SHOULD NOT exceed 280 characters!\n\n<example>\n\n(tweet #1)\n\nIn 2021, I published 4 books.\n\nIn 2022, I plan on publishing 8.\n\nHere's the 5-step framework I use to write 60,000+ words in 30 hours or less (2,000 words per hour) \ud83d\udc47\n\n(tweet #2)\n\nStep 1: Atomize\n\nIf you think of a book as a huge wall of text, writing feels heavy.\n\nBut if you think of a book as lots of small sections stacked on top of each other (like LEGOs), writing feels easy.\n\n12 chapter / 60k words = 5k words per chapter.\n\nThat's a long-form blog post.\n\n(tweet #3)\n\nStep 2: Organize\n\nWithin each of these 12 chapters, make a list of all the Main Points you want to make.\n\nChapter = Topic\nChapter Outline = Everything you want to say about that topic\n\nDon't bother w/ sentences yet.\n\nJust list out ideas/opinions/points.\n\n(tweet #4)\n\nStep 3: Synthesize\n\nAfter you've listed Main Points in each of the 12 chapters, go back through and look for:\n\n\u2022 Repeating points (don't inflate word count saying the same thing twice)\n\u2022 Conflicting points (\"You said X here, but Y there?\")\n\u2022 Disorganized points (wrong chapter)\n\n(tweet #5)\n\nStep 4: Jazzercise\n\nNow that you have all your Main Points in the right chapters, start free flowing.\n\nIf you did it right, writing should feel like you're coloring inside the lines (section by section) opposed to painting on a blank canvas.\n\nOrganized containers = faster writing\n\n(tweet #6)\n\nStep 5: Crystallize\n\nYou should only get \"in the weeds\" and start line-editing once you've:\n\n\u2022 Organized big ideas into 12 chapters\n\u2022 Listed Main Points inside each chapter\n\u2022 Free-flowed inside each Main Point inside each chapter\n\nFinal editing should be quick and easy.\n\n(tweet #7)\n\nThe mistake writers make is they set out to write a book starting at Page 1.\n\nThis is how I wrote my first book, and it took 4 years.\n\nWhereas my book, The Art & Business of Online Writing, took 4 months. \n\nWriting linearly is SLOW.\n\nhttps://amazon.com/Art-Business-Online-Writing-Capturing/dp/0998203491\n\n(tweet #8)\n\nTL;DR: 5-Step Framework for writing a 60k word book in 30 hours:\n\n1. Atomize\n2. Organize\n3. Synthesize\n4. Jazzercise\n5. Crystallize\n\n</example>\n\n# TASK\n\nWrite a viral twitter thread based on this IDEA:\n\n<idea>\n{{ $('New Email Subject \"Thread\"').item.json.snippet }}\n</idea>\n\n# OUTPUT\n\nAlways respond with valid JSON in this exact format:\n```\n  {\n    \"text\": \"First tweet...\",\n    \"mediaUrls\": [],\n    \"additionalPosts\": [\n      {\"text\": \"Second tweet...\", \"mediaUrls\": []},\n      {\"text\": \"Third tweet...\", \"mediaUrls\": []}\n    ]\n  }\n```",
        "options": {},
        "promptType": "define",
        "needsFallback": true,
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "1f728f4c-4326-4c4b-aaa7-885aad1840da",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1712,
        864
      ],
      "parameters": {
        "color": 7,
        "width": 288,
        "height": 192,
        "content": "# Error Report\n\n\ud83d\udc49 View run logs and results.\n\n\ud83d\udc49 API Dashboard:\n https://my.blotato.com/api-dashboard"
      },
      "typeVersion": 1
    },
    {
      "id": "47eef70b-5bd4-4360-8e0e-d00661a82970",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1136,
        -16
      ],
      "parameters": {
        "color": 4,
        "width": 928,
        "height": 1472,
        "content": "# Post Long-Form Threads\n\n## IMPORTANT\nDo not post the same image/video over and over again, otherwise it will be flagged as spam. Make sure to disclose AI generated content if you're using avatars.\n\n\ud83d\udc49  **Blotato API Docs**: https://help.blotato.com/api\n\u2705  **Troubleshoot Errors**: https://my.blotato.com/api-dashboard\n\ud83d\udcf7  **Media Requirements**: https://help.blotato.com/api/media\n\ud83d\udee0\ufe0f  **Contact help**: log into blotato > click support button in bottom right corner"
      },
      "typeVersion": 1
    },
    {
      "id": "dc28620b-a359-4600-8632-158f035fe974",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1264,
        304
      ],
      "parameters": {
        "color": 2,
        "width": 320,
        "height": 176,
        "content": "# Setup 3\n1. Open each node\n2. Select your social account\n3. Deactivate platforms you don't need\n3. \ud83d\udc49 **You don't need to do anything else!**"
      },
      "typeVersion": 1
    },
    {
      "id": "cc2e26e1-5326-492f-9a7d-ed868b9da94f",
      "name": "Twitter [BLOTATO]",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "onError": "continueErrorOutput",
      "position": [
        1392,
        560
      ],
      "parameters": {
        "options": {},
        "platform": "twitter",
        "accountId": {
          "__rl": true,
          "mode": "list",
          "value": "38",
          "cachedResultUrl": "https://backend.blotato.com/v2/accounts/38",
          "cachedResultName": "Sabrina_Ramonov"
        },
        "postContentText": "={{ $('AI Writes Thread').item.json.output.text }}",
        "threadPostsArray": "={{ $json.output.additionalPosts }}",
        "threadInputMethod": "array",
        "postContentMediaUrls": "={{ $json.output.mediaUrls }}"
      },
      "credentials": {
        "blotatoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "3b67d34c-61c1-47d8-8eed-40b397691afd",
      "name": "Threads [BLOTATO]",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "onError": "continueErrorOutput",
      "position": [
        1392,
        768
      ],
      "parameters": {
        "options": {},
        "platform": "threads",
        "accountId": {
          "__rl": true,
          "mode": "id",
          "value": "253"
        },
        "postContentText": "={{ $('AI Writes Thread').item.json.output.text }}",
        "threadPostsArray": "={{ $json.output.additionalPosts }}",
        "threadInputMethod": "array",
        "postContentMediaUrls": "={{ $json.output.mediaUrls }}"
      },
      "credentials": {
        "blotatoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "a9184370-d24e-4d33-8e64-1a881d25013d",
      "name": "Bluesky [BLOTATO]",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "onError": "continueErrorOutput",
      "position": [
        1392,
        976
      ],
      "parameters": {
        "options": {},
        "platform": "bluesky",
        "accountId": {
          "__rl": true,
          "mode": "list",
          "value": "6036",
          "cachedResultUrl": "https://backend.blotato.com/v2/accounts/6036",
          "cachedResultName": "sabrinaramonov.bsky.social"
        },
        "postContentText": "={{ $('AI Writes Thread').item.json.output.text }}",
        "threadPostsArray": "={{ $json.output.additionalPosts }}",
        "threadInputMethod": "array",
        "postContentMediaUrls": "={{ $json.output.mediaUrls }}"
      },
      "credentials": {
        "blotatoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "762b3c16-16a7-4ebc-aa48-8ca162c9a3f5",
      "name": "Error Report",
      "type": "n8n-nodes-base.merge",
      "position": [
        1808,
        624
      ],
      "parameters": {
        "numberInputs": 4
      },
      "notesInFlow": false,
      "typeVersion": 3.2,
      "alwaysOutputData": false
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "1a4bf39d-7a57-47cb-bf92-2747d049a1bd",
  "connections": {
    "OpenAI Fixer": {
      "ai_languageModel": [
        [
          {
            "node": "Structured Output Parser",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Writes Thread",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Backup": {
      "ai_languageModel": [
        [
          {
            "node": "AI Writes Thread",
            "type": "ai_languageModel",
            "index": 1
          }
        ]
      ]
    },
    "AI Writes Thread": {
      "main": [
        [
          {
            "node": "Mark email as read",
            "type": "main",
            "index": 0
          },
          {
            "node": "Twitter [BLOTATO]",
            "type": "main",
            "index": 0
          },
          {
            "node": "Threads [BLOTATO]",
            "type": "main",
            "index": 0
          },
          {
            "node": "Bluesky [BLOTATO]",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Bluesky [BLOTATO]": {
      "main": [
        [],
        [
          {
            "node": "Error Report",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Threads [BLOTATO]": {
      "main": [
        [],
        [
          {
            "node": "Error Report",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Twitter [BLOTATO]": {
      "main": [
        [],
        [
          {
            "node": "Error Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mark email as read": {
      "main": [
        [],
        [
          {
            "node": "Error Report",
            "type": "main",
            "index": 3
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Writes Thread",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "New Email Subject \"Thread\"": {
      "main": [
        [
          {
            "node": "AI Writes Thread",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}