I’m working with a Telegram bot that uses webhooks to receive updates. Most of the time when users send the /start command, my server gets the expected message object:
{
"update_id": 12345678,
"message": {
"message_id": 1001,
"from": {
"id": 987654321,
"is_bot": false,
"first_name": "John",
"last_name": "Smith",
"language_code": "en"
},
"chat": {
"id": 987654321,
"first_name": "John",
"last_name": "Smith",
"type": "private"
},
"date": 1634567890,
"text": "/start",
"entities": [
{
"offset": 0,
"length": 6,
"type": "bot_command"
}
]
}
}
But sometimes, especially with first-time users, I get a my_chat_member object instead:
{
"update_id": 87654321,
"my_chat_member": {
"chat": {
"id": 123456789,
"first_name": "Alice",
"type": "private"
},
"from": {
"id": 123456789,
"is_bot": false,
"first_name": "Alice",
"language_code": "es"
},
"date": 1634560000,
"old_chat_member": {
"user": {
"id": 111222333,
"is_bot": true,
"first_name": "MyBot",
"username": "my_awesome_bot"
},
"status": "member"
},
"new_chat_member": {
"user": {
"id": 111222333,
"is_bot": true,
"first_name": "MyBot",
"username": "my_awesome_bot"
},
"status": "kicked",
"until_date": 0
}
}
}
When this happens, I don’t receive the actual /start command text. This issue occurs across different platforms including mobile apps and web clients. What could be causing this behavior and how can I handle it properly?