Telegram Routings
Bottender offers a bunch of helpers to route within your Telegram or multi-platform app. For example, you may use Telegram particular routes within your router:
const { router, telegram } = require('bottender/router');
function App() {
return router([
telegram.message(HandleMessage),
telegram.editedMessage(HandleEditedMessage),
telegram.channelPost(HandleChannelPost),
telegram.editedChannelPost(HandleEditedChannelPost),
telegram.inlineQuery(HandleInlineQuery),
telegram.chosenInlineResult(HandleChosenInlineResult),
telegram.callbackQuery(HandleCallbackQuery),
telegram.shippingQuery(HandleShippingQuery),
telegram.preCheckoutQuery(HandlePreCheckoutQuery),
telegram.poll(HandlePoll),
telegram(HandleTelegram),
]);
}
/* Note: You need to implement those functions */
async function HandleMessage(context) {}
async function HandleEditedMessage(context) {}
async function HandleChannelPost(context) {}
async function HandleEditedChannelPost(context) {}
async function HandleInlineQuery(context) {}
async function HandleChosenInlineResult(context) {}
async function HandleCallbackQuery(context) {}
async function HandleShippingQuery(context) {}
async function HandlePreCheckoutQuery(context) {}
async function HandlePoll(context) {}
async function HandleTelegram(context) {}
All available routes in telegram that recognize different kind of events:
telegram- triggers the action when receiving any Telegram events.telegram.message- triggers the action when receiving Telegrammessageevents.telegram.editedMessage- triggers the action when receiving TelegrameditedMessageevents.telegram.channelPost- triggers the action when receiving TelegramchannelPostevents.telegram.editedChannelPost- triggers the action when receiving TelegrameditedChannelPostevents.telegram.inlineQuery- triggers the action when receiving TelegraminlineQueryevents.telegram.chosenInlineResult- triggers the action when receiving TelegramchosenInlineResultevents.telegram.callbackQuery- triggers the action when receiving TelegramcallbackQueryevents.telegram.shippingQuery- triggers the action when receiving TelegramshippingQueryevents.telegram.preCheckoutQuery- triggers the action when receiving TelegrampreCheckoutQueryevents.telegram.poll- triggers the action when receiving Telegrampollevents.