Send a welcome message to newcomers to the Telegram group | Telegram bot

15 April 2023 740 Reading time: 1 minute

You have a telegram group where you gather your audience and you want to welcome message new members to the group, how can you do that?

To do this you need to follow a few steps

1. Need to create a Telegram bot( We talked about this in our article: How to create a Telegram bot with PHP? )

2. Adds our bot to the group we will use

3. PHP Telegram We create our bot with the following codes using the library

include 'Telegram.php';
$token = "YOUR_BOT_TOKEN";
$telegram = new Telegram($token);
$data = $telegram->getData();
   $chat_id = $telegram->ChatID();
   $newUser = $data['message']['new_chat_member']['first_name'];
   $content = array('chat_id' => $chat_id, 'text' => $newUser.' welcome!');

You can add the above codes by creating a bot.php file on your server and this way you can identify your Webhook by opening it in a browser. Your bot will now automatically send a "Welcome" message to new users who will join your Telegram group.

Similar articles