{
  "name": "ZapZap: auto reply to incoming messages",
  "nodes": [
    {
      "parameters": {
        "content": "Replies to incoming messages that contain 'hello'. Open the Config node and fill instanceId, apiKey and apiSecret (dashboard: Settings and API). Then point the instance webhook to this workflow's Production URL (dashboard, or PUT /instances/{id}/webhook). Activate the workflow.",
        "width": 460,
        "height": 250
      },
      "id": "n1",
      "name": "Instructions",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -260,
        -140
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "zapzap-auto-reply",
        "options": {}
      },
      "id": "n2",
      "name": "Incoming message",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        100
      ],
      "webhookId": "zapzap-auto-reply"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "n3",
              "name": "baseUrl",
              "value": "https://api.zapzapapi.com/api/v1",
              "type": "string"
            },
            {
              "id": "n4",
              "name": "instanceId",
              "value": "YOUR_INSTANCE_ID",
              "type": "string"
            },
            {
              "id": "n5",
              "name": "apiKey",
              "value": "YOUR_API_KEY",
              "type": "string"
            },
            {
              "id": "n6",
              "name": "apiSecret",
              "value": "YOUR_API_SECRET",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      },
      "id": "n7",
      "name": "Config",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        220,
        100
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "n8",
              "leftValue": "={{ $json.body.data.message.fromMe }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              }
            },
            {
              "id": "n9",
              "leftValue": "={{ $json.body.data.message.text }}",
              "rightValue": "hello",
              "operator": {
                "type": "string",
                "operation": "contains"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "n10",
      "name": "Is hello",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        440,
        100
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $(\"Config\").first().json.baseUrl }}/{{ $(\"Config\").first().json.instanceId }}/send/text",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "x-api-key",
              "value": "={{ $(\"Config\").first().json.apiKey }}"
            },
            {
              "name": "x-api-secret",
              "value": "={{ $(\"Config\").first().json.apiSecret }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ number: $json.body.data.message.chatid.replace('@s.whatsapp.net', ''), text: 'Hi! Thanks for your message. A person from our team will answer soon.' }) }}",
        "options": {}
      },
      "id": "n11",
      "name": "Send reply",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        660,
        100
      ]
    }
  ],
  "connections": {
    "Incoming message": {
      "main": [
        [
          {
            "node": "Config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Config": {
      "main": [
        [
          {
            "node": "Is hello",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is hello": {
      "main": [
        [
          {
            "node": "Send reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false
  }
}
