bot-middleware-jubi
raw JSON → 1.0.102 verified Sat Apr 25 auth: no javascript
bot-middleware-jubi is a Node.js server middleware for building chatbot backends with support for Facebook Messenger, Twilio WhatsApp, Firebase Cloud Messaging (FCM), and web sockets. Version 1.0.102 is the latest. It requires MongoDB for storage and optionally Redis for clustering. The package provides a unified configuration interface for multiple channels, including passphrase-based authentication, dashbot integration, and static file serving. It is primarily used with CommonJS require() and has minimal TypeScript support.
Common errors
error TypeError: Server is not a function ↓
cause Using ES module import or incorrect destructuring.
fix
Use const { Server } = require('bot-middleware-jubi'); and ensure Node.js version supports CommonJS.
error MongoError: failed to connect to server [localhost:27017] ↓
cause MongoDB is not running or the dbUri is incorrect.
fix
Start MongoDB or update the dbUri with correct credentials and host.
error Error: listen EADDRINUSE :::4000 ↓
cause Port 4000 is already in use by another process.
fix
Change the httpPort option to an available port or kill the process using port 4000.
Warnings
gotcha Do not use ES module imports (import/export) with this package; it is CommonJS only and may cause runtime errors. ↓
fix Use const { ... } = require('bot-middleware-jubi'); instead of import.
gotcha The dbUri must point to a running MongoDB instance; the package does not provide connection pooling warnings if the URI is invalid. ↓
fix Ensure MongoDB is running and the URI is correct before calling Server().
deprecated The properties 'dashbotKey', 'fcmServerKey', and 'firebaseWebConfig' are optional but may be removed in a future version. ↓
fix Check the latest documentation for replacement APIs if they are missing.
Install
npm install bot-middleware-jubi yarn add bot-middleware-jubi pnpm add bot-middleware-jubi Imports
- Server wrong
import { Server } from 'bot-middleware-jubi';correctconst { Server } = require('bot-middleware-jubi'); - facebook wrong
const facebook = require('bot-middleware-jubi').facebook;correctconst { facebook } = require('bot-middleware-jubi'); - createAdapter
const { createAdapter } = require('bot-middleware-jubi');
Quickstart
const { Server, facebook } = require('bot-middleware-jubi');
Server({
root: 'https://yourdomain.com/path',
socketLocalPath: '/socket',
httpPort: 4000,
dbUri: 'mongodb://root:root@127.0.0.1:27017/mydb',
staticDirectory: __dirname + '/static',
adapterPath: '/adapter',
adapterDirectory: __dirname + '/adapter',
projectId: 'myproject_100911645983',
passphraseMiddleware: 'supersecret',
timeoutSeconds: 60
}, () => {
facebook({
verificationToken: 'verify',
pageAccessToken: process.env.PAGE_ACCESS_TOKEN ?? '',
path: '/fb'
});
console.log('Server initialized');
});