Selected work
Backend Tool · Node.jsNode.js 20+

bridge-lead-pooling

Hourly webhook poller that pools MogulBridge leads into daily CSVs and posts end-of-day summaries to Microsoft Teams.

Pulls webhook-request payloads from the MogulBridge admin API on a configurable cadence, accumulates leads per day scoped to one or more partners, and exports a CSV plus a summary adaptive card to Microsoft Teams at end of business.

Role — Solo developer
  • Node.js
  • JavaScript (ESM)
  • csv-stringify
  • node-cron
  • dotenv
  • Fetch API
  • Microsoft Teams
  • Windows Task Scheduler

bridge-lead-pooling is a production webhook poller that keeps a rolling daily pool of sales leads from MogulBridge. It runs collect cycles on any schedule you want (typically hourly), fetches new webhook requests since the last cursor, deduplicates by request ID, and appends only the leads from your configured partner list to that day's pool. At the end of the working day (configurable hour, defaults to 17:00 Pacific), it publishes: a CSV export written to disk and an adaptive card POST to a Microsoft Teams Power Automate webhook with totals, top campaigns/events, and a preview of the first 8 leads.

The core logic is split into commands. collect always fetches new records and updates the cursor; publish builds the CSV and notifies Teams; tick chains them safely for scheduled runs—always collects, publishes only once per local-zone day at/after PUBLISH_HOUR, and is safe to fire on any cadence. Windows Task Scheduler integration (install-task) walks you through registering a scheduled task with natural-language interval parsing ("every 2 hours", "1h30m", "5 times a day" all work). On Linux or macOS, a standard cron entry runs the same tick command.

The implementation handles timezone-aware day boundaries (IANA timezone string), stores state and pools as JSON files on disk to survive process restarts, and provides defensive partner filtering both server-side (API query param) and client-side (drops mismatched records with a warning). The adaptive card payload stays compact intentionally—Power Automate's card renderer hits size limits around 28 KB—so the full CSV is always saved locally; Teams just gets the summary and a path to where the file was written.

What's notable
  • Timezone-aware daily pooling: day boundaries defined by IANA timezone, safe to run on any schedule and publish exactly once per day
  • Flexible scheduling: command-line interface with Windows Task Scheduler helper (natural-language interval parsing) or Linux cron, plus in-process dev scheduler for testing
  • Robust cursor-based pagination: deduplicates by webhook request ID, tracks cursor (last_collected_at), stops early when crossing previously seen records
  • Compact adaptive card: defensive size control (stays under 28 KB) with totals, top 5 campaigns and events, first 8 leads, CSV metadata, full CSV saved to disk
  • 65-column normalized CSV: flattens nested webhook payloads (lead contact + demographics, venue + event details, campaign metadata) into a single clean export