WhatsApp Routing
Bottender offers a bunch of helpers to route within your WhatsApp or multi-platform application. For example, you may use WhatsApp particular routes within your router:
const { router, whatsapp } = require('bottender/router');
function App() {
return router([
whatsapp.message(HandleMessage),
whatsapp.media(HandleMedia),
whatsapp.received(HandleReceived),
whatsapp.sent(HandleSent),
whatsapp.delivered(HandleDelivered),
whatsapp.read(HandleRead),
whatsapp(HandleWhatsapp),
]);
}
async function HandleMessage(context) {
/* skip... */
}
async function HandleMedia(context) {
/* skip... */
}
async function HandleReceived(context) {
/* skip... */
}
async function HandleSent(context) {
/* skip... */
}
async function HandleDelivered(context) {
/* skip... */
}
async function HandleRead(context) {
/* skip... */
}
async function HandleWhatsapp(context) {
/* skip... */
}
All available routes in whatsapp that recognize different kind of events:
whatsapp- matches when receiving any whatsapp events.whatsapp.message- matches when receiving whatsappreceivedevents. Alias:whatsapp.received.whatsapp.media- matches when receiving whatsappreceivedevents includes media.whatsapp.received- matches when receiving whatsappreceivedevents.whatsapp.sent- matches when receiving whatsappsentevents.whatsapp.delivered- matches when receiving whatsappdeliveredevents.whatsapp.read- matches when receiving whatsappreadevents.