Event
Bottender event helps you determine what kind of message is sent from user.
You can access context.event
object within your handlers as the following example shows.
bot.onEvent(async (context) => {
if (context.event.isText) {
await context.sendText('I know you sent text message.');
} else {
await context.sendText('I know you did not send text message.');
}
});
For platform specific events, please check out following links:
Platform | Doc |
---|---|
Console | APIReference-ConsoleEvent |
Messenger | APIReference-MessengerEvent |
LINE | APIReference-LineEvent |
Slack | APIReference-SlackEvent |
Telegram | APIReference-TelegramEvent |
Viber | APIReference-ViberEvent |
rawEvent
Underlying raw event.
Example:
event.rawEvent;
// {
// ...
// }
isMessage
Determine if the event is a message event.
Example:
event.isMessage; // true
message
The message object from Messenger raw event.
Example:
event.message;
// {
// ...
// text: 'Awesome.',
// }
isText
Determine if the event is a message event which includes text.
Example:
event.isText; // true
text
The text string from Messenger raw event.
Example:
event.text; // 'Awesome.'