{
  "name": "Izini events to Google Sheets",
  "nodes": [
    {
      "id": "13f52909-0edf-4394-8f27-7c8ad081013e",
      "name": "Instructions",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -60,
        -60
      ],
      "parameters": {
        "color": 4,
        "width": 760,
        "height": 300,
        "content": "## Izini events to Google Sheets\n1. Paste your webhook secret (Izini: Developers > Webhooks) into **Sign with your webhook secret**.\n2. Make a sheet with the columns Received, Event, Headline, Reference, Date, Project, Delivery and Link; connect Google and pick it in **Add a row**.\n3. Activate the workflow, copy the production URL of **Izini webhook**, and add it in Izini as a webhook with the events you want.\n\nRequests not signed by Izini, or older than 5 minutes, get 401. A retried delivery is handled once. Guide: https://app.izini.ng/developers/guides/events-to-your-tools"
      }
    },
    {
      "id": "bd05fece-218f-43de-89f4-b23b04364eac",
      "name": "Izini webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        0,
        300
      ],
      "parameters": {
        "httpMethod": "POST",
        "path": "izini-events",
        "responseMode": "responseNode",
        "options": {
          "rawBody": true
        }
      }
    },
    {
      "id": "48f45f31-3ba0-4de6-874f-f2e7956114f1",
      "name": "Read raw body",
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1.1,
      "position": [
        220,
        300
      ],
      "parameters": {
        "operation": "text",
        "destinationKey": "rawBody"
      }
    },
    {
      "id": "d758d473-6e76-49f9-87d3-22d785e90556",
      "name": "Sign with your webhook secret",
      "type": "n8n-nodes-base.crypto",
      "typeVersion": 1,
      "position": [
        440,
        300
      ],
      "parameters": {
        "action": "hmac",
        "type": "SHA256",
        "value": "={{ $('Izini webhook').item.json.headers['x-izini-timestamp'] }}.{{ $json.rawBody }}",
        "dataPropertyName": "expectedSignature",
        "secret": "PASTE_YOUR_IZINI_WEBHOOK_SECRET",
        "encoding": "hex"
      }
    },
    {
      "id": "85041a09-deec-4d8c-8223-41aee11569b1",
      "name": "Signed by Izini, sent in the last 5 minutes?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        660,
        300
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "leftValue": "={{ $json.expectedSignature }}",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "rightValue": "={{ $('Izini webhook').item.json.headers['x-izini-signature-v2'] }}"
            },
            {
              "leftValue": "={{ Math.abs($now.toSeconds() - Number($('Izini webhook').item.json.headers['x-izini-timestamp'])) }}",
              "operator": {
                "type": "number",
                "operation": "lt"
              },
              "rightValue": 300
            }
          ],
          "combinator": "and"
        }
      }
    },
    {
      "id": "7423cc26-aae3-423f-8178-3478334e2289",
      "name": "Answer 200",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.5,
      "position": [
        880,
        200
      ],
      "parameters": {
        "respondWith": "noData",
        "options": {
          "responseCode": 200
        }
      }
    },
    {
      "id": "3b5bee7c-1966-4b1d-830e-a9dd85d229a9",
      "name": "Answer 401",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.5,
      "position": [
        880,
        420
      ],
      "parameters": {
        "respondWith": "noData",
        "options": {
          "responseCode": 401
        }
      }
    },
    {
      "id": "b995a81a-c3b5-404e-8dcb-b9b7e1a1dd05",
      "name": "Parse event",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1100,
        200
      ],
      "parameters": {
        "mode": "raw",
        "jsonOutput": "={{ $('Read raw body').item.json.rawBody }}",
        "includeOtherFields": false
      }
    },
    {
      "id": "a3a3838f-f970-49aa-88cf-066c7ba06db5",
      "name": "Skip repeats",
      "type": "n8n-nodes-base.removeDuplicates",
      "typeVersion": 2,
      "position": [
        1320,
        200
      ],
      "parameters": {
        "operation": "removeItemsSeenInPreviousExecutions",
        "logic": "removeItemsWithAlreadySeenKeyValues",
        "dedupeValue": "={{ $json.id }}"
      }
    },
    {
      "id": "40875fd9-5fb5-40fb-8746-72993eb0f45c",
      "name": "Describe event",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1540,
        200
      ],
      "parameters": {
        "mode": "manual",
        "includeOtherFields": true,
        "assignments": {
          "assignments": [
            {
              "id": "headline",
              "name": "headline",
              "type": "string",
              "value": "={{ ({\"consent.updated\":\"Consent recorded\",\"dsar.received\":\"New data subject request\",\"dsar.due_soon\":\"Data subject request due within 7 days\",\"dsar.overdue\":\"Data subject request past its target\",\"dsar.closed\":\"Data subject request closed\",\"incident.created\":\"Incident logged\",\"incident.breach_clock\":\"72-hour NDPC clock\",\"incident.ndpc_notified\":\"Breach reported to the NDPC\",\"dpia.completed\":\"DPIA completed\",\"policy.published\":\"Privacy policy published\",\"vendor.dpa_review_due\":\"Vendor DPA due for review\",\"training.overdue\":\"Staff training overdue\",\"car.due\":\"Annual audit return due 31 March\"})[$json.event] ?? $json.event }}{{ $json.event === 'incident.breach_clock' ? ': ' + (({\"started\":\"clock started\",\"48h\":\"48 hours left\",\"24h\":\"24 hours left\",\"6h\":\"6 hours left\",\"overdue\":\"deadline passed\"})[$json.payload.milestone] ?? $json.payload.milestone) : '' }}"
            },
            {
              "id": "reference",
              "name": "reference",
              "type": "string",
              "value": "={{ $json.payload.reference ?? $json.payload.agreement_name ?? \"\" }}"
            },
            {
              "id": "when",
              "name": "when",
              "type": "string",
              "value": "={{ $json.payload.due_at ?? $json.payload.notification_deadline ?? $json.payload.review_due_date ?? $json.payload.due_date ?? $json.timestamp }}"
            },
            {
              "id": "link",
              "name": "link",
              "type": "string",
              "value": "={{ $json.payload.dashboard_url ?? \"https://app.izini.ng/dashboard\" }}"
            }
          ]
        }
      }
    },
    {
      "id": "78553c48-79a8-4604-8f80-3b0fbd397706",
      "name": "Add a row",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        1760,
        200
      ],
      "parameters": {
        "resource": "sheet",
        "operation": "append",
        "authentication": "oAuth2",
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Received": "={{ $now.toISO() }}",
            "Event": "={{ $json.event }}",
            "Headline": "={{ $json.headline }}",
            "Reference": "={{ $json.reference }}",
            "Date": "={{ $json.when }}",
            "Project": "={{ $json.project_id }}",
            "Delivery": "={{ $json.id }}",
            "Link": "={{ $json.link }}"
          },
          "schema": [
            {
              "id": "Received",
              "displayName": "Received",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Event",
              "displayName": "Event",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Headline",
              "displayName": "Headline",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Reference",
              "displayName": "Reference",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Date",
              "displayName": "Date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Project",
              "displayName": "Project",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Delivery",
              "displayName": "Delivery",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Link",
              "displayName": "Link",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ]
        },
        "options": {}
      }
    }
  ],
  "connections": {
    "Izini webhook": {
      "main": [
        [
          {
            "node": "Read raw body",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read raw body": {
      "main": [
        [
          {
            "node": "Sign with your webhook secret",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sign with your webhook secret": {
      "main": [
        [
          {
            "node": "Signed by Izini, sent in the last 5 minutes?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Signed by Izini, sent in the last 5 minutes?": {
      "main": [
        [
          {
            "node": "Answer 200",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Answer 401",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Answer 200": {
      "main": [
        [
          {
            "node": "Parse event",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse event": {
      "main": [
        [
          {
            "node": "Skip repeats",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Skip repeats": {
      "main": [
        [
          {
            "node": "Describe event",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Describe event": {
      "main": [
        [
          {
            "node": "Add a row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false,
    "source": "https://app.izini.ng/developers/guides/events-to-your-tools"
  }
}
