{
  "name": "Twitter Webhook Handler",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "twitter-actions",
        "responseMode": "lastNode"
      },
      "id": "webhook-1",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "rules": {
          "rules": [
            {
              "value": "post_tweet",
              "output": 0
            },
            {
              "value": "reply",
              "output": 1
            },
            {
              "value": "like",
              "output": 2
            },
            {
              "value": "post_with_image",
              "output": 3
            },
            {
              "value": "reply_with_image",
              "output": 4
            },
            {
              "value": "thread",
              "output": 5
            },
            {
              "value": "quote_tweet",
              "output": 6
            }
          ]
        }
      },
      "id": "switch-1",
      "name": "Route Action",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 1,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "// Post Tweet\nconst text = $json.text;\nif (!text) return { json: { error: 'Missing text' } };\nreturn { json: { success: true, action: 'post_tweet', text } };"
      },
      "id": "code-1",
      "name": "Post Tweet",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        700,
        100
      ]
    },
    {
      "parameters": {
        "jsCode": "// Reply\nconst { text, tweetId } = $json;\nif (!text || !tweetId) return { json: { error: 'Missing fields' } };\nreturn { json: { success: true, action: 'reply', text, tweetId } };"
      },
      "id": "code-2",
      "name": "Reply",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        700,
        220
      ]
    },
    {
      "parameters": {
        "jsCode": "// Like\nconst { tweetId } = $json;\nif (!tweetId) return { json: { error: 'Missing tweetId' } };\nreturn { json: { success: true, action: 'like', tweetId } };"
      },
      "id": "code-3",
      "name": "Like",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        700,
        340
      ]
    },
    {
      "parameters": {
        "jsCode": "// Post with Image\nconst { text, imageUrl } = $json;\nif (!text || !imageUrl) return { json: { error: 'Missing fields' } };\nreturn { json: { success: true, action: 'post_with_image', text, imageUrl } };"
      },
      "id": "code-4",
      "name": "Post with Image",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        700,
        460
      ]
    },
    {
      "parameters": {
        "jsCode": "// Reply with Image\nconst { text, tweetId, imageUrl } = $json;\nif (!text || !tweetId || !imageUrl) return { json: { error: 'Missing fields' } };\nreturn { json: { success: true, action: 'reply_with_image', text, tweetId, imageUrl } };"
      },
      "id": "code-5",
      "name": "Reply with Image",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        700,
        580
      ]
    },
    {
      "parameters": {
        "jsCode": "// Thread\nconst { tweets } = $json;\nif (!tweets || !Array.isArray(tweets) || tweets.length < 2) {\n return { json: { error: 'Need at least 2 tweets' } };\n}\nreturn { json: { success: true, action: 'thread', tweetCount: tweets.length, tweets } };"
      },
      "id": "code-6",
      "name": "Thread",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        700,
        700
      ]
    },
    {
      "parameters": {
        "jsCode": "// Quote\nconst { text, tweetId } = $json;\nif (!text || !tweetId) return { json: { error: 'Missing fields' } };\nreturn { json: { success: true, action: 'quote_tweet', text, tweetId } };"
      },
      "id": "code-7",
      "name": "Quote Tweet",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        700,
        820
      ]
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "respond-1",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        950,
        460
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Route Action",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route Action": {
      "main": [
        [
          {
            "node": "Post Tweet",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Reply",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Like",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Post with Image",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Reply with Image",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Thread",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Quote Tweet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post Tweet": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reply": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Like": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post with Image": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reply with Image": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Thread": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Quote Tweet": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": []
}