K
K
Kirill Sirenko2020-04-18 22:57:56
PHP
Kirill Sirenko, 2020-04-18 22:57:56

Sending Telegram messages by a bot without human intervention. How?

Good afternoon!

I searched half of the Internet in search of an example, but did not understand.
Everywhere they describe bots that need to write something. However, I need to be able to receive messages from the bot on some event.

I have written a php script that, when called, calls the API of a third-party service.
API gives away 10 products. If a new 11 appears (the last one in the request changes), then the bot needs to send me a message.

I don't understand how to implement. I saw options with an infinite loop, I saw options with crowns.
Do I need a webhook for this or is it for something else? I would be grateful if someone gives a smoke to a similar bot code.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
nozzy, 2020-04-19
@nozzy

Webhook is not needed here. You create a bot in a cart, enter the name of the bot in the search, find it, write any message to it, otherwise the bot cannot be the first to send a message to users. You pull the address from your script:
https://api.telegram.org/bot <Bot_Token>/sendMessage?chat_id=<Your_ID>&text="New product arrived"
And that's it.

U
Uno, 2020-04-19
@Noizefan

How to know something?

Ask

Wait to be told

And API won't tell you anything.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question