Telegram | Chat not found as Bot

When you log as bot, the GetChats method cannot be used, so you don't get All available chats. If it's the first time you login as Bot and you try to send a message to a known Chat, you will get this error:

 

{"@type":"error","code":5,"message":"Chat not found"}

 

The solution is to call the GetChat method before sending a telegram message and pass the ChatId as a parameter. Once you get the Chat data, you can send telegram messages as usual.

 

As a note, you only need to call GetChat the FIRST TIME before sending a message if you have never received any bot message from this chat. If you close the application and start again, there is no need to call GetChat first because the Chat is already saved in the telegram database.