whatsapp-business
Version:
Node.js connector for the WhatsApp Business APIs with TypeScript support, integration tests and more.
46 lines (45 loc) • 1.45 kB
TypeScript
import express, { Router } from "express";
import { WebhookEvents } from "../types";
export interface WebhookClientArgs {
/**
* Use this option if you want to use your own express application
*/
expressApp?: {
app: express.Application;
/**
* If the app should start listening on the specified port when initializing the webhook router.
*/
shouldStartListening: boolean;
};
/**
* The server port, defaults to: 8080
*/
port?: number;
/**
* the url for the endpoint, example: { "path": "/whatsapp/business" }.
*
* if not provided will default to: "/webhook".
*/
path?: string;
/**
* The token you provided for this endpoint. It is used to authenticate the webhook.
*/
token: string;
}
/**
* Use this client if you want to easily initialize webhook connections.
* Before anything, make sure your server has an https connection.
* For more info, check the docs: https://developers.facebook.com/docs/whatsapp/cloud-api/guides/set-up-webhooks
*/
export declare class WebhookClient {
private path;
private port;
private token;
protected router: Router;
expressApp?: WebhookClientArgs["expressApp"];
constructor({ path, port, expressApp, token }: WebhookClientArgs);
/**
* Initializes the webhook listener server with the provided events.
*/
initWebhook(events?: WebhookEvents): void;
}