spectrum-ts is a unified messaging SDK for TypeScript. Write your logic once, deliver it across every platform — iMessage, WhatsApp Business, your terminal, or a custom platform you build yourself.
Installation
spectrum-ts is the batteries-included package for the standard provider set.
The macOS-only local iMessage adapter is intentionally separate so its native
Messages database dependencies are never installed in cloud applications.
@spectrum-ts/core plus only the providers you need:
spectrum-ts/providers/<platform> import paths work as long as the matching provider package is installed.
Local iMessage is the exception: install and import it explicitly. It has no
spectrum-ts/providers/imessage-local compatibility path.
Core concepts
Spectrum is built around four primitives:
Every message arrives as a tuple containing a and a . The space gives you the ability to respond; the message gives you the content and metadata.
Quickstart
Get your credentials
Find yourPROJECT_ID and SECRET_KEY in your project Settings on the dashboard.
You can pass these to Spectrum(...) directly, or omit them and let Spectrum
read SPECTRUM_PROJECT_ID and SPECTRUM_PROJECT_SECRET from the environment.
The same explicit-wins-over-env fallback applies to webhookSecret (SPECTRUM_WEBHOOK_SECRET)
and to every provider’s config.
Provider config fallbacks are automatic and convention-based: any text config
field can be supplied through the environment as SPECTRUM_<PLATFORM>_<FIELD>,
where <PLATFORM> is the provider’s id upper-cased (spaces and punctuation become
_) and <FIELD> is the config key in UPPER_SNAKE_CASE. For example
Telegram’s botToken reads from SPECTRUM_TELEGRAM_BOT_TOKEN, and WhatsApp
Business’s phoneNumberId reads from SPECTRUM_WHATSAPP_BUSINESS_PHONE_NUMBER_ID.
Explicit config always wins over the environment — see the provider setup pages
for each field’s env var name.
Run your first app
terminal) can be used without credentials:
The app instance
Spectrum() returns a — an object that merges a message stream with platform-specific custom event streams.
app.messages is an AsyncIterable of tuples containing a and a .
Custom events emitted by providers are exposed as flat async iterables on the same object — see Custom events and lifecycle.
app.webhook() handles both native Spectrum webhooks and Fusor webhooks through the same method. See Webhooks for setup and framework adapters.
Multi-platform in three lines
Combine providers to receive and send across platforms simultaneously:app.messages stream. The message.platform field identifies the source.
Logging
Spectrum emits structured logs across the core runtime and providers. Control the verbosity withlogLevel:
Telemetry
Spectrum has built-in OpenTelemetry instrumentation. Enable it by passingtelemetry: true:
OTEL_EXPORTER_OTLP_* environment variables override the default endpoint and headers.
Calling app.stop() flushes any pending telemetry data before shutting down.