Telegram Bot Welcome greetings message

4.9k views Asked by At

"How to send welcome greetings message using Bot, in Telegram"? Acctually i create new bot in telegram. and now i want , when new user start my bot, my bot send him Welcome greetings message? is it possible with "getupdates" method or i should use "webhooks" for it? pls guide me.

I have create one bot like @mak_tech_bot. and join it with my other telegram accout, but it not send any welcome message. i have also use /command.

I also tried one example in localhost

<?php
ini_set('error_reporting',E_ALL);
$botToken = "TOKEN";
$website = "https://api.telegram.org/bot".$botToken;

$update = file_get_contents('php://input');
$update = json_decode($update,TRUE);

$chatId = $update["message"]["chat"]["id"];
$message = $update["message"]["text"];

switch($message){
    case "/test":
        sendMessage($chatId,"test123");
        break;
    case "/hi":
        sendMessage($chatId,"Hello123");
        break;
    default:
        sendMessage($chatId,"default");
}

function sendMessage($chatId,$message){
    $url = $GLOBALS[website]."/sendMessage?chat_id=".$chatId."$text=".urlencode($message);
    file_get_contents($url);
}
?>
1

There are 1 answers

2
Sean Wei On

When you click START button, you will send /start command to bot, just add case '/start': to your code to send greeting message.