Viber Routing
Bottender offers a bunch of helpers to route within your Viber or multi-platform app. For example, you may use Viber particular routes within your router
:
const { router, viber } = require('bottender/router');
function App() {
return router([
viber.message(HandleMessage),
viber.subscribed(HandleSubscribed),
viber.unsubscribed(HandleUnsubscribed),
viber.conversationStarted(HandleConversationStarted),
viber.delivered(HandleDelivered),
viber.seen(HandleSeen),
viber.failed(HandleFailed),
viber.any(HandleViber),
]);
}
/* Note: You need to implement those functions */
async function HandleMessage(context) {}
async function HandleSubscribed(context) {}
async function HandleUnsubscribed(context) {}
async function HandleConversationStarted(context) {}
async function HandleDelivered(context) {}
async function HandleSeen(context) {}
async function HandleFailed(context) {}
async function HandleViber(context) {}
All available routes in viber
that recognize different kind of events:
viber.any
- triggers the action when receiving any Viber events.viber.message
- triggers the action when receiving Vibermessage
events.viber.subscribed
- triggers the action when receiving Vibersubscribed
events.viber.unsubscribed
- triggers the action when receiving Viberunsubscribed
events.viber.conversationStarted
- triggers the action when receiving Viberconversation_started
events.viber.delivered
- triggers the action when receiving Viberdelivered
events.viber.seen
- triggers the action when receiving Viberseen
events.viber.failed
- triggers the action when receiving Viberfailed
events.