skip to Main Content

I have a telegram bot where the user can send /start command and I will receive this command on my server via web hook. In 99% of cases the request from telegram looks like this:

{
   "update_id":99999999,
   "message":{
      "message_id":9999,
      "from":{
         "id":999999999,
         "is_bot":false,
         "first_name":"first_name",
         "last_name":"last_name",
         "language_code":"code"
      },
      "chat":{
         "id":99999999,
         "first_name":"first_name",
         "last_name":"last_name",
         "type":"private"
      },
      "date":1665383118,
      "text":"/start",
      "entities":[
         {
            "offset":0,
            "length":6,
            "type":"bot_command"
         }
      ]
   }
}

The object is "message" and I have a text "/start" there.

But sometimes from some new users who hasn’t used this bot before when they send start the request from telegram look like this:

{
   "update_id":999999999,
   "my_chat_member":{
      "chat":{
         "id":999999999,
         "first_name":"first_name",
         "type":"private"
      },
      "from":{
         "id":999999999,
         "is_bot":false,
         "first_name":"first_name",
         "language_code":"code"
      },
      "date":1665381194,
      "old_chat_member":{
         "user":{
            "id":8888888888,
            "is_bot":true,
            "first_name":"bot_name",
            "username":"bot_name"
         },
         "status":"member"
      },
      "new_chat_member":{
         "user":{
            "id":8888888888,
            "is_bot":true,
            "first_name":"bot_name",
            "username":"bot_name"
         },
         "status":"kicked",
         "until_date":0
      }
   }
}

The object "my_chat_member" and the "start" command was not received from this user.

This happens for users on IPhone, Android, PC, Web.
I can’t understand why it happens and how to fix.

2

Answers


  1. Chosen as BEST ANSWER

    The problem was on my server side. I used int32 for users' and chats' ids but they can be bigger. Using the correct type solved the problem.


  2. Message type "my_chat_member" means somebody described as "from" wants to unsubscribe from bot. "status":"kicked" says the same. Here https://core.telegram.org/bots/api you can read Getting updates topic

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search