Skip to main content

AI Brief: hbf-broadcast

A Node.js polling service that scans for pending broadcast campaigns and delivers mass messages across multiple messaging channels (Facebook Messenger, Microsoft Teams, Slack, Viber, Email). It operates as an always-running daemon with no inbound API surface beyond a health-check endpoint.

What This Repo Does

hbf-broadcast periodically polls hbf-core for broadcasts in PENDING, WAITING, or SENDING state. For each broadcast, it authenticates with the target channel, fetches the subscriber list, and delivers messages in configurable batches. It tracks per-subscriber delivery responses back in hbf-core, supporting retry and resumption across scan cycles.

Tech Stack

  • Language: JavaScript (Node.js, CommonJS)
  • Framework: Restify (HTTP server, health-check only)
  • Key dependencies: @helvia/hbf-core-api, elasticsearch, exceljs, json2csv, nodemailer, axios, pino, fast-sort, config

Entry Points

  • Main: bin/start.js (invoked by npm start)
  • App bootstrap: app.js (class App, instantiates server + starts scan loop)
  • Server: server.js (Restify HTTP server, no routes registered beyond builtins)
  • Config: config/default.yml (overrides via config/local.yml or env vars from config/custom-environment-variables.yml)

Key Directories

DirectoryPurpose
channels/One file per messaging platform. Each extends BaseChannel.
clients/Low-level API clients (Facebook Graph, email SMTP, Slack, Teams, Viber).
logger/Pino-based app and request loggers.
util/Miscellaneous helpers (delayPromise).
config/default.yml (defaults) and custom-environment-variables.yml (env var mapping).

API Surface

The Restify server starts on the configured port but no application routes are registered. It exists only to expose the process as an HTTP service for health probes in orchestrated environments.

External Dependencies

  • hbf-core API: @helvia/hbf-core-api — fetches broadcasts, saves status, fetches/creates subscribers and responses
  • Elasticsearch: elasticsearch package — used by the email reporter channel for analytics report data
  • Excel/CSV export: exceljs, json2csv — report generation for email channel
  • Email: nodemailer — SMTP delivery for email channel (analytics reports)
  • APM: elastic-apm-node — optional performance monitoring

Running Locally

npm install
# create config/local.yml with core.url and core.token
npm start
# or without APM:
# export ELASTIC_APM_ACTIVE=false && node ./bin/start.js

Tests

No test suite configured (npm test exits with error 1). Tests are not present in this repo.