Source: https://eventregistry.org/documentation?tab=n8n_news_alert_system

# Example 2: News Alert System Workflow

This workflow monitors Event Registry for recent events and sends formatted alerts using the **minuteStreamEvents** endpoint. Runs automatically every 5 minutes to provide near real-time monitoring. The endpoint tracks both new events and updates to existing events, making it ideal for real-time activity tracking.

## Workflow Steps

1. **Schedule Trigger** - Runs every 5 minutes
2. **HTTP Request** - Fetches recent events from Event Registry using minuteStreamEvents endpoint
3. **IF** - Checks if events were returned
4. **Set** - Converts `eventInfo` object to array
5. **Split Out** - Processes each event individually
6. **Edit Fields** - Extracts and formats event data
7. **HTML** - Formats alert as HTML (optional)
8. **Email** - Sends notification

## Step-by-Step Node Configuration

**1. Schedule Trigger Node:**

1. Add a **Schedule Trigger** node from the trigger nodes
2. Configure the following:
3. **Trigger Times:** Select `Every Minute` or `Custom Cron`
4. For `Every Minute`: Set **Every X Minutes:** to `5`
5. For `Custom Cron`: Enter `*/5 * * * *` (runs every 5 minutes)
6. Click "**Back to canvas**" in the upper left corner

**2. HTTP Request Node:**

1. Add an **HTTP Request** node after the Schedule Trigger
2. Configure the following settings:
3. **Method:** Select `POST` from the dropdown
4. **URL:** Enter `https://eventregistry.org/api/v1/minuteStreamEvents`
5. **Authentication:** Select `Generic Credential Type`
6. **Credential Type:** Select `Custom Auth`
7. **Credential for Custom Auth:** Select your `Event Registry API` credential
8. **Send Body:** Check the box
9. **Body Content Type:** Select `JSON`
10. **Specify Body:** Specify body using JSON
11. **Body:** Enter the following request body JSON:

  ```

              {
    "lang": "eng",
    "recentActivityEventsMaxEventCount": 50,
    "recentActivityEventsUpdatesAfterMinsAgo": 5
  }
  ```
12. **Note:** For detailed filtering options and available parameters, see the [Stream of events](/documentation?tab=feedOfEvents) endpoint documentation (keywords, categories, locations, language, etc.).
13. Click "**Back to canvas**" in the upper left corner

**3. IF Node:**

1. Add an **IF** node after the HTTP Request node
2. Configure the condition to check if events were returned:
3. **Condition:** Select `Number`
4. **Value 1:** Enter expression `{{ $json.recentActivityEvents?.events?.length || 0 }}`
5. **Operation:** Select `is greater than`
6. **Value 2:** Enter `0`
7. **Note:** The API returns events in `recentActivityEvents.eventInfo` object (URI → event mapping). This condition ensures the workflow only continues if events exist.
8. Click "**Back to canvas**" in the upper left corner

**4. Edit Fields Node:**

1. Connect into the `true` output of the IF node
2. Click **Add Value** and configure the following:
3. **Field Name:**`eventsArray`, **Value:**`{{ Object.values($json.recentActivityEvents.eventInfo || {}) }}`
4. Click "**Back to canvas**" in the upper left corner

**5. Split Out Node:**

1. Add a **Split Out** node after the Set node
2. Configure the following:
3. **Fields to Split Out:** Enter `eventsArray`
4. **Include:** Select `All Other Fields` to keep the original response data
5. **Note:** The `recentActivityEvents.events` array contains URIs of new events. You can distinguish between NEW and UPDATED events by checking if an event URI exists in this array (see Edit Fields node below).
6. Click "**Back to canvas**" in the upper left corner

**6. Edit Fields Node:**

1. Add an **Edit Fields** node after the Split Out node
2. Click **Add Value** for each field you want to extract:
3. **Field Name:**`title`, **Value:**`{{ !!$json?.title?.eng ? $json.title.eng : Object.values($json.title)[0] }}`
4. **Field Name:**`summary`, **Value:**`{{ $json.summary?.eng || $json.summary || 'No summary available' }}`
5. **Field Name:**`articleCount`, **Value:**`{{ $json.totalArticleCount || $json.articleCounts?.total || 0 }}`
6. **Field Name:**`alertLevel`, **Value:**`{{ ($json.totalArticleCount || $json.articleCounts?.total || 0) > 200 ? 'CRITICAL' : (($json.totalArticleCount || $json.articleCounts?.total || 0) > 50 ? 'HIGH' : 'MEDIUM') }}`
7. **Field Name:**`eventUri`, **Value:**`{{ $json.uri || '' }}`
8. Click "**Back to canvas**" in the upper left corner

**7. HTML Node:**

1. Add an **HTML** node after the Split Out node
2. Configure the following:
3. **Operation:** Select `Convert to HTML Table`
4. Click "**Back to canvas**" in the upper left corner

**8. Email Node:**

1. Add a **Gmail** or **Email** node after the HTML node
2. Configure based on your chosen node type:
  - **For Gmail node:**
    - **Operation:** Select `Send`
    - **To:** Enter recipient email address
    - **Subject:** Enter email subject, e.g., `Content Research Results`
    - **Email Type:** Select `HTML`
    - **Message:** Use expression `{{ $json.table }}` to reference HTML Table from previous node
  - **For Email node:**
    - If you haven't already, configure your email account credentials first
    - **Operation:** Select `Send`
    - **To Email:** Enter recipient email address
    - **Subject:** Enter email subject, e.g., `Content Research Results`
    - **Email Format:** Select `HTML`
    - **Message:** Use expression `{{ $json.table }}` to reference HTML Table from previous node
3. Click "**Back to canvas**" in the upper left corner

## Additional Resources

- For Schedule Trigger configuration, see [n8n Schedule Trigger documentation](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.schedule/)
- For notification setup, see [Email Node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.email/) or [Slack Node](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.slack/) documentation
- For Set node usage, see [Set Node documentation](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.set/)
