V
V
vosyukov2017-10-04 18:04:22
Python
vosyukov, 2017-10-04 18:04:22

How to send a message to a user in Telegram from a bot?

1) I created a bot
2) I initiated a conversation with him
3) I make a request (token and chat id inserted my own)

https://api.telegram.org/bot<token>/sendMessage?chat_id=<chatId>&text=Hello

As a result, I get the response {"ok":false,"error_code":403,"description":"Forbidden: bot can't initiate conversation with a user"}
Tell me what's wrong.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Aleksey Solovyev, 2017-10-04
@vosyukov

From the error, we see that the bot cannot create a conversation. Are you sure you create it through an account, and not through a bot? Check the variables carefully: user id, etc.
It's hard to say what the error is without seeing the code ... Throw it here - we will solve the problem)
What library did you use? Up-to-date? They had an update there not so long ago, MB of which they changed - in the order of a complete nonsense idea.

N
nllm, 2017-10-04
@nllm

Maybe you are specifying the wrong chat_id? Or a token from another bot?
And so in the description everything is described.

H
Heron77, 2021-10-11
@Heron77

The API reported that the robot could not initiate a conversation. You must first do this from your Telegram account.
1. Type in the search @username_bot_who_specified_when_created
2. It will appear in the contact list
3. Click on it
4. Click "Start" The
conversation has been created now The robot will normally send messages

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question