πŸ”§ Real-time public transport delay tracking with ScrapeGraphAI, Teams & Dropbox

⚑ 51 views Β· πŸ”§ Miscellaneous

πŸ’‘ Pro Tip β€” HTTP Request scraping tends to break when sites update their markup. If you’re scraping a major platform, check if ScraperNode covers it β€” it has maintained scrapers for LinkedIn, Instagram, TikTok, YouTube, and 20+ other platforms that return structured data.

View All Scrapers

Description

Public Transport Schedule & Delay Tracker with Microsoft Teams and Dropbox

Workflow Preview Image

⚠️ COMMUNITY TEMPLATE DISCLAIMER: This is a community-contributed template that uses ScrapeGraphAI (a community node). Please ensure you have the ScrapeGraphAI community node installed in your n8n instance before using this template.

This workflow automatically scrapes public transport websites or apps for real-time schedules and service alerts, then pushes concise delay notifications to Microsoft Teams while archiving full-detail JSON snapshots in Dropbox. Ideal for commuters and travel coordinators, it keeps riders informed and maintains a historical log of disruptions.

Pre-conditions/Requirements

Prerequisites

Required Credentials

Specific Setup Requirements

ItemExampleNotes
Transit URL(s)https://mycitytransit.com/line/42Must return the schedule or service alert data you need
Polling Interval5 minAdjust via Cron node or external trigger
Teams Channel#commuter-updatesCreate an incoming webhook in channel settings

How it works

This workflow automatically scrapes public transport websites or apps for real-time schedules and service alerts, then pushes concise delay notifications to Microsoft Teams while archiving full-detail JSON snapshots in Dropbox. Ideal for commuters and travel coordinators, it keeps riders informed and maintains a historical log of disruptions.

Key Steps:

Set up steps

Setup Time: 15-25 minutes

  1. Clone or Import the JSON workflow into your n8n instance.
  2. Install ScrapeGraphAI community node if you haven’t already (Settings β†’ Community Nodes).
  3. Open the Set node and enter your target routes or API endpoints (array of URLs/IDs).
  4. Configure ScrapeGraphAI:
    • Add your API key in the node’s credentials section.
    • Define CSS selectors or API fields inside the node parameters.
  5. Add Microsoft Teams credentials:
    • Paste your channel’s incoming webhook URL into the Microsoft Teams node.
    • Customize the message template (e.g., include route name, delay minutes, reason).
  6. Add Dropbox credentials:
    • Provide the access token and designate a folder path (e.g., /TransitLogs/).
  7. Customize the If node logic to match your delay threshold (e.g., β‰₯5 min).
  8. Activate the workflow and trigger via the webhook URL, or add a Cron node (every 5 min).

Node Descriptions

Core Workflow Nodes:

Data Flow:

  1. Webhook β†’ Set β†’ SplitInBatches β†’ ScrapeGraphAI β†’ Code (Normalize) β†’ If (Delay Detected?)
    β”œβ”€ true β†’ Merge β†’ Microsoft Teams β†’ Dropbox
    └─ false β†’ Dropbox

Customization Examples

Change to Slack instead of Teams

// Replace Microsoft Teams node with Slack node
{
  "text": `🚊 *${$json.route}* is delayed by *${$json.delay}* minutes.`,
  "channel": "#commuter-updates"
}

Filter only major delays (>10 min)

// In If node, use:
return $json.delay >= 10;

Data Output Format

The workflow outputs structured JSON data:

{
  "route": "Line 42",
  "expected_departure": "2024-04-22T14:05:00Z",
  "actual_departure": "2024-04-22T14:17:00Z",
  "delay": 12,
  "status": "delayed",
  "reason": "Signal failure at Main Station",
  "scraped_at": "2024-04-22T13:58:22Z",
  "source_url": "https://mycitytransit.com/line/42"
}

Troubleshooting

Common Issues

  1. ScrapeGraphAI returns empty data – Verify CSS selectors/API fields match the current website markup; update selectors after site redesigns.
  2. Teams messages not arriving – Ensure the Teams webhook URL is correct and the incoming webhook is still enabled.
  3. Dropbox writes fail – Check folder path, token scopes (files.content.write), and available storage quota.

Performance Tips

Pro Tips:

πŸ”— Nodes Used

Dropbox, Webhook, Microsoft Teams

πŸ“₯ Import

Download workflow.json and import into n8n: Workflow menu β†’ Import from File

πŸ“– Importing guide Β· πŸ”‘ Credential setup