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(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
- triggers the action when receiving any LINE events.line.message
- triggers the action when receiving LINEmessage
events.line.follow
- triggers the action when receiving LINEfollow
events.line.unfollow
- triggers the action when receiving LINEunfollow
events.line.join
- triggers the action when receiving LINEjoin
events.line.leave
- triggers the action when receiving LINEleave
events.line.memberJoined
- triggers the action when receiving LINEmemberJoined
events.line.memberLeft
- triggers the action when receiving LINEmemberLeft
events.line.postback
- triggers the action when receiving LINEpostback
events.line.beacon.enter
- triggers the action when receiving LINEbeacon
events with typeenter
.line.beacon.banner
- triggers the action when receiving LINEbeacon
events with typebanner
.line.beacon.stay
- triggers the action when receiving LINEbeacon
events with typestay
.line.beacon
- triggers the action when receiving LINEbeacon
events.line.accountLink
- triggers the action when receiving LINEaccountLink
events.line.things.link
- triggers the action when receiving LINEthings
events with typelink
.line.things.unlink
- triggers the action when receiving LINEthings
events with typeunlink
.line.things.scenarioResult
- triggers the action when receiving LINEthings
events with typescenarioResult
.line.things
- triggers the action when receiving LINEthings
events.