№ 03 · Projects · maintained
Messenger Webhooks
Node.js library for building Facebook Messenger chatbots with an event-driven webhook API.
- Created
- Stack
- TypeScriptExpressnpmMessenger API
- Site
- messenger-webhooks.vercel.app/
- Source
- pyyupsk/messenger-webhooks
A TypeScript library for building Facebook Messenger chatbots. Event-driven architecture on top of Express, with full type definitions and a simple API for handling incoming events and sending messages.
Why this exists
Building Messenger chatbots typically involves wrestling with webhook verification, event parsing, and message sending. This library abstracts that complexity into a clean, typed API so you can focus on your bot's logic instead of plumbing.
Features
- Event-driven — handle messages, posts, and other events with simple listeners
- Full TypeScript support — complete type definitions for all API responses
- Express integration — uses Express under the hood for webhook handling
- Simple API — send text, images, and other message types with minimal code
Usage
import { Bot, MessageEvent } from "@pyyupsk/messenger-webhooks";
const bot = new Bot({
accessToken: "YOUR_ACCESS_TOKEN",
verifyToken: "YOUR_VERIFY_TOKEN",
});
bot.on("message", (event: MessageEvent) => {
const { sender, message } = event;
bot.sendTextMessage(sender.id, `You wrote: ${message.text}`);
});
bot.start();Getting started
- Create a Facebook App and generate your access token
- Set up webhook verification in the Facebook Developer Portal
- Deploy your bot with the required environment variables