{
  "name": "Threadwire: answer WhatsApp messages from n8n",
  "nodes": [
    {
      "parameters": {
        "content": "## Answer WhatsApp messages from n8n\n1. Activate this workflow and copy the **Production URL** of *Threadwire event*.\n2. In your Threadwire panel, under **Developers → Webhooks** (admins only), set that as your webhook URL. Leave the events there as they are: *Someone wrote* already keeps only `message.received`. The events are one list for your whole account, so un-ticking the others would switch them off for every other system too.\n3. In *Reply*, add a **Header Auth** credential: name `Authorization`, value `Bearer YOUR_API_KEY`.\n4. Put your own logic between *Someone wrote* and *Reply*: look up an order, ask an AI, check stock.\n\nReplies go to someone who just wrote, so they are never limited as first messages.\n\n**Lock the address:** on the same page set an **Authentication header** (a name and a secret value of yours), and in *Threadwire event* set Authentication to **Header Auth** with that name and value. n8n then refuses anyone else who posts to it.",
        "width": 520,
        "height": 420
      },
      "id": "5c9c5ebd-0cba-500d-87f7-790e0e356e3d",
      "name": "How it works",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -60,
        -460
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "threadwire-events",
        "responseMode": "onReceived",
        "options": {}
      },
      "id": "0ca095df-9fc3-5022-bd32-bc1f8b6efdc6",
      "name": "Threadwire event",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        0
      ],
      "webhookId": "0a0420eb-ae51-5a54-b18c-178851976d6f"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "3326f8a9-1cf7-5731-92ec-85b5b96cf461",
              "leftValue": "={{ $json.body.type }}",
              "rightValue": "message.received",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "7a939f53-4d72-5f81-8996-6ea5fec450f8",
      "name": "Someone wrote",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        220,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://threadwire.net/api/v1/messages",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ instance_id: $json.body.data.instance_id, to: $json.body.data.phone, text: 'Thanks for your message! We will answer shortly.' }) }}",
        "options": {}
      },
      "id": "d03e78b4-f986-5ded-9741-fd7e1b80fc99",
      "name": "Reply",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        460,
        -20
      ]
    }
  ],
  "connections": {
    "Threadwire event": {
      "main": [
        [
          {
            "node": "Someone wrote",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Someone wrote": {
      "main": [
        [
          {
            "node": "Reply",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false
  }
}
