Skip to main content

Update List

Evogram supports all events available in the Telegram API. Let's take a look at what events exist and what information we get.

message

The message event occurs every time a user sends a message to a chat or bot. We receive UserMessageContext, with which we can send messages, obtain information about the user, chat.

Usage example
client.updates.on("message", (message) => {
message.send(`${message.user.fullname}, thank you for writing to us!`);
});

edited_message

The edited_message event occurs every time a user edits a message already sent in a chat or bot. We also receive UserMessageContext, but with the updated message text.

Usage example
client.updates.on("edited_message", (message) => {
message.send(`${message.user.fullname}, you have edited your message!`);
});

channel_post

The channel_post event occurs every time a new message appears in the channel. We receive MessageContext, which contains information about the message and channel, as well as the sender, etc.

Usage example
client.updates.on("channel_post", (post) => {
console.log(`A new post ${post.authorSignature ? `(by ${post.authorSignature})` : ``} has been published in the "${post.chat.title}" channel`);
});

edited_channel_post

The edited_channel_post event occurs every time a sent message in the channel was changed. We receive MessageContext.

Usage example
client.updates.on("edited_channel_post", (post) => {
console.log(`The post ${post.authorSignature ? `(by ${post.authorSignature})` : ``} in the "${post.chat.title}" channel has been edited`);
});

inline_query

The inline_query event occurs every time a user uses the bot's inline mode. We receive InlineQueryContext, which contains the query text and user data.

Usage example
client.updates.on("inline_query", (query) => {
query.answer([{
id: "1",
type: "article",
title: "Hello, world!",
description: "This is an article sample.",
input_message_content: {
message_text: "You selected the 'Hello, world!' article."
}
}]);
});

chosen_inline_result

The chosen_inline_result event occurs every time a user selects a result from the list that we send him in response to his inline query. We receive ChosenInlineResultContext, which contains information about the selected result and the user.

Usage example
client.updates.on("chosen_inline_result", (result) => {
console.log(`User ${result.user.fullname} has chosen the result with ID ${result.id}`);
});

callback_query

The callback_query event occurs every time a user clicks a button in a message. We receive CallbackQueryContext, which contains information about the user, chat, and pressed button.

Usage example
client.updates.on("callback_query", (query) => {
query.answer({
text: "You pressed the button!",
show_alert: true
});
});

shipping_query

The shipping_query event occurs when a user requests information about payment and delivery. We receive ShippingQueryContext, which contains information about the user and delivery request.

Usage example
client.updates.on("shipping_query", (query) => {
console.log(`User ${query.user.fullname} requests delivery information`);
query.answer(true);
});

pre_checkout_query

The pre_checkout_query event occurs when a user requests a check before placing an order. We receive PreCheckoutQueryContext, which contains information about the user and the order.

Usage example
client.updates.on("pre_checkout_query", (query) => {
console.log(`User ${query.user.fullname} requested a pre-checkout verification.`);
});

poll

The poll event occurs every time a user creates a poll in the chat. We receive PollContext, which contains information about the poll.

Usage example
client.updates.on("poll", (poll) => {
console.log(`A poll was created: '${poll.question}'`);
});

poll_answer

The poll_answer event occurs every time a user votes in a poll. We receive PollAnswerContext, which contains information about the user and answers.

Usage example
client.updates.on("poll_answer", (answer) => {
console.log(`User ${answer.user.fullname} voted in the poll`);
});

my_chat_member

The my_chat_member event occurs every time your bot joins / leaves / has been removed from a chat. We receive ChatMemberContext, which contains information about the user and the bot's participation status in the chat.

Usage example
client.updates.on("my_chat_member", (member) => {
console.log(`The bot has been ${member.newChatMember.status} from ${member.chat.title}`);
});

chat_member

The chat_member event occurs every time a user joins / leaves / has been removed from a chat. We receive ChatMemberContext, which contains information about the user and the user's participation status in the chat.

Usage example
client.updates.on("chat_member", (member) => {
console.log(`${member.user.fullname} has been ${member.newChatMember.status} from ${member.chat.title}`);
});

chat_join_request

The chat_join_request event occurs every time a user sends a request to join a group. We receive ChatJoinRequestContext, which contains information about the user and the group.

Usage example
client.updates.on("chat_join_request", (request) => {
console.log(`User ${request.user.fullname} requests to join the ${request.chat.title} group`);
request.approve()
});