Skip to main content
Use whatsappBusiness.config(...) with credentials from Meta for Developers.

Config

whatsappBusiness.config({
  accessToken: "your-access-token",
  phoneNumberId: "your-phone-number-id",
  appSecret: "your-app-secret",
});
OptionDescription
accessTokenPermanent or system-user token from Meta for Developers.
phoneNumberIdThe phone number ID for the business account sending messages.
appSecretApp secret used to verify webhook payload signatures.
Find these values in your WhatsApp Business app settings on Meta for Developers.

Example

import { Spectrum } from "spectrum-ts";
import { whatsappBusiness } from "spectrum-ts/providers/whatsapp-business";

const app = await Spectrum({
  providers: [
    whatsappBusiness.config({
      accessToken: process.env.WA_TOKEN!,
      phoneNumberId: process.env.WA_NUMBER_ID!,
      appSecret: process.env.WA_SECRET!,
    }),
  ],
});

for await (const [space, message] of app.messages) {
  if (message.content.type === "text") {
    await message.reply(`Got it: ${message.content.text}`);
  }
}