{
  "name": "Twitter Template",
  "nodes": [
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4.1",
          "mode": "list",
          "cachedResultName": "gpt-4.1"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        -492,
        80
      ],
      "id": "2debef12-4ac8-421d-b561-509c432941e9",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.output }}",
        "options": {
          "systemMessage": "# Overview\nYou are an AI image creator agent that transforms Twitter/X posts into visually striking, realistic, and metaphor-rich image prompts for AI tools like DALL\u00b7E, Midjourney, or Firefly. These images must immediately grab attention in a fast-scrolling feed, visually reinforce the core idea, and feel like mini stories or campaign visuals.\n\n\u2e3b\n\n## Objective:\n\t1.\tInterpret the message of the tweet\n\t2.\tIdentify the dominant action, metaphor, or seasonal shift\n\t3.\tCreate a prompt that results in a high-quality image that:\n\t\u2022\tUses natural textures, cinematic light, and strong focal points\n\t\u2022\tReflects action, contrast, or seasonal momentum\n\t\u2022\tIs formatted for Twitter/X (landscape 1200x675 or square 1080x1080)\n\t\u2022\tLeaves intentional space for clear copy overlay if needed\n\n\u2e3b\n\n## Output Instructions:\n\t\u2022\tOutput only the image prompt \u2014 no extra text\n\t\u2022\tUse visual language inspired by photography or editorial design\n\t\u2022\tInclude layout suggestions (e.g. split-screen, text area in lower third)\n\t\u2022\tMention mood, palette, textures, shadows, and composition\n\t\u2022\tAvoid placeholder-style icon-based layouts unless explicitly needed\n\n\u2e3b\n\n## Style Guidelines:\nDesign visuals that feel like:\n\t\u2022\tA cinematic still from a seasonal campaign\n\t\u2022\tA powerful metaphor or transformation (before/after, chaos/order, bloom/fade)\n\t\u2022\tRealistic settings: gardening tools with dirt, dew on leaves, pruning hands in golden light\n\t\u2022\tTextural richness: soil, weathered gloves, scattered seed packets, sunlight glinting\n\t\u2022\tPalette: natural greens, rich earth tones, soft yellows and whites for contrast\n\t\u2022\tVisual weight and story \u2014 not decorative, but emotive and purposeful\n\n\u2e3b\n\n## Example Prompt (Based on \u201cMay is Power Month\u201d Tweet):\nA high-impact Twitter graphic in landscape format (1200x675). A realistic close-up of gloved hands pruning overgrown garden vines with sharp secateurs. In the background: neat raised beds ready for planting. Sunlight streams through trees from the upper right, casting warm, dynamic shadows. A terra cotta pot overflows with seed packets and tools. Handwritten chalk sign in soil reads: \u201cMay is Power Month\u201d. Text area in bottom third reads: \u201cPlant. Prune. Prep.\u201d Natural grain and soft focus in background add realism. Colour palette: deep greens, soil browns, soft white and chalk grey."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.8,
      "position": [
        -144,
        -140
      ],
      "id": "cc73c7df-ab6a-4c17-b78f-5dc70601a16c",
      "name": "Image Prompt Agent"
    },
    {
      "parameters": {
        "toolDescription": "Use this tool to search the web. ",
        "method": "POST",
        "url": "https://api.tavily.com/search",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "{\n  \"query\": \"{searchTerm}\",\n  \"topic\": \"general\",\n  \"search_depth\": \"advanced\",\n  \"chunks_per_source\": 3,\n  \"max_results\": 1,\n  \"time_range\": null,\n  \"days\": 7,\n  \"include_answer\": true,\n  \"include_raw_content\": false,\n  \"include_images\": false,\n  \"include_image_descriptions\": false,\n  \"include_domains\": [],\n  \"exclude_domains\": []\n}",
        "placeholderDefinitions": {
          "values": [
            {
              "name": "searchTerm",
              "description": "What the user is searching for"
            }
          ]
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolHttpRequest",
      "typeVersion": 1.1,
      "position": [
        -372,
        80
      ],
      "id": "4c0e4096-9fa6-4d76-a2e9-edaa688af0fa",
      "name": "Tavily",
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Topic of Post:  {{ $json['Topic of Post'] }}\n\nTarget Audience: {{ $json['Target Audience'] }}\n\nAdditional Context: {{ $json['Additional Context'] }}",
        "options": {
          "systemMessage": "=## Objectives:\nBegin by conducting a real-time search using the Tavily tool to gather the most accurate, up-to-date information on the topic.  Use any additional context if provided to guide tone, language, and audience-specific insights.  \n\nBased on your research, generate a high-performing Twitter/X post that:\n\t\u2022\tOpens with a strong hook (e.g. a bold claim, stat, or surprising insight)\n\t\u2022\tUses a clear, confident, and concise tone\n\t\u2022\tIs informative or thought-provoking while staying under the character limit\n\t\u2022\tOptionally includes 1\u20132 well-placed emojis (if appropriate to tone)\n\t\u2022\tEnds with a clear engagement prompt (e.g. \u201cAgree?\u201d, \u201cWhat\u2019s your take?\u201d, \u201cSave this for later.\u201d)\n\t\u2022\tIncludes 1\u20133 relevant hashtags if useful, but not forced\n\t\u2022\tMay include a link to a source, article, or product if appropriate\n\n\u2e3b\n\n## Style Guidelines:\n\t\u2022\tPrioritise brevity and impact (max: 280 characters)\n\t\u2022\tAvoid jargon or overly corporate tone\n\t\u2022\tUse plain English, strong verbs, and short sentences\n\t\u2022\tTweets can be standalone or openers to threads\n\t\u2022\tMust feel native to the Twitter/X platform \u2014 smart, useful, or provocative\n\n\u2e3b\n\n## Output Instructions:\n\t\u2022\tYour ONLY output should be the final tweet text\n\t\u2022\tDo not include explanations, hashtags-only posts, or notes\n\t\u2022\tIf a link is essential, include it naturally within the tweet\n\n\u2e3b\n\n## Example Workflow:\n\t1.\tReceive a topic (e.g., \u201cThe ROI of warehouse automation\u201d)\n\t2.\tUse Tavily to gather recent info or examples\n\t3.\tCraft a single high-impact tweet using that insight\n\t4.\tFormat it with a strong hook, tight writing, and call to action\n\t5.\tAdd 1\u20133 niche hashtags if relevant"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.8,
      "position": [
        -520,
        -140
      ],
      "id": "5997ba24-6578-4d09-b950-dafc826d8cbe",
      "name": "Twitter Post Agent"
    },
    {
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "Topic of Post"
            },
            {
              "name": "Target Audience"
            },
            {
              "name": "Email"
            },
            {
              "name": "Folder Name"
            },
            {
              "name": "Additional Context"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1.1,
      "position": [
        -740,
        -140
      ],
      "id": "4346c64c-0a03-4933-8b7a-439dc6cbd135",
      "name": "When Executed by Another Workflow"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.openai.com/v1/images/generations",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "model",
              "value": "gpt-image-1"
            },
            {
              "name": "prompt",
              "value": "={{ $json.output }}"
            },
            {
              "name": "size",
              "value": "1024x1024"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        232,
        -140
      ],
      "id": "fc6093a2-b867-4fff-86c1-e919d88e35d4",
      "name": "Generate Image",
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "toBinary",
        "sourceProperty": "data[0].b64_json",
        "options": {}
      },
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        452,
        -140
      ],
      "id": "165ebfa7-cb58-4160-8733-d06238874972",
      "name": "Convert to Binary"
    },
    {
      "parameters": {
        "name": "Twitter Image",
        "driveId": {
          "__rl": true,
          "value": "My Drive",
          "mode": "list",
          "cachedResultName": "My Drive",
          "cachedResultUrl": "https://drive.google.com/drive/my-drive"
        },
        "folderId": {
          "__rl": true,
          "value": "={{ $('When Executed by Another Workflow').item.json['Folder Name'] }}",
          "mode": "id"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        672,
        -140
      ],
      "id": "ab3b9a1c-51d8-46ec-b41b-a9bda19fab23",
      "name": "Upload Image",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "81949d4a-b601-45d8-baee-49287ce38b4c",
              "name": "Platform",
              "value": "Instagram",
              "type": "string"
            },
            {
              "id": "d5b78358-7da5-4d77-b5ee-c37eddce15d9",
              "name": "Generated Text",
              "value": "={{ $('Twitter Post Agent').item.json.output }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        892,
        -140
      ],
      "id": "f3f5da7a-8b15-4092-98ea-ddc83ef122b4",
      "name": "Output to Manager Agent"
    }
  ],
  "connections": {
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Twitter Post Agent",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Image Prompt Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Image Prompt Agent": {
      "main": [
        [
          {
            "node": "Generate Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tavily": {
      "ai_tool": [
        [
          {
            "node": "Twitter Post Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Twitter Post Agent": {
      "main": [
        [
          {
            "node": "Image Prompt Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Twitter Post Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Image": {
      "main": [
        [
          {
            "node": "Convert to Binary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to Binary": {
      "main": [
        [
          {
            "node": "Upload Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload Image": {
      "main": [
        [
          {
            "node": "Output to Manager Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "8fb196c3-6118-4c11-a0c9-5d026b5e8769",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "ma9DFWxxZ5P63f6a",
  "tags": []
}