Message the bot once from your account, then check the token and chat ID in the code.
What the message means
Telegram only lets a bot write to a chat that has started. The library also needs a working HTTPS connection with the right time.
Fix it in this order
- Open your bot in Telegram and press start.
- Check the token from the bot creator chat and the chat ID of your own account.
- Sync the time first. See the NTP page.
- Add the certificate or use the setting your library needs for HTTPS.
- Poll every second or two, not in a tight loop.
- Print the library return values to see errors.
Why it happens
A Telegram bot cannot start a conversation. The user must message the bot, or add it to a group, first; the python-telegram-bot documentation states this, and once the user has written to the bot you can save the chat ID.
When you receive messages by polling, Telegram’s Bots FAQ says an update is confirmed only when a later getUpdates call passes an offset one higher than the last update ID, and that getUpdates returns the earliest 100 unconfirmed updates. If your code does not advance the offset, the same updates come back or newer ones wait behind them. A wrong device clock is a common cause of HTTPS failures on microcontrollers, so sync the time first.
If you see this, do this
| You see | Do this |
|---|---|
| Never receives anything | Token, chat ID or HTTPS. |
| Sends but does not receive | Polling or the update offset. |
Related
Last reviewed: November 2026. These are the usual causes and the order that finds them fastest. Test on your own board; clones and cables differ.
Why this happens
A Telegram bot talks to the Bot API over HTTPS. It cannot start a chat. A person has to send a message to the bot first, and only then can the bot send to that person’s chat ID. Without that first message, a send fails with an error even though the token is correct.
Receiving works by polling. Each getUpdates call returns the unconfirmed updates, and the library confirms older ones by asking for an update ID higher than the last one it saw. If the code does not advance that number, the same updates come back. If two programs use the same token at the same time, Telegram returns a conflict, so a bot left running on a computer can block the board. The HTTPS part needs a correct clock, as certificates are checked against the date.
How to confirm the cause
- Open the bot in the Telegram app and press start or send a word. Then check that the board prints that message.
- Print the return code of getUpdates and sendMessage. An error number tells you what failed.
- Print the chat ID from each message and compare with the one in your code. Group chat IDs are negative numbers.
- Check the token for stray spaces and a full copy of it, including the part after the colon.
- Make sure no other program is running the same bot, and check the time is synced before the first request.
Worked example
This follows the UniversalTelegramBot library’s pattern. It polls every 2 seconds and replies to each message with the same chat ID it came from. For tests you can use setInsecure(), but the certificate setting shown in the comment is the safer choice.
#include <WiFiClientSecure.h>
#include <UniversalTelegramBot.h>
WiFiClientSecure client;
UniversalTelegramBot bot(BOT_TOKEN, client);
// in setup(): client.setCACert(TELEGRAM_CERTIFICATE_ROOT);
void loop() {
int n = bot.getUpdates(bot.last_message_received + 1);
for (int i = 0; i < n; i++) {
String id = bot.messages[i].chat_id;
Serial.println(bot.messages[i].text);
bot.sendMessage(id, "got it", "");
}
delay(2000);
}Common mistakes
- Never messaging the bot first.
- Polling every few milliseconds, which can trigger rate limits.
- Letting an old copy of the bot keep running elsewhere.
- Hard-coding a chat ID from another account.
- Publishing the token in code that is shared.
If this did not fix it
- The clock: HTTPS checks fail on a wrong date.
- Memory: a long message list can use up heap on a small board.
- The router or network blocking outgoing HTTPS.