Skip to content

How to identify a bot in the Telegram messenger?#

Starting from version 4.4.24 of the Telegram messenger API from GREEN-API, it has become possible to identify bots when sending and receiving messages.

For this, the chatType and senderType fields were added to the API webhooks, and new values were added for the type field.

Using the table, choose the method or webhook that is convenient for you to track bots in the chat or sender type. The field will take the value bot for Telegram bots.

Field Type Description Method / Webhook
chatType string Chat type. Takes the value: "user", "group", "supergroup", "channel", "bot" Added to the senderData object in webhooks. Added to the journal methods lastIncomingMessages, lastOutgonigMessages, getMessage, getChatHistory
senderType string Sender type. Takes the value: "user", "group", "supergroup", "channel", "bot" Added to the senderData object in webhooks. Added to the journal methods lastIncomingMessages, lastOutgonigMessages, getMessage, getChatHistory
type string Chat type.
Can take the values: "user", "group", "supergroup", "channel", "bot"
The field was extended in the getChats method

Example of the chatType and senderType fields of the senderData object in webhooks#

The sender is a bot

"senderData": {
    "chatId": "10000000",
    "chatType": "bot", 
    "sender": "10000000",
    "chatName": "Vasilisa the Wise",
    "senderName": "Vasilisa the Wise",
    "senderType": "bot", 
    "senderContactName": "Vasilisa the Wise",
    "senderPhoneNumber": 79998887766
}

A bot sends a message in a group chat

"senderData": {
    "chatId": "-10000000",
    "chatType": "group", 
    "sender": "10000000",
    "chatName": "Group",
    "senderName": "Vasilisa the Wise",
    "senderType": "bot",
    "senderContactName": "Vasilisa the Wise",
    "senderPhoneNumber": 79998887766
}

Example of the type field in the responses of the getChats method#

Example of a getChats method response

    {
        "chatId": "10000000",
        "name": "Vasilisa the Wise",
        "type": "bot",  
        "phoneNumber": 79876543210
    }

Example of the chatType and senderType fields in the journal methods#

Example of a journal method response

{
    "type": "incoming",
    "idMessage": "1769676078000",
    "timestamp": 1769676078,
    "typeMessage": "textMessage",
    "chatId": "-10000000",
    "chatType": "group",  
    "textMessage": "I use GREEN-API to send this message!",
    "senderId": "20000000",
    "senderName": "Vasilisa the Wise",
    "senderType": "bot",
    "senderContactName": "Vasilisa the Wise",
    "deletedMessageId": "",
    "editedMessageId": "",
    "isEdited": false,
    "isDeleted": false
}