{
  "name": "ZapZap: send a poll after a purchase",
  "nodes": [
    {
      "parameters": {
        "content": "POST {\"phone\":\"5511999999999\"} to the webhook URL after a purchase. The customer receives a native WhatsApp poll. Open the Config node and fill instanceId, apiKey and apiSecret (dashboard: Settings and API). ",
        "width": 460,
        "height": 230
      },
      "id": "n1",
      "name": "Instructions",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -260,
        -140
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "zapzap-purchase",
        "options": {}
      },
      "id": "n2",
      "name": "Purchase webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        100
      ],
      "webhookId": "zapzap-purchase"
    },
    {
      "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": {
        "method": "POST",
        "url": "={{ $(\"Config\").first().json.baseUrl }}/{{ $(\"Config\").first().json.instanceId }}/send/poll",
        "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: String($json.body.phone).replace(/\\D/g, ''), text: 'How was your purchase?', choices: ['Great', 'Good', 'Could be better'], selectableCount: 1 }) }}",
        "options": {}
      },
      "id": "n8",
      "name": "Send poll",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        440,
        100
      ]
    }
  ],
  "connections": {
    "Purchase webhook": {
      "main": [
        [
          {
            "node": "Config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Config": {
      "main": [
        [
          {
            "node": "Send poll",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false
  }
}
