Sending form data to Telegram

How do I send a request from the site to Telegram ?

Now I will tell you how to send requests from the site data from the feedback form (or simple notifications about payment, for example) using a telegram bot

The first thing to do is to create a bot in the cart

This is done simply – Type @botfather in the search

Как отправить заявку с сайта в Telegram

The list opens – Select the first one and click “Start”

Как отправить заявку с сайта в Telegram, форма, php, html, Telegram

NEXT – Enter the command /new bot

There will be a message

Alright, a new bot. How are we going to call it? Please choose a name for your bot.

What does it mean to come up with a bot name ( for example, Testsbox )

NEXT – you will be informed

Good. Now let’s choose a username for your bot. It must end in bot. Like this, for example: TetrisBot or tetris_bot.

(Good. Now let’s choose a username for your bot. It should end with “bot”. Like this, for example: TetrisBot or tetris_bot.)

We come up with the nickname of the bot ( for example , testhure_bot )

telegram is popular many names are busy

Will inform you that:

Sorry, this username is already taken. Please try something different.
(Sorry, this username is already taken. Please try something else.)

As the bot ‘s nickname fits , you will see a message and a TOKEN ( which you need to write down )

BotFather, [31.10.19 13:30]Done! Congratulations on your new bot. You will find it at t.me/tsmoney_bot. You can now add a description, about section and profile picture for your bot, see /help for a list of commands. By the way, when you’ve finished creating your cool bot, ping our Bot Support if you want a better username for it. Just make sure the bot is fully operational before you do this.

Use this token to access the HTTP API:
84917655:AAG_ArG0Bc3apH2nG-9Ncr675q8tugoRY2I
Keep your token secure and store it safely, it can be used by anyone to control your bot.

For a description of the Bot API, see this page: https://core.telegram.org/bots/api

THIS IS HOW THE TOKEN – 84917655 LOOKS LIKE:AAG_ArG0Bc3apH2nG-9Ncr675q8tugoRY2I ( WRITING IT DOWN)

Как отправлять заявки в Telegram?

NOW – you need to find your bot

We enter into the search the NICKNAME that you came up with @testhure_bot

CLICK “Start” to launch your bot

Сейчас я расскажу вам, как отправлять заявки с сайта (данные из формы обратной связи) с помощью телеграм-бота в

The last thing to do is to create a CHAT – so that applications ( notifications ) from your site come to it

In the main menu – click CREATE GROUP – select the name of the group ( chat)

 


important!!! – Invite your bot to the chat

Как отправлять заявки в Telegram

That ‘s almost it !!! We have a BOT and a TOKEN from it , we have created a chat ( group ) what would the BOT send messages from your site there

We just need to find out the ID of the GROUP ( CHAT )

To do this, write to the chat /join @nikvashegobot ( /join @testhure_bot )

How to send a message to a group – you need to enter in the browser

https://api.telegram.org/botXXX/getUpdates

Where is your bot’s XXX token

I have something like this

https://api.telegram.org/bot8491654235:AAG_ArG0BcbapH22nG-1Ncrn0Aq8tugoRY7I/getUpdates

If everything is correct, such content will open – there you need to find the GROUP ID

Как отправить заявку с сайта в Telegram

important! there’s a lot of id you need which is with a MINUS

 


PHP Form handler and the form itself ( if necessary )

<?php


if (isset($_POST[‘form’])) { // This is the ID of the button that will be clicked and the php script will work – Remove if just a message when entering the page ( remove the bracket at the bottom}

$name = $_POST[‘user_name’];// this is what we catch from the form
$phone = $_POST[‘user_phone’]; // this is what we catch from the form
$email = $_POST[‘user_email’]; // this is what we catch from the form
// Can be attributed so if you don’t need to catch
// $zakaz = “Order from XXX sites”;

$token = “849452335:AAG_ArG0H2nG-9Ncrn0Aq835oRY2I”; // This is a TOKEN
$chat_id = “-23534799”; // This is the ID of the group

$arr = array(

// ‘Order from sites: ‘ => $zakaz,
‘Phone: ‘ => $phone,
‘Name: ‘ => $name,
‘Soap’ => $email
);

foreach($arr as $key => $value) {
$txt .= “<b>”.$key.”</b> “.$value.”%0A”;
};

$sendToTelegram = fopen(“https://api.telegram.org/bot{$token}/sendMessage?chat_id={$chat_id}&parse_mode=html&text={$txt}”,”r”);

// This condition If a redirect is sent, if not, the error can be removed!
if ($sendToTelegram) {
header(‘Location: url.html ‘);
} else {
echo “Error”;
}
// button id
}
?>
<form action=”” name=”form” method=”POST”>
<legend>Form title</legend>

<div class=”form-group”>
<label for=””>Enter your name</label>
<input type=”text” class=”form-control” id=”” name=”user_name” placeholder=”For example, Ivan”>
</div>

<div class=”form-group”>
<label for=””>Enter the phone number</label>
<input type=”text” class=”form-control” id=”” name=”user_phone” placeholder=”+7 (999) 99 99 999″>
</div>

<div class=”form-group”>
<label for=””>Enter email</label>
<input type=”text” class=”form-control” id=”” name=”user_email” placeholder=”[email protected]”>
</div>

<button type=”submit” name=”form” class=”btn btn-primary”>Submit form</button>
</form>

 

 

Check Also

FAKE CRYPTO EXCHANGE SCRIPT

FAKE CRYPTO EXCHANGE SCRIPT

Main Features: – Automatic address generation for each user – Automatic verification of deposits to …

2 comments

  1. Good afternoon! data from the form’s checkboxes does not come with this code. How can this issue be resolved?Thanks!

Leave a Reply to adminTM Cancel reply

Your email address will not be published. Required fields are marked *