N8n workflows for the Discover Regenerative API

The Australian team is developing a new website to showcase regenerative producers and help wholesale buyers to find their produce. The main directory is implemented as web component and fetches data from an API. The API is mainly based on the Data Food Consortium standard but has been extended and modified a bit to suit the constraints of the web component implemented with the Startin’Blox framework.

Below are the current n8n workflows to provide the API endpoints (in several posts). You can import them into your n8n account and then change all the Airtable nodes to user your credentials and point to your data.

Related topics:

{
  "name": "List producers",
  "nodes": [
    {
      "parameters": {
        "options": {}
      },
      "id": "7da0f772-6d53-4d90-95af-f22947f81f6b",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1420,
        260
      ]
    },
    {
      "parameters": {
        "authentication": "airtableTokenApi",
        "operation": "list",
        "application": {
          "__rl": true,
          "value": "https://airtable.com/appYTxkFLvN3W4J6C/tblP4i5QIdYtmxrwN",
          "mode": "url",
          "__regex": "https://airtable.com/([a-zA-Z0-9]{2,})"
        },
        "table": {
          "__rl": true,
          "value": "https://airtable.com/appYTxkFLvN3W4J6C/tblP4i5QIdYtmxrwN/viwmhktn3zlXoScG8",
          "mode": "url",
          "__regex": "https://airtable.com/[a-zA-Z0-9]{2,}/([a-zA-Z0-9]{2,})"
        },
        "additionalOptions": {
          "view": "viwD9cQqttDRfCM9y"
        }
      },
      "id": "ba592d9c-e7ca-4861-a70a-4232256f1669",
      "name": "Airtable",
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 1,
      "position": [
        600,
        260
      ],
      "credentials": {
        "airtableTokenApi": {
          "id": "TXqyAKUNoMiPowTA",
          "name": "Maikel's Airtable token for Regen"
        }
      }
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            {
              "name": "@id",
              "value": "=https://n8n.openfoodnetwork.org.uk/webhook/regen/producer?id={{ $json.id }}"
            }
          ]
        },
        "options": {
          "dotNotation": true
        }
      },
      "id": "07ea92d6-b57f-4135-96bf-bdeb7d890f8f",
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        1060,
        260
      ]
    },
    {
      "parameters": {
        "jsCode": "var list = $input.all().map((i) => i.json);\n\nreturn {\n  \"@context\": \"https://discover.openfoodnetwork.org.au/context.json\",\n  \"@id\": \"https://n8n.openfoodnetwork.org.uk/webhook/regen/producers\",\n  \"@type\": \"ldp:Container\",\n  \"ldp:contains\": list\n}\n"
      },
      "id": "a847b084-8a78-42e1-9bd4-aea855376458",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        1200,
        260
      ]
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{ $json.fields.Source }}",
              "operation": "notEqual",
              "value2": "={{ undefined }}"
            }
          ]
        }
      },
      "id": "f72667b6-c020-409e-a831-30bb4aeddf28",
      "name": "Filter",
      "type": "n8n-nodes-base.filter",
      "typeVersion": 1,
      "position": [
        820,
        260
      ]
    },
    {
      "parameters": {
        "path": "regen/produce_categories",
        "responseMode": "responseNode",
        "options": {
          "ignoreBots": false
        }
      },
      "id": "57d8de5a-c2e8-4e1f-9cb4-df16b0615361",
      "name": "List produce categories",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        420,
        540
      ],
      "webhookId": "cd454bfd-3800-4a9b-b23a-5e8f1d7942c3"
    },
    {
      "parameters": {
        "authentication": "airtableTokenApi",
        "operation": "list",
        "application": {
          "__rl": true,
          "value": "https://airtable.com/appYTxkFLvN3W4J6C/tblP4i5QIdYtmxrwN",
          "mode": "url",
          "__regex": "https://airtable.com/([a-zA-Z0-9]{2,})"
        },
        "table": {
          "__rl": true,
          "value": "https://airtable.com/appYTxkFLvN3W4J6C/tblP4i5QIdYtmxrwN/viwmhktn3zlXoScG8",
          "mode": "url",
          "__regex": "https://airtable.com/[a-zA-Z0-9]{2,}/([a-zA-Z0-9]{2,})"
        },
        "additionalOptions": {
          "fields": [
            "Produce category"
          ],
          "view": "viwD9cQqttDRfCM9y"
        }
      },
      "id": "33162689-1bdf-446c-933a-e344e89f5499",
      "name": "Airtable categories",
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 1,
      "position": [
        600,
        540
      ],
      "credentials": {
        "airtableTokenApi": {
          "id": "TXqyAKUNoMiPowTA",
          "name": "Maikel's Airtable token for Regen"
        }
      }
    },
    {
      "parameters": {
        "operation": "aggregateItems",
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "category",
              "renameField": true,
              "outputFieldName": "categories"
            }
          ]
        },
        "options": {}
      },
      "id": "855a6787-d346-41bb-ba7d-87352403fa5d",
      "name": "Item Lists",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 2.2,
      "position": [
        1840,
        540
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify(\n{\n  \"@context\": \"https://api.regenerative.org.au/context.json\",\n  \"@id\": \"https://n8n.openfoodnetwork.org.uk/webhook/regen/produce_categories\",\n  \"@type\": \"ldp:Container\",\n  \"ldp:contains\": $json.categories\n}\n) }}",
        "options": {}
      },
      "id": "22c2556e-5386-4813-8e6b-85f9bc504410",
      "name": "Respond with categories",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        2020,
        540
      ]
    },
    {
      "parameters": {
        "fieldToSplitOut": "fields['Produce category']",
        "options": {}
      },
      "id": "2119b050-ed29-460d-9933-5d7d7e36817a",
      "name": "Split categories",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 2.2,
      "position": [
        760,
        540
      ]
    },
    {
      "parameters": {
        "operation": "sort",
        "sortFieldsUi": {
          "sortField": [
            {
              "fieldName": "other"
            },
            {
              "fieldName": "['fields[\\'Produce category\\']']"
            }
          ]
        },
        "options": {}
      },
      "id": "c5f8e5f0-5701-4729-b77c-a7fc0461b4a9",
      "name": "Item Lists1",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 2.2,
      "position": [
        1360,
        540
      ]
    },
    {
      "parameters": {
        "operation": "removeDuplicates"
      },
      "id": "22c7ffc0-1709-41e4-9317-3409b0f94087",
      "name": "Item Lists2",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 2.2,
      "position": [
        960,
        540
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "var category = $json[\"fields['Produce category']\"];\n\n$json.category = {\n  \"@id\":\"https://n8n.openfoodnetwork.org.uk/webhook/regen/produce_category?id=\" + encodeURI(category),\n  \"@type\": \"http://www.w3.org/2004/02/skos/core#Concept\",\n  \"ofn:label\": category\n}\n\n\nreturn $input.item;"
      },
      "id": "2188d9d5-059d-4afc-aa8e-cbc76464eacf",
      "name": "Code1",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        1580,
        540
      ]
    },
    {
      "parameters": {
        "values": {
          "boolean": [
            {
              "name": "other",
              "value": "={{ $json['fields[\\'Produce category\\']'] == \"Other\" }}"
            }
          ]
        },
        "options": {}
      },
      "id": "41dadd1b-7eff-4bb4-8acc-28a619c9ec93",
      "name": "Set1",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        1180,
        540
      ]
    },
    {
      "parameters": {
        "path": "regen/producers",
        "responseMode": "responseNode",
        "options": {
          "ignoreBots": false
        }
      },
      "id": "549d6ff8-2a7f-411b-b815-812efa290fc0",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        420,
        260
      ],
      "webhookId": "f264e173-e8b4-4d14-bbca-335e13696346"
    }
  ],
  "pinData": {},
  "connections": {
    "Airtable": {
      "main": [
        [
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter": {
      "main": [
        [
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "List produce categories": {
      "main": [
        [
          {
            "node": "Airtable categories",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Airtable categories": {
      "main": [
        [
          {
            "node": "Split categories",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Item Lists": {
      "main": [
        [
          {
            "node": "Respond with categories",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split categories": {
      "main": [
        [
          {
            "node": "Item Lists2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Item Lists1": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Item Lists2": {
      "main": [
        [
          {
            "node": "Set1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code1": {
      "main": [
        [
          {
            "node": "Item Lists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set1": {
      "main": [
        [
          {
            "node": "Item Lists1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Airtable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {},
  "versionId": "03416c49-c02a-40ae-9331-10874e1070ce",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "28870f2868c6821b7375131334e38ef8f27782bd5b2dd7efd016a3383f12b722"
  },
  "id": "O6YrofjdUoM7LzGa",
  "tags": []
}
{
  "name": "List products",
  "nodes": [
    {
      "parameters": {
        "options": {}
      },
      "id": "f57a645a-f650-4982-9c75-364d2bfe3ba9",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1640,
        340
      ]
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            {
              "name": "@id",
              "value": "=https://n8n.openfoodnetwork.org/webhook/regen/product?id={{ $json.id }}"
            }
          ]
        },
        "options": {
          "dotNotation": true
        }
      },
      "id": "2d438d19-1f8e-46aa-b3c2-96a5be1adf3d",
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        1260,
        440
      ]
    },
    {
      "parameters": {
        "jsCode": "var list = $input.all().map((i) => i.json);\n\nreturn {\n  \"@context\": \"https://discover.openfoodnetwork.org.au/context.json\",\n  \"@id\": \"https://n8n.openfoodnetwork.org/webhook/regen/products\",\n  \"@type\": \"ldp:Container\",\n  \"ldp:contains\": list\n}\n"
      },
      "id": "eef04058-a5e2-4b4e-a1a8-4c46fb075115",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        1420,
        440
      ]
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{ $json.fields['User API key (from Enterprises)'] }}",
              "operation": "notEqual",
              "value2": "={{ undefined }}"
            }
          ]
        }
      },
      "id": "6123eda8-e075-46ba-b71f-b4392c4acdc1",
      "name": "Filter",
      "type": "n8n-nodes-base.filter",
      "typeVersion": 1,
      "position": [
        1040,
        440
      ]
    },
    {
      "parameters": {
        "path": "regen/products",
        "responseMode": "responseNode",
        "options": {
          "ignoreBots": false
        }
      },
      "id": "9cad73c9-4d9c-470a-9452-da27aab7eddd",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        340,
        340
      ],
      "webhookId": "08edb3f7-5887-46a9-8e00-50a3ed83df01"
    },
    {
      "parameters": {
        "authentication": "airtableTokenApi",
        "application": {
          "__rl": true,
          "value": "https://airtable.com/appYTxkFLvN3W4J6C/tblP4i5QIdYtmxrwN/viwmhktn3zlXoScG8",
          "mode": "url",
          "__regex": "https://airtable.com/([a-zA-Z0-9]{2,})"
        },
        "table": {
          "__rl": true,
          "value": "https://airtable.com/appYTxkFLvN3W4J6C/tblP4i5QIdYtmxrwN/viwD9cQqttDRfCM9y",
          "mode": "url",
          "__regex": "https://airtable.com/[a-zA-Z0-9]{2,}/([a-zA-Z0-9]{2,})"
        },
        "id": "={{ $json.query.id }}\n"
      },
      "id": "3fc24304-5614-463f-af04-969a0eabcbe9",
      "name": "Airtable1",
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 1,
      "position": [
        820,
        260
      ],
      "credentials": {
        "airtableTokenApi": {
          "id": "TXqyAKUNoMiPowTA",
          "name": "Maikel's Airtable token for Regen"
        }
      }
    },
    {
      "parameters": {
        "fieldToSplitOut": "fields['Featured products (Record IDs)']",
        "options": {}
      },
      "id": "960b9858-a67f-421f-8b27-e87d8af3f981",
      "name": "Item Lists",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 2.2,
      "position": [
        1040,
        260
      ]
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            {
              "name": "@id",
              "value": "=https://n8n.openfoodnetwork.org/webhook/regen/product?id={{ $json['fields[\\'Featured products (Record IDs)\\']'] }}"
            }
          ]
        },
        "options": {
          "dotNotation": true
        }
      },
      "id": "78f013bf-549f-4543-bdb0-b19273319143",
      "name": "Set1",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        1260,
        260
      ]
    },
    {
      "parameters": {
        "jsCode": "var list = $input.all().map((i) => i.json);\n\nvar enterprise_id = $('Webhook').first().json.query.id;\n\nreturn {\n  \"@context\": \"https://discover.openfoodnetwork.org.au/context.json\",\n  \"@id\": \"https://n8n.openfoodnetwork.org/webhook/regen/products?id=\" + enterprise_id,\n  \"@type\": \"ldp:Container\",\n  \"ldp:contains\": list\n}\n"
      },
      "id": "81232f34-2358-4501-8da3-299ed50c65dc",
      "name": "Code1",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        1420,
        260
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "8ef17cfc-391a-4601-91cf-4edf3789dbcc",
              "leftValue": "={{ $json.query.id }}",
              "rightValue": "=",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "04f01463-3637-4cc2-ac44-097bc827cff6",
      "name": "If for one producer",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        540,
        340
      ]
    },
    {
      "parameters": {
        "authentication": "airtableTokenApi",
        "operation": "list",
        "application": {
          "__rl": true,
          "value": "https://airtable.com/appYTxkFLvN3W4J6C/tbldjknx5NuYewe2W/viwAj6VI5mvDYzwIW?blocks=hide",
          "mode": "url",
          "__regex": "https://airtable.com/([a-zA-Z0-9]{2,})"
        },
        "table": {
          "__rl": true,
          "value": "https://airtable.com/appYTxkFLvN3W4J6C/tbldjknx5NuYewe2W/viwAj6VI5mvDYzwIW?blocks=hide",
          "mode": "url",
          "__regex": "https://airtable.com/[a-zA-Z0-9]{2,}/([a-zA-Z0-9]{2,})"
        },
        "additionalOptions": {
          "fields": [],
          "filterByFormula": "",
          "view": "viwAj6VI5mvDYzwIW"
        }
      },
      "id": "9d25edc0-c8d9-4178-8bb4-90b8d54b26d6",
      "name": "Products of all producers",
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 1,
      "position": [
        820,
        440
      ],
      "credentials": {
        "airtableTokenApi": {
          "id": "TXqyAKUNoMiPowTA",
          "name": "Maikel's Airtable token for Regen"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Set": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter": {
      "main": [
        [
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "If for one producer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Airtable1": {
      "main": [
        [
          {
            "node": "Item Lists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Item Lists": {
      "main": [
        [
          {
            "node": "Set1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set1": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code1": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If for one producer": {
      "main": [
        [
          {
            "node": "Airtable1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Products of all producers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Products of all producers": {
      "main": [
        [
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {},
  "versionId": "fe021140-fe5a-40d2-aa97-41616e257c64",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "28870f2868c6821b7375131334e38ef8f27782bd5b2dd7efd016a3383f12b722"
  },
  "id": "l8m6PTQBg52zWwNH",
  "tags": []
}
{
  "name": "Show producer",
  "nodes": [
    {
      "parameters": {
        "path": "regen/producer",
        "responseMode": "responseNode",
        "options": {
          "ignoreBots": false
        }
      },
      "id": "43a506bb-f5cb-495d-8796-ca1c199b1844",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        260,
        200
      ],
      "webhookId": "9e41f6ec-dfa9-4977-b3fb-bd1f79fdfd0e"
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "927222b0-d3de-45f8-b3e5-d6614eb5ca51",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1500,
        200
      ]
    },
    {
      "parameters": {
        "jsCode": "function ldpContainerize(object, key, container_id, prefix) {\n  var ids = object[key];\n  \n  if (ids === undefined) return undefined;\n  if (ids.constructor !== Array) {\n    ids = [ids];\n  }\n  var list = ids.map((id) => ({\"@id\": prefix + id}));\n  object[key] = {\n    \"@id\": container_id,\n    \"@type\": \"ldp:Container\",\n    \"ldp:contains\": list\n  };\n}\n\nfunction replaceURLList(subject, key, webhook, id) {\n  var value = subject[key];\n\n  if (value === undefined) return undefined;\n  if (value.constructor !== Array) {\n    value = [value];\n  }\n  \n  subject[key] = value.map((url) => webhookURL(url, webhook, id));\n}\n\nfunction replaceURL(subject, key, webhook, id) {\n  subject[key] = { \"@id\": webhookURL(subject[key], webhook, id) }\n}\n\nfunction webhookURL(url, webhook, id) {\n  var source = \"https://openfoodnetwork.org.au/api/dfc\";\n  var endpoint = \"https://n8n.openfoodnetwork.org.uk/webhook/\" + webhook;\n  return url.replace(source, endpoint) + \"?id=\" + id;\n}\n\nvar enterprise = items[0].json[\"@graph\"][0];\nvar regen_data = items[1].json;\nvar record_id = regen_data[\"@id\"].split(\"=\").pop();\n\nreplaceURL(enterprise, \"dfc-b:hasAddress\", \"888be4b3-5b54-4e98-8808-c6aabc0e375c\", record_id);\nreplaceURLList(enterprise, \"dfc-b:hasSocialMedia\", \"b9c3687f-9f0f-4628-9bcc-f3331afb6fa8\", record_id);\nldpContainerize(enterprise, \"dfc-b:hasSocialMedia\", \"https://n8n.openfoodnetwork.org.uk/webhook/regen/social_medias?id=\" + record_id, \"\");\n\ndelete enterprise[\"dfc-b:manages\"];\ndelete enterprise[\"dfc-b:affiliates\"];\n\n// \"[Direct online purchase, Email, Phone]\"\nvar contact_prefs = regen_data[\"ofn:Wholesale_enquiry_preferences\"] ?? [];\nif (!contact_prefs.includes(\"Email\")) {\n  delete enterprise[\"dfc-b:email\"];\n}\nif (!contact_prefs.includes(\"Phone\")) {\n  delete enterprise[\"dfc-b:hasPhoneNumber\"];\n}\n\nObject.assign(enterprise, regen_data);\n\nreturn [enterprise];"
      },
      "id": "52e8fd86-11ae-4204-9fee-0c6fbe816568",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        1140,
        20
      ]
    },
    {
      "parameters": {
        "authentication": "airtableTokenApi",
        "application": {
          "__rl": true,
          "value": "https://airtable.com/appYTxkFLvN3W4J6C/tblP4i5QIdYtmxrwN/viwmhktn3zlXoScG8",
          "mode": "url",
          "__regex": "https://airtable.com/([a-zA-Z0-9]{2,})"
        },
        "table": {
          "__rl": true,
          "value": "https://airtable.com/appYTxkFLvN3W4J6C/tblP4i5QIdYtmxrwN/viwD9cQqttDRfCM9y",
          "mode": "url",
          "__regex": "https://airtable.com/[a-zA-Z0-9]{2,}/([a-zA-Z0-9]{2,})"
        },
        "id": "={{ $json.query.id }}\n"
      },
      "id": "a4322610-4904-4e35-82f8-35ec0fc61351",
      "name": "Airtable",
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 1,
      "position": [
        580,
        0
      ],
      "credentials": {
        "airtableTokenApi": {
          "id": "TXqyAKUNoMiPowTA",
          "name": "Maikel's Airtable token for Regen"
        }
      }
    },
    {
      "parameters": {},
      "id": "ac8ba2f1-b248-49e3-9764-c837240a915e",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 2.1,
      "position": [
        940,
        20
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "\nfunction ldpContainerize(ids, container_id, prefix) {\n  if (!Array.isArray(ids)) { return undefined }\n  var list = ids.map((id) => ({\"@id\": prefix + encodeURI(id)}));\n  return {\n    \"@id\": container_id,\n    \"@type\": \"ldp:Container\",\n    \"ldp:contains\": list\n  };\n}\n\nvar record_id = $json.id;\nvar regen_data = $json.fields;\nvar public_fields = [\n  \"First Nations country\",\n  \"State code\",\n  \"State\",\n  \"First Nations led\",\n  \"Traditional Practices\",\n  \"Practices\",\n  \"Produce category\",\n  \"Wholesale enquiry preferences\",\n  \"Wholesale buy description\",\n  \"Wholesale URL 1 label\",\n  \"Wholesale URL 1\",\n  \"Wholesale URL 2 label\",\n  \"Wholesale URL 2\",\n  \"Wholesale URL 3 label\",\n  \"Wholesale URL 3\",\n  \"Selling to household\",\n  \"Household buy label\",\n  \"Household URL\",\n];\nvar public_data = public_fields.reduce(\n  (result, field) => {\n    var key = \"ofn:\" + field.replaceAll(\" \", \"_\");\n    result[key] = regen_data[field];\n    return result;\n  },\n  {}\n);\n\npublic_data[\"dfc-b:supplies\"] = ldpContainerize(\n  regen_data[\"Featured products (Record IDs)\"],\n  \"https://n8n.openfoodnetwork.org.uk/webhook/regen/producer/products?id=\" + record_id,\n  \"https://n8n.openfoodnetwork.org.uk/webhook/regen/product?id=\"\n);\n\npublic_data[\"ofn:hasProduceCategory\"] = ldpContainerize(\n  regen_data[\"Produce category\"],\n  \"https://n8n.openfoodnetwork.org.uk/webhook/regen/producer/produce_categories?id=\" + record_id,\n  \"https://n8n.openfoodnetwork.org.uk/webhook/regen/produce_category?id=\"\n);\npublic_data[\"ofn:hasAssurancePartnerships\"] = ldpContainerize(\n  regen_data[\"Confirmed Assurance partnerships (record IDs)\"],\n  \"https://n8n.openfoodnetwork.org.uk/webhook/regen/producer/partnerships?id=\" + record_id,\n  \"https://n8n.openfoodnetwork.org.uk/webhook/regen/assurance?id=\"\n);\npublic_data[\"ofn:hasCertifications\"] = ldpContainerize(\n  regen_data[\"Confirmed Certifications (record IDs)\"],\n  \"https://n8n.openfoodnetwork.org.uk/webhook/regen/producer/certifications?id=\" + record_id,\n  \"https://n8n.openfoodnetwork.org.uk/webhook/regen/assurance?id=\"\n);\npublic_data[\"ofn:hasSupportingEvidence\"] = ldpContainerize(\n  regen_data[\"Airtable recordID Rollup (from Supporting evidence)\"],\n  \"https://n8n.openfoodnetwork.org.uk/webhook/regen/producer/evidence?id=\" + record_id,\n  \"https://n8n.openfoodnetwork.org.uk/webhook/regen/assurance?id=\"\n);\n\npublic_data[\"ofn:contact_email_endpoint_uri\"] = \"https://n8n.openfoodnetwork.org.uk/webhook/regen/contact-email?id=\" + record_id;\npublic_data[\"@id\"] = \"https://n8n.openfoodnetwork.org.uk/webhook/regen/producer?id=\" + record_id;\npublic_data[\"@context\"] = \"https://discover.openfoodnetwork.org.au/context.json\";\n\nreturn public_data;"
      },
      "id": "7c860c14-537c-40dd-b5f7-62bf6ab0c485",
      "name": "Regen producer data",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        760,
        100
      ]
    },
    {
      "parameters": {
        "url": "=https://openfoodnetwork.org.au/api/dfc/enterprises/{{ $json.fields.uid }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {}
      },
      "id": "6232db76-569c-49c1-9f5d-14a4593fd19b",
      "name": "OFN DFC API",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        760,
        -80
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "HtdqHbr4tczScLlN",
          "name": "OFN API Token from Airtable record"
        }
      }
    },
    {
      "parameters": {
        "path": "regen/social_medias",
        "responseMode": "responseNode",
        "options": {
          "ignoreBots": false
        }
      },
      "id": "cf2e963e-aa18-43f0-ba76-412474dc628e",
      "name": "Social Medias",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        260,
        1100
      ],
      "webhookId": "9e41f6ec-dfa9-4977-b3fb-bd1f79fdfd0e"
    },
    {
      "parameters": {
        "authentication": "airtableTokenApi",
        "application": {
          "__rl": true,
          "value": "https://airtable.com/appYTxkFLvN3W4J6C/tblP4i5QIdYtmxrwN/viwmhktn3zlXoScG8",
          "mode": "url",
          "__regex": "https://airtable.com/([a-zA-Z0-9]{2,})"
        },
        "table": {
          "__rl": true,
          "value": "https://airtable.com/appYTxkFLvN3W4J6C/tblP4i5QIdYtmxrwN/viwD9cQqttDRfCM9y",
          "mode": "url",
          "__regex": "https://airtable.com/[a-zA-Z0-9]{2,}/([a-zA-Z0-9]{2,})"
        },
        "id": "={{ $json.query.id }}\n"
      },
      "id": "f7cc1bd9-1ba5-465d-ace4-fed406c469af",
      "name": "Read enterprise",
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 1,
      "position": [
        400,
        1100
      ],
      "credentials": {
        "airtableTokenApi": {
          "id": "TXqyAKUNoMiPowTA",
          "name": "Maikel's Airtable token for Regen"
        }
      }
    },
    {
      "parameters": {
        "url": "=https://openfoodnetwork.org.au/api/dfc/enterprises/{{ $json.fields.uid }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {}
      },
      "id": "59619fa8-0661-4e20-9703-55ce255b14d5",
      "name": "OFN DFC API1",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        660,
        1100
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "HtdqHbr4tczScLlN",
          "name": "OFN API Token from Airtable record"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "function ldpContainerize(object, key, container_id, prefix) {\n  var ids = object[key];\n  \n  if (ids === undefined) return undefined;\n  if (ids.constructor !== Array) {\n    ids = [ids];\n  }\n  var list = ids.map((id) => ({\"@id\": prefix + id}));\n  object[key] = {\n    \"@id\": container_id,\n    \"@type\": \"ldp:Container\",\n    \"ldp:contains\": list\n  };\n}\n\nfunction replaceURLList(subject, key, webhook, id) {\n  var value = subject[key];\n\n  if (value === undefined) return undefined;\n  if (value.constructor !== Array) {\n    value = [value];\n  }\n  \n  subject[key] = value.map((url) => webhookURL(url, webhook, id));\n}\n\nfunction replaceURL(subject, key, webhook, id) {\n  subject[key] = webhookURL(subject[key], webhook, id)\n}\n\nfunction webhookURL(url, webhook, id) {\n  var source = \"https://openfoodnetwork.org.au/api/dfc\";\n  var endpoint = \"https://n8n.openfoodnetwork.org.uk/webhook/\" + webhook;\n  return url.replace(source, endpoint) + \"?id=\" + id;\n}\n\nvar enterprise = items[0].json[\"@graph\"][0];\n\nvar record_id = $('Social Medias').first().json.query.id;\n\nreplaceURLList(enterprise, \"dfc-b:hasSocialMedia\", \"b9c3687f-9f0f-4628-9bcc-f3331afb6fa8\", record_id);\nldpContainerize(enterprise, \"dfc-b:hasSocialMedia\", \"https://n8n.openfoodnetwork.org.uk/webhook/regen/social_medias?id=\" + record_id, \"\");\n\n\nreturn [enterprise[\"dfc-b:hasSocialMedia\"]];"
      },
      "id": "d8a4c1f5-d854-4d89-baab-007bd5508eac",
      "name": "List Social Media",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        1120,
        1100
      ]
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "be8a983b-5fb5-4c71-a312-d92a119fec05",
      "name": "Respond to Webhook1",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1280,
        1100
      ]
    },
    {
      "parameters": {
        "path": "regen/producer/certifications",
        "responseMode": "responseNode",
        "options": {
          "ignoreBots": false
        }
      },
      "id": "33956fbb-8424-43a4-bd67-e2081a8d63e6",
      "name": "Certifications",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        260,
        340
      ],
      "webhookId": "76eb1f0c-4d42-4bfd-b0ee-63e82cbe7d43"
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify($json[\"ofn:hasCertifications\"]) }}",
        "options": {}
      },
      "id": "4c9efc96-5126-4d2a-8ff6-677fc9213b06",
      "name": "Respond with certifications",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1500,
        340
      ]
    },
    {
      "parameters": {
        "path": "regen/producer/partnerships",
        "responseMode": "responseNode",
        "options": {
          "ignoreBots": false
        }
      },
      "id": "72de64cf-449f-4089-a5b0-41906907c451",
      "name": "Partnerships",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        260,
        480
      ],
      "webhookId": "99cc983d-6e09-494b-bbe8-6f77b0ba139d"
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify($json[\"ofn:hasAssurancePartnerships\"]) }}",
        "options": {}
      },
      "id": "2cb16f39-d663-4ad5-99aa-77788745148d",
      "name": "Respond with Partnerships",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1500,
        480
      ]
    },
    {
      "parameters": {
        "path": "regen/producer/evidence",
        "responseMode": "responseNode",
        "options": {
          "ignoreBots": false
        }
      },
      "id": "2390eff5-07c5-4ed8-bc79-9570666d9774",
      "name": "Evidence",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        260,
        620
      ],
      "webhookId": "1f2fe434-2949-4e88-a8fb-b2b8e5bd6e22"
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify($json[\"ofn:hasSupportingEvidence\"]) }}",
        "options": {}
      },
      "id": "59f83ffe-4e69-4b64-8a70-dd2e5d8a1b90",
      "name": "Respond with Evidence",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1500,
        620
      ]
    },
    {
      "parameters": {
        "path": "regen/producer/produce_categories",
        "responseMode": "responseNode",
        "options": {
          "ignoreBots": false
        }
      },
      "id": "97a49800-fb40-4cbd-ab2b-9560ec54d2fc",
      "name": "Produce Categories",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        260,
        760
      ],
      "webhookId": "59e7e38c-e56f-465e-8394-b1945539e2ae"
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify($json[\"ofn:hasProduceCategory\"]) }}",
        "options": {}
      },
      "id": "26b407d3-7462-45b3-ad5c-09a7e2fcdc29",
      "name": "Respond with Produce Categories",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1500,
        760
      ]
    },
    {
      "parameters": {
        "path": "regen/produce_category",
        "responseMode": "responseNode",
        "options": {
          "ignoreBots": false
        }
      },
      "id": "dd86df4b-90e5-4015-adef-c5c5b1747df6",
      "name": "Show Produce Category",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        260,
        920
      ],
      "webhookId": "1f2b1197-179c-4c15-b710-9ae3163c8b73"
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify(\n{\n  \"@context\": \"https://discover.openfoodnetwork.org.au/context.json\",\n  \"@id\": \"https://n8n.openfoodnetwork.org.uk/webhook/regen/produce_category?id=\" + encodeURI($json.query.id),\n  \"@type\": \"http://www.w3.org/2004/02/skos/core#Concept\",\n  \"ofn:label\": $json.query.id\n}\n) }}",
        "options": {}
      },
      "id": "e5833658-fd6f-4995-9f60-90170fe2a053",
      "name": "Respond with Produce Category",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        480,
        920
      ]
    },
    {
      "parameters": {
        "mode": "chooseBranch"
      },
      "id": "ca3c2b5c-da6e-4822-b10e-b7fa3ecc6d79",
      "name": "Merge1",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 2.1,
      "position": [
        1280,
        340
      ]
    },
    {
      "parameters": {
        "mode": "chooseBranch"
      },
      "id": "09af645e-480e-43d0-89cd-d77ded2b0373",
      "name": "Merge2",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 2.1,
      "position": [
        1280,
        480
      ]
    },
    {
      "parameters": {
        "mode": "chooseBranch"
      },
      "id": "dc7a7d88-5dff-499d-99bb-8fa3e734c672",
      "name": "Merge3",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 2.1,
      "position": [
        1280,
        620
      ]
    },
    {
      "parameters": {
        "mode": "chooseBranch"
      },
      "id": "5c6ab65c-de27-40c6-bed4-2f75a1a34888",
      "name": "Merge4",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 2.1,
      "position": [
        1280,
        760
      ]
    },
    {
      "parameters": {
        "mode": "chooseBranch"
      },
      "id": "bbb69439-a1cb-4ed2-9327-3c91d5d2baa3",
      "name": "Merge5",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 2.1,
      "position": [
        1280,
        200
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "0fa7df11-0e50-4581-b245-9b1257a0c65b",
              "leftValue": "={{ $json.query }}",
              "rightValue": "=0",
              "operator": {
                "type": "object",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "1f9689d9-5c7f-4a27-82a9-222c4070f301",
      "name": "Filter",
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2,
      "position": [
        420,
        0
      ]
    }
  ],
  "pinData": {},
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Merge5",
            "type": "main",
            "index": 1
          },
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge2",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge3",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge4",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Airtable": {
      "main": [
        [
          {
            "node": "OFN DFC API",
            "type": "main",
            "index": 0
          },
          {
            "node": "Regen producer data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Regen producer data": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "OFN DFC API": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Social Medias": {
      "main": [
        [
          {
            "node": "Read enterprise",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read enterprise": {
      "main": [
        [
          {
            "node": "OFN DFC API1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OFN DFC API1": {
      "main": [
        [
          {
            "node": "List Social Media",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "List Social Media": {
      "main": [
        [
          {
            "node": "Respond to Webhook1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Certifications": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          },
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Partnerships": {
      "main": [
        [
          {
            "node": "Merge2",
            "type": "main",
            "index": 1
          },
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Evidence": {
      "main": [
        [
          {
            "node": "Merge3",
            "type": "main",
            "index": 1
          },
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Produce Categories": {
      "main": [
        [
          {
            "node": "Merge4",
            "type": "main",
            "index": 1
          },
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Show Produce Category": {
      "main": [
        [
          {
            "node": "Respond with Produce Category",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "Respond with certifications",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge2": {
      "main": [
        [
          {
            "node": "Respond with Partnerships",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge3": {
      "main": [
        [
          {
            "node": "Respond with Evidence",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge4": {
      "main": [
        [
          {
            "node": "Respond with Produce Categories",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge5": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter": {
      "main": [
        [
          {
            "node": "Airtable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {},
  "versionId": "0efa4310-88a8-4d2a-adef-419467305c1f",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "28870f2868c6821b7375131334e38ef8f27782bd5b2dd7efd016a3383f12b722"
  },
  "id": "iAuP2uaX0zEE1iJ5",
  "tags": []
}
{
  "name": "Show product",
  "nodes": [
    {
      "parameters": {
        "path": "regen/product",
        "responseMode": "responseNode",
        "options": {
          "ignoreBots": false
        }
      },
      "id": "532c74d8-32ee-406d-9bd9-92fd1335a47a",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        320,
        260
      ],
      "webhookId": "64e10622-10ec-47b3-ab99-c4eb760d4863"
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "a3f42767-a5d4-4965-b354-afffc37b2fd6",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1260,
        260
      ]
    },
    {
      "parameters": {},
      "id": "65c07c56-3966-4ee8-bfdf-86a3cdd7b623",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 2.1,
      "position": [
        960,
        260
      ]
    },
    {
      "parameters": {
        "authentication": "airtableTokenApi",
        "application": {
          "__rl": true,
          "value": "https://airtable.com/appYTxkFLvN3W4J6C/tbldjknx5NuYewe2W/viwAj6VI5mvDYzwIW?blocks=hide",
          "mode": "url",
          "__regex": "https://airtable.com/([a-zA-Z0-9]{2,})"
        },
        "table": {
          "__rl": true,
          "value": "https://airtable.com/appYTxkFLvN3W4J6C/tbldjknx5NuYewe2W/viwAj6VI5mvDYzwIW?blocks=hide",
          "mode": "url",
          "__regex": "https://airtable.com/[a-zA-Z0-9]{2,}/([a-zA-Z0-9]{2,})"
        },
        "id": "={{ $json.query.id }}\n"
      },
      "id": "73843644-da36-43f4-9f79-6635245f5ccb",
      "name": "Airtable",
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 1,
      "position": [
        460,
        260
      ],
      "credentials": {
        "airtableTokenApi": {
          "id": "TXqyAKUNoMiPowTA",
          "name": "Maikel's Airtable token for Regen"
        }
      }
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "\nvar record_id = $json.id;\nvar regen_data = $json.fields;\nvar public_fields = [\n  \"Type\",\n]\nvar public_data = public_fields.reduce(\n  (result, field) => {\n    var key = \"ofn:\" + field.replaceAll(\" \", \"_\");\n    result[key] = regen_data[field];\n    return result;\n  },\n  {}\n);\n\npublic_data[\"dfc-b:suppliedBy\"] = regen_data.Enterprises[0];\npublic_data[\"@id\"] = \"https://n8n.openfoodnetwork.org.uk/webhook/regen/product?id=\" + record_id;\npublic_data[\"@context\"] = \"https://discover.openfoodnetwork.org.au/context.json\";\n\n\nreturn public_data;"
      },
      "id": "0af41cf4-d2e9-4933-a614-a5a4c14b0d1e",
      "name": "Regen product",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        720,
        340
      ]
    },
    {
      "parameters": {
        "url": "=https://openfoodnetwork.org.au/api/dfc/enterprises/{{ $json.fields['Enterprise ID'] }}/supplied_products/{{ $json.fields['Product ID'] }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {}
      },
      "id": "06a14df9-86ee-4aaf-9d82-da3ff73a9e07",
      "name": "OFN DFC SuppliedProduct",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        720,
        140
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "ZVcShlgPshwKNhRp",
          "name": "OFN API token from Airtable enterprises"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "\nvar dfc_data = items[0].json;\nvar regen_data = items[1].json;\n\nObject.assign(dfc_data, regen_data);\n\ndfc_data[\"dfc-b:suppliedBy\"] = \"https://n8n.openfoodnetwork.org.uk/webhook/regen/producer?id=\" + dfc_data[\"dfc-b:suppliedBy\"];\n\nreturn [dfc_data];"
      },
      "id": "cd5eee18-b293-440a-a65e-4871ae91dea2",
      "name": "Merge data sets",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        1100,
        260
      ]
    }
  ],
  "pinData": {},
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Airtable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Merge data sets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Airtable": {
      "main": [
        [
          {
            "node": "OFN DFC SuppliedProduct",
            "type": "main",
            "index": 0
          },
          {
            "node": "Regen product",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Regen product": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "OFN DFC SuppliedProduct": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge data sets": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {},
  "versionId": "39a72678-5b0b-496b-b737-8479d664142a",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "28870f2868c6821b7375131334e38ef8f27782bd5b2dd7efd016a3383f12b722"
  },
  "id": "uBenqT5DCddIuljm",
  "tags": []
}
{
  "name": "List assurances",
  "nodes": [
    {
      "parameters": {
        "options": {}
      },
      "id": "c00b7ab1-9f65-4457-b450-9ea64890055b",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1380,
        260
      ]
    },
    {
      "parameters": {
        "authentication": "airtableTokenApi",
        "operation": "list",
        "application": {
          "__rl": true,
          "value": "https://airtable.com/appYTxkFLvN3W4J6C/tbl8IMjaEt5SW6VPd/viwsIpEmVpAxZBWew?blocks=hide",
          "mode": "url",
          "__regex": "https://airtable.com/([a-zA-Z0-9]{2,})"
        },
        "table": {
          "__rl": true,
          "value": "https://airtable.com/appYTxkFLvN3W4J6C/tbl8IMjaEt5SW6VPd/viwsIpEmVpAxZBWew?blocks=hide",
          "mode": "url",
          "__regex": "https://airtable.com/[a-zA-Z0-9]{2,}/([a-zA-Z0-9]{2,})"
        },
        "additionalOptions": {
          "fields": [],
          "filterByFormula": "=AND({Assured enterprise recordID}=\"{{ $json.query.id }}\", {Type}=\"{{ $json.query.type }}\")",
          "view": "viwsIpEmVpAxZBWew"
        }
      },
      "id": "8215a4f7-c985-46ed-905d-ea82418ad454",
      "name": "Airtable",
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 1,
      "position": [
        600,
        260
      ],
      "alwaysOutputData": true,
      "credentials": {
        "airtableTokenApi": {
          "id": "TXqyAKUNoMiPowTA",
          "name": "Maikel's Airtable token for Regen"
        }
      }
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "function ldpContainerize(object, key, container_id, prefix) {\n  var ids = object[key];\n\n  if (ids === undefined) { return undefined; };\n  \n  var list = ids.map((id) => ({\"@id\": prefix + id}));\n\n  object[key] = {\n    \"@id\": container_id,\n    \"@type\": \"ldp:Container\",\n    \"ldp:contains\": list\n  };\n}\n\nif ($json.id === undefined) { return {}; }\nvar record_id = $json.id;\nvar regen_data = $json.fields;\nvar public_fields = [\n  \"Type\",\n  \"Creation date\",\n  \"Title\",\n  \"Certification ID\",\n  \"Classification\",\n  \"Description\",\n  \"Service provider\",\n  \"Expiry date\",\n  \"Documentation permissions\",\n  \"Assurance partner\",\n]\nvar public_data = public_fields.reduce(\n  (result, field) => {\n    var key = \"ofn:\" + field.replaceAll(\" \", \"_\");\n    result[key] = regen_data[field];\n    return result;\n  },\n  {}\n);\n\nldpContainerize(\n  public_data, \"ofn:Assurance_partner\",\n  \"https://n8n.openfoodnetwork.org.uk/webhook/regen/groups?id=\" + record_id,\n  \"https://n8n.openfoodnetwork.org.uk/webhook/regen/group?id=\"\n);\n\nif (regen_data[\"Documentation_permissions\"] == \"Publicly available\" && regen_data[\"Attachments\"]) {\n  public_data[\"ofn:attachment_url\"] = regen_data[\"Attachments\"][0].url\n}\n\npublic_data[\"@type\"] = \"ofn:\" + public_data[\"ofn:Type\"];\ndelete public_data[\"ofn:Type\"];\n\npublic_data[\"@id\"] = \"https://n8n.openfoodnetwork.org.uk/webhook/regen/assurance?id=\" + record_id;\n\n\nreturn public_data;"
      },
      "id": "43925f7f-082c-459a-8cea-c8e1f5b59add",
      "name": "Regen data",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        940,
        260
      ],
      "alwaysOutputData": true
    },
    {
      "parameters": {
        "jsCode": "var list = $input.all().map((i) => i.json);\n\nreturn {\n  \"@context\": \"https://discover.openfoodnetwork.org.au/context.json\",\n  \"@id\": \"https://n8n.openfoodnetwork.org.uk/webhook/regen/assurances\",\n  \"@type\": \"ldp:Container\",\n  \"ldp:contains\": list\n}\n"
      },
      "id": "37219612-6194-4178-9671-8957701c8812",
      "name": "Containerise",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        1160,
        260
      ]
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "909c7e1b-2b64-426a-856e-ad00ad9ab7e2",
      "name": "Respond to Webhook1",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1380,
        460
      ]
    },
    {
      "parameters": {
        "authentication": "airtableTokenApi",
        "operation": "list",
        "application": {
          "__rl": true,
          "value": "https://airtable.com/appYTxkFLvN3W4J6C/tblfKbu0lB05jnsNC/viwIdjxqd6IoZkg4k?blocks=hide",
          "mode": "url",
          "__regex": "https://airtable.com/([a-zA-Z0-9]{2,})"
        },
        "table": {
          "__rl": true,
          "value": "https://airtable.com/appYTxkFLvN3W4J6C/tblfKbu0lB05jnsNC/viwIdjxqd6IoZkg4k?blocks=hide",
          "mode": "url",
          "__regex": "https://airtable.com/[a-zA-Z0-9]{2,}/([a-zA-Z0-9]{2,})"
        },
        "additionalOptions": {
          "fields": [],
          "view": "viwIdjxqd6IoZkg4k"
        }
      },
      "id": "65f9f92a-ef48-4982-999c-41f89c0f7069",
      "name": "Airtable1",
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 1,
      "position": [
        600,
        460
      ],
      "alwaysOutputData": true,
      "credentials": {
        "airtableTokenApi": {
          "id": "TXqyAKUNoMiPowTA",
          "name": "Maikel's Airtable token for Regen"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "var list = $input.all().map((i) => i.json);\n\nreturn {\n  \"@context\": \"https://discover.openfoodnetwork.org.au/context.json\",\n  \"@id\": \"https://n8n.openfoodnetwork.org.uk/webhook/regen/assurance_partners\",\n  \"@type\": \"ldp:Container\",\n  \"ldp:contains\": list\n}\n"
      },
      "id": "618a4295-3631-45fd-9c8d-81260b29e562",
      "name": "Containerise1",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        1160,
        460
      ]
    },
    {
      "parameters": {
        "path": "regen/assurances",
        "responseMode": "responseNode",
        "options": {
          "ignoreBots": false
        }
      },
      "id": "28cad1a8-747a-49ab-9b49-b4dabea6fc18",
      "name": "Assurances of enterprise",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        320,
        260
      ],
      "webhookId": "fdca8501-ca9d-4950-8f3b-7ef8b469eaf5"
    },
    {
      "parameters": {
        "path": "regen/assurance_partners",
        "responseMode": "responseNode",
        "options": {
          "ignoreBots": false
        }
      },
      "id": "34e3ce14-a795-47eb-a480-fe6e4fa8b3be",
      "name": "Assurance partners",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        320,
        460
      ],
      "webhookId": "fdca8501-ca9d-4950-8f3b-7ef8b469eaf5"
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            {
              "name": "@id",
              "value": "=https://n8n.openfoodnetwork.org.uk/webhook/regen/group?id={{ $json.id }}"
            }
          ]
        },
        "options": {
          "dotNotation": true
        }
      },
      "id": "aab333ce-f5d8-4bdb-ae50-1ed9aa7f5dcc",
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        960,
        460
      ]
    }
  ],
  "pinData": {},
  "connections": {
    "Airtable": {
      "main": [
        [
          {
            "node": "Regen data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Regen data": {
      "main": [
        [
          {
            "node": "Containerise",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Containerise": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Airtable1": {
      "main": [
        [
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Containerise1": {
      "main": [
        [
          {
            "node": "Respond to Webhook1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Assurances of enterprise": {
      "main": [
        [
          {
            "node": "Airtable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Assurance partners": {
      "main": [
        [
          {
            "node": "Airtable1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set": {
      "main": [
        [
          {
            "node": "Containerise1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {},
  "versionId": "b3a57211-0ff7-4d5c-a2c6-8b3d8240ed30",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "28870f2868c6821b7375131334e38ef8f27782bd5b2dd7efd016a3383f12b722"
  },
  "id": "iNQPhiaN6ZNXGLwC",
  "tags": []
}
{
  "name": "List certification options",
  "nodes": [
    {
      "parameters": {
        "options": {}
      },
      "id": "dc014768-855e-4cce-9dd6-6c1f7d148d93",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        860,
        260
      ]
    },
    {
      "parameters": {
        "jsCode": "\nvar labels = [\n\"Organic\",\n\"Organic (in transition)\",\n\"Biodynamic\",\n\"Biodynamic (in transition)\",\n\"Regenerative\",\n\"Regenerative (in transition)\",\n\"Ecological Outcome Verification\",\n\"Ecological Outcome Verification (initiated)\"\n];\n\nvar label_objects = labels.map((label) => (\n {\n  \"@id\":\"https://n8n.openfoodnetwork.org.uk/webhook/regen/certification?id=\" + encodeURI(label),\n  \"@type\": \"http://www.w3.org/2004/02/skos/core#Concept\",\n  \"ofn:label\": label\n }\n))\n\nvar json = {\n  \"@context\":\"https://api.regenerative.org.au/context.json\",\n  \"@id\":\"https://n8n.openfoodnetwork.org.uk/webhook/regen/certifications\",\n  \"@type\":\"ldp:Container\",\n  \"ldp:contains\": label_objects\n};\nreturn [json];\n"
      },
      "id": "70f91edf-e06d-4fcb-850f-6454311d9ee1",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        540,
        260
      ]
    },
    {
      "parameters": {
        "path": "regen/certifications",
        "responseMode": "responseNode",
        "options": {
          "ignoreBots": false
        }
      },
      "id": "0d0dd562-9675-4a23-aa1b-de8355b1831a",
      "name": "List certification options",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        320,
        260
      ],
      "webhookId": "be374d9d-e754-4cf0-93ad-a6388f3c076d"
    },
    {
      "parameters": {
        "path": "regen/certification",
        "responseMode": "responseNode",
        "options": {
          "ignoreBots": false
        }
      },
      "id": "4a009fff-771d-469c-8296-5e598ec59c8e",
      "name": "Show certification option",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        320,
        440
      ],
      "webhookId": "368ceef0-af58-4e6e-ace6-a3495bfcf00f"
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={\n  \"@id\":\"https://n8n.openfoodnetwork.org.uk/webhook/regen/certification?id={{ encodeURI($json.query.id) }}\",\n  \"@type\": \"http://www.w3.org/2004/02/skos/core#Concept\",\n  \"ofn:label\": \"{{ $json.query.id }}\"\n}",
        "options": {}
      },
      "id": "40d09f4f-7aac-4082-b11d-17dac9fa1363",
      "name": "Respond to Webhook1",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        860,
        440
      ]
    }
  ],
  "pinData": {},
  "connections": {
    "Code": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "List certification options": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Show certification option": {
      "main": [
        [
          {
            "node": "Respond to Webhook1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {},
  "versionId": "8558c5e4-d658-4183-b2c9-106bbddc1300",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "28870f2868c6821b7375131334e38ef8f27782bd5b2dd7efd016a3383f12b722"
  },
  "id": "8MjaAfYUA2JaoHrV",
  "tags": []
}
{
  "name": "Show assurance",
  "nodes": [
    {
      "parameters": {
        "path": "regen/assurance",
        "responseMode": "responseNode",
        "options": {
          "ignoreBots": false
        }
      },
      "id": "0693714b-b122-43b6-9d58-610f1a078fde",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        320,
        260
      ],
      "webhookId": "e8cb714d-0eed-48db-9d9c-9dfe862348a9"
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "92169f5b-1471-4709-b9ad-ee255e5efba3",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1100,
        260
      ]
    },
    {
      "parameters": {
        "authentication": "airtableTokenApi",
        "application": {
          "__rl": true,
          "value": "https://airtable.com/appYTxkFLvN3W4J6C/tbl8IMjaEt5SW6VPd/viwsIpEmVpAxZBWew?blocks=hide",
          "mode": "url",
          "__regex": "https://airtable.com/([a-zA-Z0-9]{2,})"
        },
        "table": {
          "__rl": true,
          "value": "https://airtable.com/appYTxkFLvN3W4J6C/tbl8IMjaEt5SW6VPd/viwsIpEmVpAxZBWew?blocks=hide",
          "mode": "url",
          "__regex": "https://airtable.com/[a-zA-Z0-9]{2,}/([a-zA-Z0-9]{2,})"
        },
        "id": "={{ $json.query.id }}\n"
      },
      "id": "218614ff-135c-42f8-9c2b-b82e6664d357",
      "name": "Airtable",
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 1,
      "position": [
        560,
        260
      ],
      "credentials": {
        "airtableTokenApi": {
          "id": "TXqyAKUNoMiPowTA",
          "name": "Maikel's Airtable token for Regen"
        }
      }
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "function ldpContainerize(object, key, container_id, prefix) {\n  var ids = object[key];\n\n  if (ids === undefined) { return undefined; };\n  \n  var list = ids.map((id) => ({\"@id\": prefix + encodeURI(id)}));\n\n  object[key] = {\n    \"@id\": container_id,\n    \"@type\": \"ldp:Container\",\n    \"ldp:contains\": list\n  };\n}\n\nvar record_id = $json.id;\nvar regen_data = $json.fields;\nvar public_fields = [\n  \"Type\",\n  \"Creation date\",\n  \"Title\",\n  \"Certification ID\",\n  \"Certification status\",\n  \"Classification\",\n  \"Description\",\n  \"Link\",\n  \"Service provider\",\n  \"Expiry date\",  \"Documentation permissions\",\n  \"Assurance partner\",\n]\nvar public_data = public_fields.reduce(\n  (result, field) => {\n    var key = \"ofn:\" + field.replaceAll(\" \", \"_\");\n    result[key] = regen_data[field];\n    return result;\n  },\n  {}\n);\n\npublic_data[\"ofn:service_provider_label\"] = (regen_data[\"Service provider name\"] ?? [])[0];\npublic_data[\"ofn:service_provider_uri\"] = (regen_data[\"Service provider website\"] ?? [])[0];\n\nif (regen_data[\"Attachments\"] && regen_data[\"Attachments\"].length > 0) {\n  public_data[\"ofn:attachment_uri\"] = regen_data[\"Attachments\"][0].url;\n}\n\n\npublic_data[\"ofn:hasCertificationStatus\"] = {\n  \"@id\": \"https://n8n.openfoodnetwork.org.uk/webhook/regen/certification?id=\" + encodeURI(regen_data[\"Certification status\"])\n};\n\nldpContainerize(\n  public_data, \"ofn:Assurance_partner\",\n  \"https://n8n.openfoodnetwork.org.uk/webhook/regen/groups?id=\" + record_id,\n  \"https://n8n.openfoodnetwork.org.uk/webhook/regen/group?id=\"\n);\n\nldpContainerize(\n  public_data, \"ofn:Classification\",\n  \"https://n8n.openfoodnetwork.org.uk/webhook/regen/assurance/classifications?id=\" + record_id,\n  \"https://n8n.openfoodnetwork.org.uk/webhook/regen/assurance/classification?id=\"\n);\n\nif (regen_data[\"Documentation_permissions\"] == \"Publicly available\" && regen_data[\"Attachments\"]) {\n  public_data[\"ofn:attachment_url\"] = regen_data[\"Attachments\"][0].url\n}\n\npublic_data[\"@type\"] = \"ofn:\" + public_data[\"ofn:Type\"].replaceAll(\" \", \"_\");\ndelete public_data[\"ofn:Type\"];\n\npublic_data[\"@id\"] = \"https://n8n.openfoodnetwork.org.uk/webhook/regen/assurance?id=\" + record_id;\npublic_data[\"@context\"] = \"https://discover.openfoodnetwork.org.au/context.json\";\n\nreturn public_data;"
      },
      "id": "28585497-85aa-4f15-b49c-ba11a083c5c1",
      "name": "Regen data",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        800,
        260
      ]
    },
    {
      "parameters": {
        "path": "regen/assurance/classification",
        "responseMode": "responseNode",
        "options": {
          "ignoreBots": false
        }
      },
      "id": "084ace3f-c4e0-483f-b35c-1b120f57509d",
      "name": "Show Classification",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        320,
        600
      ],
      "webhookId": "1f2b1197-179c-4c15-b710-9ae3163c8b73"
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={\n  \"@context\": \"https://discover.openfoodnetwork.org.au/context.json\",\n  \"@id\": \"https://n8n.openfoodnetwork.org.uk/webhook/regen/assurance/classification?id={{ encodeURI($json.query.id) }}\",\n  \"@type\": \"http://www.w3.org/2004/02/skos/core#Concept\",\n  \"ofn:label\": \"{{ $json.query.id }}\"\n}\n",
        "options": {}
      },
      "id": "0f37e4aa-c141-4581-b078-03189998c196",
      "name": "Respond with Classification",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        560,
        600
      ]
    },
    {
      "parameters": {
        "path": "regen/assurance/classifications",
        "responseMode": "responseNode",
        "options": {
          "ignoreBots": false
        }
      },
      "id": "59e65f0f-9e39-4650-8e0a-85b655e84201",
      "name": "List Classifications",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        320,
        440
      ],
      "webhookId": "b8cebd65-62a4-4e23-b0df-a339a22d95d8"
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify($json[\"ofn:Classification\"]) }}",
        "options": {}
      },
      "id": "b60df1f2-ebd5-47d6-90b4-1000360fb413",
      "name": "Respond to Classifications",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1100,
        440
      ]
    },
    {
      "parameters": {
        "path": "regen/supporting_evidence_classifications",
        "responseMode": "responseNode",
        "options": {
          "ignoreBots": false
        }
      },
      "id": "dcadbb20-0890-481c-ab47-659a12e8da81",
      "name": "List Classification options",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        320,
        760
      ],
      "webhookId": "d75c3d62-95a8-47b4-bdf8-702d37fded13"
    },
    {
      "parameters": {
        "authentication": "airtableTokenApi",
        "operation": "list",
        "application": {
          "__rl": true,
          "value": "https://airtable.com/appYTxkFLvN3W4J6C/tbl8IMjaEt5SW6VPd/viwxzaIKeZOtzOtnl?blocks=hide",
          "mode": "url",
          "__regex": "https://airtable.com/([a-zA-Z0-9]{2,})"
        },
        "table": {
          "__rl": true,
          "value": "https://airtable.com/appYTxkFLvN3W4J6C/tbl8IMjaEt5SW6VPd/viwxzaIKeZOtzOtnl?blocks=hide",
          "mode": "url",
          "__regex": "https://airtable.com/[a-zA-Z0-9]{2,}/([a-zA-Z0-9]{2,})"
        },
        "additionalOptions": {
          "fields": [
            "Classification"
          ],
          "view": "viwxzaIKeZOtzOtnl"
        }
      },
      "id": "dcb3242d-6915-40bf-b7d0-e29bbbe6515c",
      "name": "Supporting Evidence",
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 1,
      "position": [
        560,
        760
      ],
      "credentials": {
        "airtableTokenApi": {
          "id": "TXqyAKUNoMiPowTA",
          "name": "Maikel's Airtable token for Regen"
        }
      }
    },
    {
      "parameters": {
        "fieldToSplitOut": "fields.Classification",
        "options": {}
      },
      "id": "8327a429-961f-4d0b-8a75-2bbbc8676f0c",
      "name": "Item Lists",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 2.2,
      "position": [
        760,
        760
      ]
    },
    {
      "parameters": {
        "operation": "sort",
        "sortFieldsUi": {
          "sortField": [
            {
              "fieldName": "other"
            },
            {
              "fieldName": "['fields.Classification']"
            }
          ]
        },
        "options": {}
      },
      "id": "f5e41be0-8af8-403b-84e4-47d0fe9d5135",
      "name": "Item Lists1",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 2.2,
      "position": [
        1100,
        760
      ]
    },
    {
      "parameters": {
        "operation": "removeDuplicates"
      },
      "id": "73e63797-c32f-45c2-ba8b-c4d4e086ba7e",
      "name": "Item Lists2",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 2.2,
      "position": [
        1260,
        760
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "var classification = $json[\"fields.Classification\"];\n\n$json.category = {\n  \"@id\":\"https://n8n.openfoodnetwork.org.uk/webhook/regen/assurance/classification?id=\" + encodeURI(classification),\n  \"@type\": \"http://www.w3.org/2004/02/skos/core#Concept\",\n  \"ofn:label\": classification\n}\n\n\nreturn $input.item;"
      },
      "id": "3e02b854-3808-48af-aef7-b39a1aeac088",
      "name": "Code1",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        1420,
        760
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify(\n{\n  \"@context\": \"https://api.regenerative.org.au/context.json\",\n  \"@id\": \"https://n8n.openfoodnetwork.org.uk/webhook/regen/supporting_evidence_classifications\",\n  \"@type\": \"ldp:Container\",\n  \"ldp:contains\": $json.categories\n}\n) }}",
        "options": {}
      },
      "id": "9ea031df-19d8-4af5-a10e-d3b14ff5cc13",
      "name": "Respond with categories",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1760,
        760
      ]
    },
    {
      "parameters": {
        "operation": "aggregateItems",
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "category",
              "renameField": true,
              "outputFieldName": "categories"
            }
          ]
        },
        "options": {}
      },
      "id": "5209e0db-a1d6-4695-b069-e522d0a39163",
      "name": "Item Lists3",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 2.2,
      "position": [
        1580,
        760
      ]
    },
    {
      "parameters": {
        "values": {
          "boolean": [
            {
              "name": "other",
              "value": "={{ $json['fields.Classification'] == \"Other\" }}"
            }
          ]
        },
        "options": {}
      },
      "id": "f8810e23-e55e-4990-9ad3-2a91c5fefe26",
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        940,
        760
      ]
    },
    {
      "parameters": {
        "authentication": "airtableTokenApi",
        "application": {
          "__rl": true,
          "value": "https://airtable.com/appYTxkFLvN3W4J6C/tbl8IMjaEt5SW6VPd/viwsIpEmVpAxZBWew?blocks=hide",
          "mode": "url",
          "__regex": "https://airtable.com/([a-zA-Z0-9]{2,})"
        },
        "table": {
          "__rl": true,
          "value": "https://airtable.com/appYTxkFLvN3W4J6C/tbl8IMjaEt5SW6VPd/viwsIpEmVpAxZBWew?blocks=hide",
          "mode": "url",
          "__regex": "https://airtable.com/[a-zA-Z0-9]{2,}/([a-zA-Z0-9]{2,})"
        },
        "id": "={{ $json.query.id }}\n"
      },
      "id": "13180fdf-b8d0-46cf-9297-139401b8087c",
      "name": "Airtable1",
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 1,
      "position": [
        560,
        440
      ],
      "credentials": {
        "airtableTokenApi": {
          "id": "TXqyAKUNoMiPowTA",
          "name": "Maikel's Airtable token for Regen"
        }
      }
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "function ldpContainerize(object, key, container_id, prefix) {\n  var ids = object[key];\n\n  if (ids === undefined) { return undefined; };\n  \n  var list = ids.map((id) => ({\"@id\": prefix + encodeURI(id)}));\n\n  object[key] = {\n    \"@id\": container_id,\n    \"@type\": \"ldp:Container\",\n    \"ldp:contains\": list\n  };\n}\n\nvar record_id = $json.id;\nvar regen_data = $json.fields;\nvar public_fields = [\n  \"Type\",\n  \"Creation date\",\n  \"Title\",\n  \"Certification ID\",\n  \"Certification status\",\n  \"Classification\",\n  \"Description\",\n  \"Link\",\n  \"Service provider\",\n  \"Expiry date\",  \"Documentation permissions\",\n  \"Assurance partner\",\n]\nvar public_data = public_fields.reduce(\n  (result, field) => {\n    var key = \"ofn:\" + field.replaceAll(\" \", \"_\");\n    result[key] = regen_data[field];\n    return result;\n  },\n  {}\n);\n\npublic_data[\"ofn:service_provider_label\"] = (regen_data[\"Service provider name\"] ?? [])[0];\npublic_data[\"ofn:service_provider_uri\"] = (regen_data[\"Service provider website\"] ?? [])[0];\n\nif (regen_data[\"Attachments\"] && regen_data[\"Attachments\"].length > 0) {\n  public_data[\"ofn:attachment_uri\"] = regen_data[\"Attachments\"][0].url;\n}\n\n\npublic_data[\"ofn:hasCertificationStatus\"] = {\n  \"@id\": \"https://n8n.openfoodnetwork.org.uk/webhook/regen/certification?id=\" + encodeURI(regen_data[\"Certification status\"])\n};\n\nldpContainerize(\n  public_data, \"ofn:Assurance_partner\",\n  \"https://n8n.openfoodnetwork.org.uk/webhook/regen/groups?id=\" + record_id,\n  \"https://n8n.openfoodnetwork.org.uk/webhook/regen/group?id=\"\n);\n\nldpContainerize(\n  public_data, \"ofn:Classification\",\n  \"https://n8n.openfoodnetwork.org.uk/webhook/regen/assurance/classifications?id=\" + record_id,\n  \"https://n8n.openfoodnetwork.org.uk/webhook/regen/assurance/classification?id=\"\n);\n\nif (regen_data[\"Documentation_permissions\"] == \"Publicly available\" && regen_data[\"Attachments\"]) {\n  public_data[\"ofn:attachment_url\"] = regen_data[\"Attachments\"][0].url\n}\n\npublic_data[\"@type\"] = \"ofn:\" + public_data[\"ofn:Type\"].replaceAll(\" \", \"_\");\ndelete public_data[\"ofn:Type\"];\n\npublic_data[\"@id\"] = \"https://n8n.openfoodnetwork.org.uk/webhook/regen/assurance?id=\" + record_id;\npublic_data[\"@context\"] = \"https://discover.openfoodnetwork.org.au/context.json\";\n\nreturn public_data;"
      },
      "id": "e3e38136-91f4-42ed-a75c-71a6dffea231",
      "name": "Regen data1",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        800,
        440
      ]
    }
  ],
  "pinData": {},
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Airtable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Airtable": {
      "main": [
        [
          {
            "node": "Regen data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Regen data": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Show Classification": {
      "main": [
        [
          {
            "node": "Respond with Classification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "List Classifications": {
      "main": [
        [
          {
            "node": "Airtable1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "List Classification options": {
      "main": [
        [
          {
            "node": "Supporting Evidence",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Supporting Evidence": {
      "main": [
        [
          {
            "node": "Item Lists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Item Lists": {
      "main": [
        [
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Item Lists1": {
      "main": [
        [
          {
            "node": "Item Lists2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Item Lists2": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Item Lists3": {
      "main": [
        [
          {
            "node": "Respond with categories",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code1": {
      "main": [
        [
          {
            "node": "Item Lists3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set": {
      "main": [
        [
          {
            "node": "Item Lists1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Airtable1": {
      "main": [
        [
          {
            "node": "Regen data1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Regen data1": {
      "main": [
        [
          {
            "node": "Respond to Classifications",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {},
  "versionId": "0beac53f-2fd2-4077-9b14-0aa0f344dd08",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "28870f2868c6821b7375131334e38ef8f27782bd5b2dd7efd016a3383f12b722"
  },
  "id": "ScVPVTAV1sYauZdX",
  "tags": []
}
{
  "name": "Show group",
  "nodes": [
    {
      "parameters": {
        "path": "regen/group",
        "responseMode": "responseNode",
        "options": {
          "ignoreBots": false
        }
      },
      "id": "a06d8e46-0077-4d5e-94b2-4116d2b4fc39",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        320,
        260
      ],
      "webhookId": "5c2e652c-340e-4ad8-9451-d84502af4604"
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "f667b48b-2f11-4c7c-8ba7-6e123f0a73e5",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        820,
        260
      ]
    },
    {
      "parameters": {
        "authentication": "airtableTokenApi",
        "application": {
          "__rl": true,
          "value": "https://airtable.com/appYTxkFLvN3W4J6C/tblfKbu0lB05jnsNC/viwNzPApKwG0Bm0xP?blocks=hide",
          "mode": "url",
          "__regex": "https://airtable.com/([a-zA-Z0-9]{2,})"
        },
        "table": {
          "__rl": true,
          "value": "https://airtable.com/appYTxkFLvN3W4J6C/tblfKbu0lB05jnsNC/viwNzPApKwG0Bm0xP?blocks=hide",
          "mode": "url",
          "__regex": "https://airtable.com/[a-zA-Z0-9]{2,}/([a-zA-Z0-9]{2,})"
        },
        "id": "={{ $json.query.id }}\n"
      },
      "id": "b9af25b4-821e-400d-b514-1fcd5ea1a32a",
      "name": "Airtable",
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 1,
      "position": [
        460,
        260
      ],
      "credentials": {
        "airtableTokenApi": {
          "id": "TXqyAKUNoMiPowTA",
          "name": "Maikel's Airtable token for Regen"
        }
      }
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "function ldpContainerize(object, key, container_id, prefix) {\n  var ids = object[key];\n  var list = object[key].map((id) => ({\"@id\": prefix + id}));\n  object[key] = {\n    \"@id\": container_id,\n    \"@type\": \"ldp:Container\",\n    \"ldp:contains\": list\n  };\n}\n\nvar record_id = $json.id;\nvar regen_data = $json.fields;\nvar public_fields = [\n  \"Group name\",\n  \"Logo URL\",\n]\nvar public_data = public_fields.reduce(\n  (result, field) => {\n    var key = \"ofn:\" + field.replaceAll(\" \", \"_\");\n    result[key] = regen_data[field];\n    return result;\n  },\n  {}\n);\n\n/*\nldpContainerize(\n  public_data, \"ofn:Assurance_partner\",\n  \"https://n8n.openfoodnetwork.org.uk/webhook/regen/assurance_partners?id=\" + record_id,\n  \"https://n8n.openfoodnetwork.org.uk/webhook/regen/assurance_partner?id=\"\n);\n*/\n\npublic_data[\"@type\"] = \"dfc-b:Enterprise\";\npublic_data[\"@id\"] = \"https://n8n.openfoodnetwork.org.uk/webhook/regen/group?id=\" + record_id;\npublic_data[\"@context\"] = \"https://discover.openfoodnetwork.org.au/context.json\";\n\nreturn public_data;"
      },
      "id": "86fea97a-11ad-47ec-8d1a-103fb4e3b8f2",
      "name": "Regen data",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        640,
        260
      ]
    }
  ],
  "pinData": {},
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Airtable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Airtable": {
      "main": [
        [
          {
            "node": "Regen data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Regen data": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {},
  "versionId": "a1dd8592-1082-4d25-af95-4ab81255b86f",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "28870f2868c6821b7375131334e38ef8f27782bd5b2dd7efd016a3383f12b722"
  },
  "id": "a3YShLhyLk8gdbAm",
  "tags": []
}
{
  "name": "Show SocialMedia",
  "nodes": [
    {
      "parameters": {
        "path": "enterprises/:enterprise_id/social_medias/:social_media_id",
        "responseMode": "responseNode",
        "options": {
          "ignoreBots": false
        }
      },
      "id": "147af962-c2e2-49dd-974a-f0fcd0573c38",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        400,
        260
      ],
      "webhookId": "b9c3687f-9f0f-4628-9bcc-f3331afb6fa8"
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "a5ca7b41-eddc-43d1-bb9b-aae2dff7c441",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1260,
        260
      ]
    },
    {
      "parameters": {
        "url": "=https://openfoodnetwork.org.au/api/dfc/enterprises/{{ $json.fields.uid }}/social_medias/{{ $('Webhook').item.json.params.social_media_id }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {}
      },
      "id": "2c3f4757-a1d3-45ce-815f-61a5d11b2554",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        840,
        260
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "HtdqHbr4tczScLlN",
          "name": "OFN API Token from Airtable record"
        }
      }
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "function replaceURL(url, webhook) {\n  var source = \"https://openfoodnetwork.org.au/api/dfc\";\n  var endpoint = \"https://n8n.openfoodnetwork.org.uk/webhook/\" + webhook;\n  return url.replace(source, endpoint);\n}\n\nvar subject = item.json;\nsubject[\"@context\"] = \"https://discover.openfoodnetwork.org.au/context.json\";\nsubject[\"@id\"] = replaceURL(subject[\"@id\"], \"b9c3687f-9f0f-4628-9bcc-f3331afb6fa8\") + \"?id=\" + $('Webhook').item.json.query.id;;\n\nif (subject[\"dfc-b:name\"] == \"whatsapp_phone\") {\n  subject[\"dfc-b:URL\"] = subject[\"dfc-b:URL\"].replace(\"https://\", \"https://wa.me/\");\n}\n\nitem.json = subject;\nreturn item;"
      },
      "id": "dc270ad2-1bbb-4138-b260-ee296c355bb8",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        1060,
        260
      ]
    },
    {
      "parameters": {
        "authentication": "airtableTokenApi",
        "application": {
          "__rl": true,
          "value": "https://airtable.com/appYTxkFLvN3W4J6C/tblP4i5QIdYtmxrwN/viwmhktn3zlXoScG8",
          "mode": "url",
          "__regex": "https://airtable.com/([a-zA-Z0-9]{2,})"
        },
        "table": {
          "__rl": true,
          "value": "https://airtable.com/appYTxkFLvN3W4J6C/tblP4i5QIdYtmxrwN/viwD9cQqttDRfCM9y",
          "mode": "url",
          "__regex": "https://airtable.com/[a-zA-Z0-9]{2,}/([a-zA-Z0-9]{2,})"
        },
        "id": "={{ $json.query.id }}\n"
      },
      "id": "287b5bb7-04d9-416d-a8df-5f91b955a53f",
      "name": "Airtable",
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 1,
      "position": [
        640,
        260
      ],
      "credentials": {
        "airtableTokenApi": {
          "id": "TXqyAKUNoMiPowTA",
          "name": "Maikel's Airtable token for Regen"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Airtable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Airtable": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {},
  "versionId": "2763d1b8-7a9b-49d3-bea0-ea7b735f726f",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "28870f2868c6821b7375131334e38ef8f27782bd5b2dd7efd016a3383f12b722"
  },
  "id": "cBQt5vNVWdnZ5NJi",
  "tags": []
}