{
  "name": "ZapZap: forward incoming messages to your CRM",
  "nodes": [
    {
      "parameters": {
        "content": "Forwards every incoming (not from you) message to your own CRM or backend URL as JSON. Set the CRM URL in the last node. 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). ",
        "width": 460,
        "height": 250
      },
      "id": "n1",
      "name": "Instructions",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -260,
        -140
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "zapzap-to-crm",
        "options": {}
      },
      "id": "n2",
      "name": "Incoming message",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        100
      ],
      "webhookId": "zapzap-to-crm"
    },
    {
      "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
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "n9",
      "name": "Not sent by me",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        440,
        100
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://YOUR-CRM.example.com/whatsapp-inbox",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ from: $json.body.data.message.chatid, text: $json.body.data.message.text, instance: $json.body.instance_name }) }}",
        "options": {}
      },
      "id": "n10",
      "name": "POST to your CRM",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        660,
        100
      ]
    }
  ],
  "connections": {
    "Incoming message": {
      "main": [
        [
          {
            "node": "Config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Config": {
      "main": [
        [
          {
            "node": "Not sent by me",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Not sent by me": {
      "main": [
        [
          {
            "node": "POST to your CRM",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false
  }
}
