php – Website notifications in Telegram


There is a site created without the use of engines. I want to attach a feedback form so that the visitor leaves his number and name in a special form, and this data is then transferred to the manager in Telegram. Can you explain in detail how this is done?


  1. You create a new bot in Telegram, write here: first /start, then /newbot.
  2. Find out your Telegram account ID. You can do this by writing to the bot
  3. You create a link to the Telegram API to send a message to a chat with you (you first need to start a chat with your Telegram bot, for this you need to press /start). The link looks like this:[Токен бота]/sendMessage?chat_id=[Твой ID]&text=[Текст]
  4. Then you need to set up your form handler. It’s already on your part, we just take the data, for example:

     $phone = $_POST['phone']; $email = $_POST['email']; $firstname = $_POST['firstname'];
  5. Then we generate the message that we want to send to Telegram. Again, for example:

     $msg = "Новая заявка на сайте! \nE-mail: $email \nТелефон: $phone \n Имя: $name";
  6. Then you need to send this data to telegram. There are many ways to do this, the easiest one is:

     $token = *Вставь сюда токен своего бота*; $telegram_admin_id = *Сюда твой ID, взятый из userinfobot*; $msg = "Новая заявка на сайте! \nE-mail: $email \nТелефон: $phone \n Имя: $name"; file_get_contents('. $token .'/sendMessage? chat_id='. $telegram_admin_id .'&text=' . urlencode($msg));
Scroll to Top