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 Telegrammessage
events.telegram.editedMessage
- triggers the action when receiving TelegrameditedMessage
events.telegram.channelPost
- triggers the action when receiving TelegramchannelPost
events.telegram.editedChannelPost
- triggers the action when receiving TelegrameditedChannelPost
events.telegram.inlineQuery
- triggers the action when receiving TelegraminlineQuery
events.telegram.chosenInlineResult
- triggers the action when receiving TelegramchosenInlineResult
events.telegram.callbackQuery
- triggers the action when receiving TelegramcallbackQuery
events.telegram.shippingQuery
- triggers the action when receiving TelegramshippingQuery
events.telegram.preCheckoutQuery
- triggers the action when receiving TelegrampreCheckoutQuery
events.telegram.poll
- triggers the action when receiving Telegrampoll
events.