LINE Routing
Bottender offers a bunch of helpers to route within your LINE or multi-platform app. For example, you may use LINE particular routes within your router:
const { router, line } = require('bottender/router');
function App() {
return router([
line.message(HandleMessage),
line.follow(HandleFollow),
line.unfollow(HandleUnfollow),
line.join(HandleJoin),
line.leave(HandleLeave),
line.memberJoined(HandleMemberJoined),
line.memberLeft(HandleMemberLeft),
line.postback(HandlePostback),
line.beacon.enter(HandleBeaconEnter),
line.beacon.banner(HandleBeaconBanner),
line.beacon.stay(HandleBeaconStay),
line.accountLink(HandleAccountLink),
line.things.link(HandleThingsLink),
line.things.unlink(HandleThingsUnlink),
line.things.scenarioResult(HandleThingsScenarioResult),
line.any(HandleLine),
]);
}
/* Note: You need to implement those functions */
async function HandleMessage(context) {}
async function HandleFollow(context) {}
async function HandleUnfollow(context) {}
async function HandleJoin(context) {}
async function HandleLeave(context) {}
async function HandleMemberJoined(context) {}
async function HandleMemberLeft(context) {}
async function HandlePostback(context) {}
async function HandleBeaconEnter(context) {}
async function HandleBeaconBanner(context) {}
async function HandleBeaconStay(context) {}
async function HandleAccountLink(context) {}
async function HandleThingsLink(context) {}
async function HandleThingsUnlink(context) {}
async function HandleThingsScenarioResult(context) {}
async function HandleLine(context) {}
All available routes in line that recognize different kind of events:
line.any- triggers the action when receiving any LINE events.line.message- triggers the action when receiving LINEmessageevents.line.follow- triggers the action when receiving LINEfollowevents.line.unfollow- triggers the action when receiving LINEunfollowevents.line.join- triggers the action when receiving LINEjoinevents.line.leave- triggers the action when receiving LINEleaveevents.line.memberJoined- triggers the action when receiving LINEmemberJoinedevents.line.memberLeft- triggers the action when receiving LINEmemberLeftevents.line.postback- triggers the action when receiving LINEpostbackevents.line.beacon.enter- triggers the action when receiving LINEbeaconevents with typeenter.line.beacon.banner- triggers the action when receiving LINEbeaconevents with typebanner.line.beacon.stay- triggers the action when receiving LINEbeaconevents with typestay.line.beacon- triggers the action when receiving LINEbeaconevents.line.accountLink- triggers the action when receiving LINEaccountLinkevents.line.things.link- triggers the action when receiving LINEthingsevents with typelink.line.things.unlink- triggers the action when receiving LINEthingsevents with typeunlink.line.things.scenarioResult- triggers the action when receiving LINEthingsevents with typescenarioResult.line.things- triggers the action when receiving LINEthingsevents.