{
  "id": 7550,
  "name": "Generate AI Twitter posts with web research using GPT, Tavily and image generation",
  "description": "*This workflow contains community nodes that are only compatible with the self-hosted version of n8n.*\n\n# **\ud83e\udd16 AI-Powered Twitter Content Generator**\n\nTransform topic ideas into ready to post Twitter drafts (text + image) using fresh web data and AI agents\n\n## **\ud83c\udfaf What does this workflow do?**\n\nThis end to end automation creates complete Twitter posts by:\n\nTaking your topic input (e.g., \"Agentic AI\") via chat interface\n\nGenerating fresh, research-backed content using AI agents:\n\nFirst agent uses GPT-4.1-MINI + Tavily to bypass LLM knowledge limits with real-time web data\n\nSecond agent creates optimized prompt for image generation\n\nProducing custom visuals through OpenAI's gpt-image-1\n\nDelivering polished drafts (text + image) via Gmail for review\n\n## **\u2699\ufe0f How it works**\n\nUser input: You provide a topic through chat node\n\nContent research:\n\nAgent 1 (GPT-4.1-mini + Tavily) researches current web data\n\nGenerates factually fresh tweet content\n\nVisual creation:\n\nAgent 2 optimizes prompt for image generation\n\nHTTP request node calls OpenAI's gpt-image-1 model to generate the image\n\nConvert to file node converst the base64 string to a file so we can send it as an attachment\n\nDelivery:\n\nGmail node sends compiled draft with text body + image attachment\n\n## **\ud83d\udd11 Required setup**\n\nHave a verified organization: [OpenAI Org Settings](https://platform.openai.com/account/org-settings)\n\nOpenAI API Key: [Create a Key Here](https://platform.openai.com/settings/organization/api-keys)\n\nTavily API Key: [Get it Here](https://app.tavily.com/home)\n\nGmail credentials: [Google Cloud Console](https://console.cloud.google.com)\n",
  "categories": [
    {
      "id": 31,
      "name": "Content Creation"
    },
    {
      "id": 51,
      "name": "Multimodal AI"
    }
  ],
  "totalViews": 1279,
  "createdAt": "2025-08-18T16:51:39.414Z",
  "workflow": {
    "id": "Qo06ih7GNFqFJJ1c",
    "meta": {
      "instanceId": "e73c77a832a4af1fdbfd95e61201dd65dffb85871e88031e3f1475c5661e7b54",
      "templateCredsSetupCompleted": true
    },
    "name": "Twitter Content Engine",
    "tags": [],
    "nodes": [
      {
        "id": "943102d8-8ddf-4680-aec1-f78e45e504f2",
        "name": "When chat message received",
        "type": "@n8n/n8n-nodes-langchain.chatTrigger",
        "position": [
          128,
          -128
        ],
        "webhookId": "afad8bd6-04d0-4f22-9f1f-f1ee22537886",
        "parameters": {
          "options": {}
        },
        "typeVersion": 1.3
      },
      {
        "id": "33cf2956-3837-4f3f-a6b6-9c2e9ba7680c",
        "name": "OpenAI Chat Model",
        "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
        "position": [
          336,
          272
        ],
        "parameters": {
          "model": {
            "__rl": true,
            "mode": "list",
            "value": "gpt-4.1-mini"
          },
          "options": {}
        },
        "credentials": {
          "openAiApi": {
            "id": "credential-id",
            "name": "openAiApi Credential"
          }
        },
        "typeVersion": 1.2
      },
      {
        "id": "e8487102-13ff-43f6-a796-bd8b660546fb",
        "name": "Twitter Content",
        "type": "@n8n/n8n-nodes-langchain.agent",
        "position": [
          48,
          80
        ],
        "parameters": {
          "text": "={{ $json.chatInput }}",
          "options": {
            "systemMessage": "## Role & Objective\nYou are an expert Twitter content creator specializing in creating viral, engaging tweets that drive high engagement rates. Your mission is to transform current information into compelling Twitter content that resonates with audiences and maximizes reach.\n\n## Core Instructions\n\n### 1. Content Research Protocol\n- **ALWAYS** use Tavily search to gather the most current information before creating any tweet\n- Search for trending topics, breaking news, and recent developments in your assigned niche\n\n### 2. Tweet Creation Framework\n\n**Before writing, ask yourself:**\n- What's the hook that will make people stop scrolling?\n- What emotion am I trying to evoke? (surprise, curiosity, excitement, urgency)\n- How can I make this valuable in under 280 characters?\n\n**Required Elements:**\n- **Hook**: Start with attention-grabbing first 5-10 words\n- **Value**: Provide insight, news, or entertainment\n- **Engagement Driver**: Include question, call-to-action, or conversation starter\n\n### 3. Content Categories (Rotate between these)\n1. **Breaking News Reactions** - Hot takes on current events\n2. **Trend Analysis** - Insights about emerging patterns\n3. **Educational Threads** - Quick tutorials or explanations\n4. **Industry Updates** - Latest developments in your niche\n5. **Controversial Takes** - Respectful but debate-worthy opinions\n6. **Behind-the-Scenes** - Process insights or personal stories\n7. **Data-Driven Insights** - Statistics and trends with interpretation\n\n### 4. Optimization Rules\n\n**Language & Tone:**\n- Write conversationally, as if talking to a friend\n- Use active voice and strong verbs\n- Vary sentence length for rhythm\n- Keep language clean and professional without emojis\n- Avoid jargon unless explaining it\n\n**Engagement Tactics:**\n- Ask questions that prompt responses\n- Use \"unpopular opinion:\" or \"hot take:\" for controversial content\n- Include numbers and statistics when available\n- Reference current events or pop culture\n- Create urgency with time-sensitive information\n\n**Technical Requirements:**\n- Keep under 280 characters\n- Front-load the most important information\n- Use line breaks for readability when needed\n- Focus on compelling copy rather than hashtags\n\n### 5. Current Information Integration\nWhen using Tavily search results:\n- Extract the most surprising or counterintuitive findings\n- Look for data points that challenge common assumptions\n- Identify emerging trends before they become mainstream\n- Find unique angles on widely reported stories\n\n### 6. Quality Checks\nBefore finalizing each tweet, verify:\n- Hook is compelling and specific\n- Content provides genuine value\n- Tone matches target audience\n- Call-to-action encourages engagement\n- Character count is optimized\n- No spelling/grammar errors\n\n## Example Output Structure\n\n**Search Findings:** Breaking: OpenAI just announced GPT-5 with 10x performance improvement. Early tests show 95% accuracy on complex reasoning tasks. Stock jumped 12% in after-hours trading.\n\n**Tweet:** GPT-5 just dropped and the results are INSANE\n95% accuracy on complex reasoning tasks\nThis changes everything for AI development\nWhat's the first thing you're going to build with it?\n\n**Tweet:** OpenAI stock up 12% after GPT-5 announcement\n10x performance jump has investors excited\nBut here's what they're missing about the real impact...\nMore details in replies\n\n**Tweet:** Everyone's talking about GPT-5's 95% accuracy rate\nBut I'm more interested in what this means for junior developers, content creators, small businesses, and education\nThoughts?\n\nRemember: Your goal is to create content that people not only read but actively engage with through likes, retweets, and replies. Every tweet should provide value while encouraging interaction."
          },
          "promptType": "define"
        },
        "typeVersion": 2.2
      },
      {
        "id": "0c3eff07-7a0c-47b3-a47b-fc5ea2296331",
        "name": "OpenAI Chat Model1",
        "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
        "position": [
          48,
          272
        ],
        "parameters": {
          "model": {
            "__rl": true,
            "mode": "list",
            "value": "gpt-4.1-mini"
          },
          "options": {}
        },
        "credentials": {
          "openAiApi": {
            "id": "credential-id",
            "name": "openAiApi Credential"
          }
        },
        "typeVersion": 1.2
      },
      {
        "id": "0f2ebb26-98cf-4c83-973a-51a237c28bc3",
        "name": "Send a message",
        "type": "n8n-nodes-base.gmail",
        "position": [
          368,
          -128
        ],
        "webhookId": "48fa98ab-4440-4cc5-af4a-1724170bf6f9",
        "parameters": {
          "sendTo": "emailhere",
          "message": "={{ $('Twitter Content').item.json.output }}",
          "options": {
            "attachmentsUi": {
              "attachmentsBinary": [
                {}
              ]
            },
            "appendAttribution": false
          },
          "subject": "New Tweet Generated",
          "emailType": "text"
        },
        "credentials": {
          "gmailOAuth2": {
            "id": "credential-id",
            "name": "gmailOAuth2 Credential"
          }
        },
        "typeVersion": 2.1
      },
      {
        "id": "ad7b33ba-1f52-4f7c-b437-d619e55e367e",
        "name": "Twitter Image Prompt",
        "type": "@n8n/n8n-nodes-langchain.agent",
        "position": [
          336,
          80
        ],
        "parameters": {
          "text": "={{ $json.output }}",
          "options": {
            "systemMessage": "# Tweet to Image Prompt Generator Agent\n\n## Role & Objective\nYou are an expert visual content strategist who converts Twitter text into optimized image generation prompts. Your mission is to analyze tweet content and create detailed prompts that will generate compelling visuals to maximize social media engagement and stop users from scrolling.\n\n## Core Instructions\n\n### 1. Tweet Analysis Protocol\n- Read the tweet content thoroughly to understand the core message\n- Identify the primary emotion and tone\n- Determine the target audience and context\n- Extract key themes that can be visualized\n\n### 2. Visual Strategy Selection\n\n**Choose the most effective approach:**\n- **Abstract Concepts** for ideas, trends, or opinions\n- **Data Representations** for statistics or comparisons  \n- **Symbolic Imagery** for metaphors or complex topics\n- **Professional Scenes** for business or industry content\n- **Technology Visuals** for AI, tech, or innovation topics\n- **Human Interest** for personal stories or relatable content\n\n### 3. Prompt Construction Framework\n\n**Structure your image prompt with these elements:**\n1. **Subject/Scene** - Main visual focus\n2. **Style Direction** - Artistic approach and aesthetic\n3. **Composition** - Layout and visual arrangement\n4. **Color Palette** - Strategic color choices\n5. **Mood/Atmosphere** - Emotional tone\n6. **Technical Specs** - Quality and format requirements\n7. **Exclusions** - What to avoid\n\n### 4. Platform Optimization\n\n**Twitter-specific requirements:**\n- High contrast for mobile viewing\n- Clean composition that works at small sizes\n- Visually striking enough to stop scroll\n- Complements text without repeating it\n- Works well with Twitter's image cropping\n\n### 5. Quality Standards\n\n**Every prompt must be:**\n- Specific enough to generate consistent results\n- Detailed but not overly complex\n- Focused on one clear visual concept\n- Optimized for social media performance\n- Free of text or typography elements\n\n## Response Format\n\nReturn only the optimized image generation prompt, ready for immediate use.\n\n## Example\n\nInput Tweet: \"GPT-5 just dropped and the results are INSANE. 95% accuracy on complex reasoning tasks. This changes everything for AI development. What's the first thing you're going to build with it?\"\n\nOutput: Futuristic AI neural network visualization, glowing interconnected nodes and pathways, electric blue and cyan color scheme, sleek digital interface elements floating in space, dark gradient background, volumetric lighting effects, modern 3D render style, clean minimalist composition, high-tech laboratory atmosphere, sharp geometric patterns, professional photography quality, 16:9 aspect ratio, no text overlays, no cluttered details, no outdated computer imagery\n\nRemember: Create prompts that generate images worthy of stopping the scroll and encouraging engagement."
          },
          "promptType": "define"
        },
        "typeVersion": 2.2
      },
      {
        "id": "1c220fad-33fe-4e1d-902e-261b27d9df97",
        "name": "gpt-image-1",
        "type": "n8n-nodes-base.httpRequest",
        "position": [
          640,
          80
        ],
        "parameters": {
          "url": "https://api.openai.com/v1/images/generations",
          "method": "POST",
          "options": {},
          "sendBody": true,
          "authentication": "genericCredentialType",
          "bodyParameters": {
            "parameters": [
              {
                "name": "model",
                "value": "gpt-image-1"
              },
              {
                "name": "prompt",
                "value": "={{ $json.output }}"
              },
              {
                "name": "size",
                "value": "1024x1024"
              }
            ]
          },
          "genericAuthType": "httpBearerAuth"
        },
        "credentials": {
          "httpBearerAuth": {
            "id": "credential-id",
            "name": "httpBearerAuth Credential"
          }
        },
        "typeVersion": 4.2
      },
      {
        "id": "b0e78b66-1e6a-410b-b7df-1b3a6659a183",
        "name": "Convert to File",
        "type": "n8n-nodes-base.convertToFile",
        "position": [
          640,
          -128
        ],
        "parameters": {
          "options": {},
          "operation": "toBinary",
          "sourceProperty": "data[0].b64_json"
        },
        "typeVersion": 1.1
      },
      {
        "id": "1ce15072-a74a-4a47-916c-f1190eebd960",
        "name": "Search in Tavily",
        "type": "@tavily/n8n-nodes-tavily.tavilyTool",
        "position": [
          192,
          272
        ],
        "parameters": {
          "query": "={{ $json.chatInput }}",
          "options": {}
        },
        "credentials": {
          "tavilyApi": {
            "id": "credential-id",
            "name": "tavilyApi Credential"
          }
        },
        "typeVersion": 1
      },
      {
        "id": "94d23fe1-61f5-4302-9ab2-1c050eaee891",
        "name": "Sticky Note",
        "type": "n8n-nodes-base.stickyNote",
        "position": [
          16,
          432
        ],
        "parameters": {
          "color": 5,
          "width": 576,
          "height": 192,
          "content": "## API Keys\n\nuse your openai api key to setup the chat model credentials\n\nuse your tavily api key to setup the credientials"
        },
        "typeVersion": 1
      },
      {
        "id": "b60b122f-cdd3-43f4-af03-83025c179639",
        "name": "Sticky Note1",
        "type": "n8n-nodes-base.stickyNote",
        "position": [
          256,
          -320
        ],
        "parameters": {
          "color": 4,
          "width": 320,
          "height": 144,
          "content": "## Gmail Credentials\n\nuse the client id and secret id you got from https://console.cloud.google.com"
        },
        "typeVersion": 1
      },
      {
        "id": "49ca644d-32a5-4b80-8a5c-081c963a5774",
        "name": "Sticky Note2",
        "type": "n8n-nodes-base.stickyNote",
        "position": [
          816,
          80
        ],
        "parameters": {
          "color": 3,
          "width": 320,
          "height": 128,
          "content": "## generic credential type\n\nChose Bearer YOUR_TOKEN_HERE and use your api key"
        },
        "typeVersion": 1
      }
    ],
    "active": false,
    "pinData": {},
    "settings": {
      "executionOrder": "v1"
    },
    "versionId": "15d93d49-e806-494f-bdd8-49b3cf33a4c2",
    "connections": {
      "gpt-image-1": {
        "main": [
          [
            {
              "node": "Convert to File",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Convert to File": {
        "main": [
          [
            {
              "node": "Send a message",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Twitter Content": {
        "main": [
          [
            {
              "node": "Twitter Image Prompt",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Search in Tavily": {
        "ai_tool": [
          [
            {
              "node": "Twitter Content",
              "type": "ai_tool",
              "index": 0
            }
          ]
        ]
      },
      "OpenAI Chat Model": {
        "ai_languageModel": [
          [
            {
              "node": "Twitter Image Prompt",
              "type": "ai_languageModel",
              "index": 0
            }
          ]
        ]
      },
      "OpenAI Chat Model1": {
        "ai_languageModel": [
          [
            {
              "node": "Twitter Content",
              "type": "ai_languageModel",
              "index": 0
            }
          ]
        ]
      },
      "Twitter Image Prompt": {
        "main": [
          [
            {
              "node": "gpt-image-1",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "When chat message received": {
        "main": [
          [
            {
              "node": "Twitter Content",
              "type": "main",
              "index": 0
            }
          ]
        ]
      }
    }
  },
  "workflowInfo": {
    "nodeCount": 12,
    "nodeTypes": {
      "n8n-nodes-base.gmail": {
        "count": 1
      },
      "n8n-nodes-base.stickyNote": {
        "count": 3
      },
      "n8n-nodes-base.httpRequest": {
        "count": 1
      },
      "n8n-nodes-base.convertToFile": {
        "count": 1
      },
      "@n8n/n8n-nodes-langchain.agent": {
        "count": 2
      },
      "@tavily/n8n-nodes-tavily.tavilyTool": {
        "count": 1
      },
      "@n8n/n8n-nodes-langchain.chatTrigger": {
        "count": 1
      },
      "@n8n/n8n-nodes-langchain.lmChatOpenAi": {
        "count": 2
      }
    }
  },
  "nodes": [
    "When chat message received",
    "OpenAI Chat Model",
    "Twitter Content",
    "OpenAI Chat Model1",
    "Send a message",
    "Twitter Image Prompt",
    "gpt-image-1",
    "Convert to File",
    "Search in Tavily",
    "Sticky Note",
    "Sticky Note1",
    "Sticky Note2"
  ],
  "nodeTypes": [
    "@n8n/n8n-nodes-langchain.agent",
    "n8n-nodes-base.httpRequest",
    "@tavily/n8n-nodes-tavily.tavilyTool",
    "n8n-nodes-base.gmail",
    "n8n-nodes-base.convertToFile",
    "n8n-nodes-base.stickyNote",
    "@n8n/n8n-nodes-langchain.chatTrigger",
    "@n8n/n8n-nodes-langchain.lmChatOpenAi"
  ]
}