{
  "id": "0OWspWtwG0zZzenm",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Register Event Monitoring for German Companies",
  "tags": [],
  "nodes": [
    {
      "id": "f782dd23-b72f-408a-8f91-a7f69ab3c07c",
      "name": "Split Batches",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -3264,
        -272
      ],
      "parameters": {
        "options": {},
        "batchSize": 5
      },
      "typeVersion": 3
    },
    {
      "id": "57631bfb-376b-44ae-a06b-7b2687d8d549",
      "name": "Rate Limit",
      "type": "n8n-nodes-base.wait",
      "position": [
        -3040,
        -464
      ],
      "parameters": {
        "amount": 2
      },
      "typeVersion": 1.1
    },
    {
      "id": "e542b1db-474e-49b5-9a93-2b0e9215df93",
      "name": "API Success?",
      "type": "n8n-nodes-base.if",
      "position": [
        -2368,
        -464
      ],
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{ $json.statusCode }}",
              "value2": 200,
              "operation": "equal"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6e2410bc-92cd-4ba6-9d1b-1f39de1e9ecd",
      "name": "Normalize Events",
      "type": "n8n-nodes-base.code",
      "position": [
        -2144,
        -560
      ],
      "parameters": {
        "jsCode": "// Normalize events\nconst response = $input.item.json;\nconst companyId = $input.item.json.company_id;\nconst companyName = $input.item.json.company_name;\nconst workflowRunId = $input.item.json.workflow_run_id;\n\nconst eventsData = response.body || {};\nconst events = eventsData.events || [];\n\nif (events.length === 0) {\n  return [];\n}\n\nreturn events.map((event, idx) => ({\n  json: {\n    event_idx: idx,\n    company_id: companyId,\n    company_name: companyName,\n    event_type: event.type || 'unknown',\n    event_category: (event.category && event.category.code) || event.category || null,\n    event_title: event.title || '',\n    event_text: event.text || '',\n    event_timestamp: event.timestamp || new Date().toISOString(),\n    event_source: event.source || null,\n    workflow_run_id: workflowRunId,\n    fetched_at: new Date().toISOString()\n  }\n}));"
      },
      "typeVersion": 2
    },
    {
      "id": "892359b9-f772-492c-8822-021d409a5d7f",
      "name": "Log API Error",
      "type": "n8n-nodes-base.code",
      "position": [
        -2144,
        -368
      ],
      "parameters": {
        "jsCode": "// Log error\nconst error = $input.item.json.error || 'Unknown error';\nconst statusCode = $input.item.json.statusCode || 0;\n\nconsole.error('API failed: ' + error);\n\nreturn {\n  json: {\n    company_id: $input.item.json.company_id,\n    company_name: $input.item.json.company_name,\n    error_type: 'api_failed',\n    error_message: error,\n    status_code: statusCode\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "efe920d7-e0b3-48ec-bdb3-37b0b79d969c",
      "name": "Merge Results",
      "type": "n8n-nodes-base.merge",
      "position": [
        -1920,
        -464
      ],
      "parameters": {
        "mode": "combine",
        "options": {
          "includeUnpaired": true
        },
        "combinationMode": "mergeByPosition"
      },
      "typeVersion": 2.1
    },
    {
      "id": "d9076eab-ec7f-4307-892a-069b9bd0c477",
      "name": "Filter Relevant",
      "type": "n8n-nodes-base.if",
      "position": [
        -1696,
        -464
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.event_category }}",
              "operation": "isNotEmpty"
            },
            {
              "value1": "={{ $json.event_category }}",
              "value2": "MANAGEMENT_AND_TEAM|FINANCES_AND_CAPITAL|MERGERS_AND_ACQUISITIONS|BANKRUPTCY|INSOLVENCY|EXPANSION|RELOCATION",
              "operation": "regex"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d602e036-7e95-43fa-b3e8-ede5998820f1",
      "name": "Deduplicate",
      "type": "n8n-nodes-base.removeDuplicates",
      "position": [
        -1456,
        -480
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "7a3ba5fa-770a-4274-983a-9461cdb6f357",
      "name": "Prepare Notification",
      "type": "n8n-nodes-base.code",
      "position": [
        -2368,
        0
      ],
      "parameters": {
        "jsCode": "// Prepare notification\nconst event = $input.item.json;\n\nfunction getUrgency(category) {\n  if (['BANKRUPTCY', 'INSOLVENCY', 'MERGERS_AND_ACQUISITIONS'].includes(category)) return 'HIGH';\n  if (['MANAGEMENT_AND_TEAM', 'FINANCES_AND_CAPITAL'].includes(category)) return 'MEDIUM';\n  return 'LOW';\n}\n\nconst eventDate = new Date(event.event_timestamp);\nconst ageHours = Math.floor((Date.now() - eventDate.getTime()) / (1000 * 60 * 60));\nconst urgency = getUrgency(event.event_category);\n\nconst message = urgency + ' Priority Event\\n\\n' +\n  'Company: ' + event.company_name + ' (' + event.company_id + ')\\n' +\n  'Category: ' + event.event_category + '\\n' +\n  'Title: ' + event.event_title + '\\n' +\n  'Time: ' + event.event_timestamp + ' (' + ageHours + 'h ago)\\n' +\n  'Source: ' + (event.event_source || 'N/A') + '\\n\\n' +\n  (event.event_text || 'No description');\n\nreturn {\n  json: {\n    company_name: event.company_name,\n    company_id: event.company_id,\n    event_title: event.event_title,\n    event_category: event.event_category,\n    event_timestamp: event.event_timestamp,\n    urgency: urgency,\n    event_age_hours: ageHours,\n    formatted_message: message,\n    workflow_run_id: event.workflow_run_id\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "183f1f4e-4105-4f1c-8b3c-6953d8fc7d6a",
      "name": "Notification Sent?",
      "type": "n8n-nodes-base.if",
      "disabled": true,
      "position": [
        -1936,
        0
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.error }}",
              "operation": "isEmpty"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2254cf19-80ed-4a5c-ac49-8c8abd368d66",
      "name": "Log Success",
      "type": "n8n-nodes-base.code",
      "position": [
        -1696,
        -96
      ],
      "parameters": {
        "jsCode": "console.log('Sent: ' + $input.item.json.company_name + ' - ' + $input.item.json.event_title);\nreturn { json: { ...$input.item.json, status: 'sent' } };"
      },
      "typeVersion": 2
    },
    {
      "id": "0dd1eeaa-fed6-4b80-85e4-8ca359532b3f",
      "name": "Log Failed",
      "type": "n8n-nodes-base.code",
      "position": [
        -1696,
        96
      ],
      "parameters": {
        "jsCode": "console.error('Failed: ' + ($input.item.json.error || 'Unknown'));\nreturn { json: { ...$input.item.json, status: 'failed' } };"
      },
      "typeVersion": 2
    },
    {
      "id": "d1b66b39-5b7c-4a4d-bf07-397dcb3235e8",
      "name": "Merge Notifications",
      "type": "n8n-nodes-base.merge",
      "position": [
        -1472,
        0
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combinationMode": "mergeByPosition"
      },
      "typeVersion": 2.1
    },
    {
      "id": "48ea187a-1b85-425d-b0bf-091860fee503",
      "name": "Loop Continue",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -1248,
        160
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "9f60fdfc-9236-4de2-9be8-2f5a8d62fc85",
      "name": "Create Summary",
      "type": "n8n-nodes-base.code",
      "position": [
        -3040,
        -288
      ],
      "parameters": {
        "jsCode": "// Create summary\nconst items = $input.all();\nconst total = items.length;\nconst sent = items.filter(i => i.json.status === 'sent').length;\nconst failed = total - sent;\n$('Config').first().json.workflow_run_id\nconst summary = {\n  workflow_run_id: $('Config').first().json.workflow_run_id || 'unknown',\n  total_events: total,\n  notifications_sent: sent,\n  notifications_failed: failed,\n  success_rate: total > 0 ? Math.round((sent / total) * 100) : 0,\n  executed_at: new Date().toISOString()\n};\n\nconsole.log('Summary: ' + sent + '/' + total + ' sent');\n\nreturn { json: summary };"
      },
      "typeVersion": 2
    },
    {
      "id": "cee92dae-80b4-4714-9133-7d4600f52d60",
      "name": "Lookup Company",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -2816,
        -464
      ],
      "parameters": {
        "url": "https://german-company-data.p.rapidapi.com/lookup",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendQuery": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "active",
              "value": "true"
            },
            {
              "name": "name",
              "value": "={{ $json.companyName }}"
            },
            {
              "name": "url",
              "value": "={{ $json.domain }}"
            }
          ]
        },
        "queryParameters": {
          "parameters": [
            {
              "name": "size",
              "value": "10"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            },
            {
              "name": "x-rapidapi-host",
              "value": "german-company-data.p.rapidapi.com"
            },
            {
              "name": "x-rapidapi-key",
              "value": "={{ $('Config').item.json['x-rapidapi-key'] }}"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "d5735302-2d19-42f4-8c8e-1c9b4fa6afde",
      "name": "Get Events",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -2592,
        -464
      ],
      "parameters": {
        "url": "=https://german-company-data.p.rapidapi.com/companies/{{ $json.companies[0].id }}/events",
        "options": {
          "response": {
            "response": {
              "fullResponse": true
            }
          }
        },
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "category",
              "value": "MANAGEMENT_AND_TEAM,FINANCES_AND_CAPITAL,NEWS_AND_EVENTS"
            },
            {
              "name": "since",
              "value": "2017-01-01"
            },
            {
              "name": "size",
              "value": "100"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "x-rapidapi-host",
              "value": "german-company-data.p.rapidapi.com"
            },
            {
              "name": "x-rapidapi-key",
              "value": "={{ $('Config').item.json['x-rapidapi-key'] }}"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "ca4dc5de-85ee-4bc0-97dd-c8e5a93353cf",
      "name": "Config",
      "type": "n8n-nodes-base.set",
      "position": [
        -3712,
        -272
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "x-rapidapi-key",
              "value": "XXXX"
            },
            {
              "name": "workflow_run_id",
              "value": "={{ $execution.id }}"
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 2
    },
    {
      "id": "2c98b0eb-48e1-4cc2-9cae-9b4c5407d53b",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -3936,
        -272
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "02ec6652-2cc1-49bb-ba4a-41111b76776d",
      "name": "\ud83c\udfd7\ufe0f Architecture Notes",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -4560,
        -544
      ],
      "parameters": {
        "width": 512,
        "height": 816,
        "content": "# B2B Register Event Monitoring for German Companies\n\nThis n8n workflow monitors significant register, financial, and news-related events for German companies. It takes a list of companies (for example from a CRM or lead list), resolves them via the Implisense / German Company Data API, retrieves recent company events, normalizes and filters them by relevance (e.g. management changes, financing, M&A, insolvency), deduplicates results, and prepares structured notifications with urgency levels. The output can be routed to email, chat tools, webhooks, or downstream systems such as CRMs or data stores for continuous company monitoring and alerting.\n\n## Setup steps\n\n1. **Replace Mock Data**: Change \"Mock Lead Input\" node to your actual lead source\n   - CRM connector (Salesforce, HubSpot, etc.)\n   - Database query\n   - CSV import\n\n2. **Configure Credentials**: Set up RapidAPI API credentials\n   - Create an account on RapidAPI  (free tier available)\n    - [RapidAPI](https://rapidapi.com/Implisense/api/German%20Company%20Data)\n   - Insert your RapidAPI x-rapidapi-key as password\n\n3. **Adjust Notification**: Configure your peferred Notification system if needed\n\n4. **Connect Output**: Add nodes after the 'Create Summary' node"
      },
      "typeVersion": 1
    },
    {
      "id": "024f7582-ffa3-469b-a618-b9edcab46bfc",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -4000,
        -336
      ],
      "parameters": {
        "color": 7,
        "width": 672,
        "height": 256,
        "content": "## Init\n"
      },
      "typeVersion": 1
    },
    {
      "id": "948ff050-ffc3-4bdf-96f9-66c0fc3ceef5",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3072,
        -544
      ],
      "parameters": {
        "color": 7,
        "width": 672,
        "height": 240,
        "content": "## Lookup & Data\n"
      },
      "typeVersion": 1
    },
    {
      "id": "e052fedc-90a2-45f1-a023-43c7f202c113",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2448,
        -144
      ],
      "parameters": {
        "color": 7,
        "width": 1136,
        "height": 384,
        "content": "## Optional Send Notification\n"
      },
      "typeVersion": 1
    },
    {
      "id": "03946203-4efb-43a3-be1e-5c75fd35251d",
      "name": "Mock Lead Input",
      "type": "n8n-nodes-base.function",
      "position": [
        -3520,
        -272
      ],
      "parameters": {
        "functionCode": "// Mock lead data for testing\n// Replace this node with your actual lead source (CRM, Webhook, CSV, etc.)\nreturn [\n  {\n    json: {\n      leadId: \"L-12345\",\n      companyName: \"Implisense \",\n      domain: \"www.implisense.com\",\n      city: \"Berlin\",\n      zip: \"10115\"\n    }\n  }\n];"
      },
      "typeVersion": 1
    },
    {
      "id": "b08cb7a9-a629-427e-9f78-218398e8fea4",
      "name": "Email, Chat, Webhook etc.",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -2160,
        0
      ],
      "parameters": {},
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "07c2a3ac-86cf-4eff-93f0-5399f65d50b7",
  "connections": {
    "Config": {
      "main": [
        [
          {
            "node": "Mock Lead Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Events": {
      "main": [
        [
          {
            "node": "API Success?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Failed": {
      "main": [
        [
          {
            "node": "Merge Notifications",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Rate Limit": {
      "main": [
        [
          {
            "node": "Lookup Company",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Deduplicate": {
      "main": [
        [
          {
            "node": "Prepare Notification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Success": {
      "main": [
        [
          {
            "node": "Merge Notifications",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "API Success?": {
      "main": [
        [
          {
            "node": "Normalize Events",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Log API Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log API Error": {
      "main": [
        [
          {
            "node": "Merge Results",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Loop Continue": {
      "main": [
        [
          {
            "node": "Split Batches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Results": {
      "main": [
        [
          {
            "node": "Filter Relevant",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Batches": {
      "main": [
        [
          {
            "node": "Create Summary",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Rate Limit",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Lookup Company": {
      "main": [
        [
          {
            "node": "Get Events",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Relevant": {
      "main": [
        [
          {
            "node": "Deduplicate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mock Lead Input": {
      "main": [
        [
          {
            "node": "Split Batches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Events": {
      "main": [
        [
          {
            "node": "Merge Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notification Sent?": {
      "main": [
        [
          {
            "node": "Log Success",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Log Failed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Notifications": {
      "main": [
        [
          {
            "node": "Loop Continue",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Notification": {
      "main": [
        [
          {
            "node": "Email, Chat, Webhook etc.",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email, Chat, Webhook etc.": {
      "main": [
        [
          {
            "node": "Notification Sent?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}