Telegram Auto Reply Bot Using PHP

यदि आपको Telegram के मैसेज को PHP Server पर अपने आप ही Send करना हैं तो इस तरह से आप BOT बनाकर आसानी से Telegram के message PHP Server पर Send कर सकते हैं । इस Article मे simple PHP telegram bot example दिया गया है । और आप इस आर्टिकल की मदद से Telegram Auto Reply Bot बहुत ही आसानी से बना सकते हैं ।

Functions of Bot

  • Bot reply messages : Bot का कार्य किसी भी Message का Reply करना होता हैं इसलिए इसे telegram auto reply bot कहा जाता हैं ।
  • Telegram php send message : Bot का कर हमारे set किए गए Message को भेजना होता हैं ।
  • Count Messages : आप user द्वारा भेजे गए Message को Count कर सकते हैं ।
  • Update Database : आप जो PHP की api बना रहे है उससे MySQL database को update कर कोई Application भी बना सकते हैं ।



How to Create a New Bot for Telegram

Telegram मे Bot बनाना बहुत ही आसान हैं हमने इस article मे कुछ Steps बताए हैं आप इनको Follow कर Telegram Bot बना सकते हैं

  • Make a bot
  • Make PHP Page and Upload on Server
  • Set your api to Webhook


Step 1 : Make a Bot

सबसे पहले आप एक Bot बनाना हैं, आइये हम Bot कैसे बनाये यह समझते हैं ।

  • अपने मोबाइल में Telegram ओपन करे ।
  • Search पर Click करे ।
  • BotFather Search करे और Open करे ( यहाँ पर ध्यान रहे की जिस पर verify mark लगा हैं वही ओपन करे जिसका User Name @BotFather हैं
  • BotFather ओपन करने के बाद आप START पर Click करे (/start से भी कर सकते हैं)
  • /newbot टाइप करे या जो help open हुए हैं उसमे /newbot पर क्लिक करे
  • अब भी boat का Name देना हैं वह Type करे, मेने यहाँ MyTestBot Type किया हैं।
  • अब आपको bot का यूजर नाम देना हैं लास्ट में bot लिखना जरुरी हैं ।
  • जब नाम accept हो जाएगा तब आपको एक token दिया जायेगा जिसे HTTP API कहा जाता हैं इसमें आगे कुछ number होते हैं उसके बाद colon और फिर text होता हैं , यह आपको कही पर सेफ रखना हैं , इसका उपयोग कर कोई भी आपकी bot को Control कर सकता हैं ।
  • इसके बाद आपको /setprivacy लिखना हैं और अपनी bot को सेलेक्ट करना हैं । यहाँ पर हमें privacy disable करना होगी क्युकी हम bot को Telegram group में ऐड कर उसके Chat को Read कर अपने Server पर Send करेंगे ।
Create a Telegram Bot

Step 2 : Make PHP Page and Upload on Server

  • अब आपको एक PHP पेज बनाना हैं और उसे अपने सर्वर पर अपलोड करना हैं , यहाँ पर ध्यान रहे की आपके सर्वर पर https होना जरुरी हैं ।
  • यहाँ पर हमें HTTP API Token जो हमें BotFather ने दिया था वह paste करना हैं ।
  • यह Telegram पर जो type करके भेजा जाएगा उसे Read करने के लिए हैं ।
  • यहाँ पर message wale array में से हमें जो भी field चाहिए उसका डाटा Read कर रहे हैं
  • यह पर आप जो भी Logic लगाना चाहते हैं वह लिख सकते है ।
  • यहाँ पर आपको जो भी message telegram पर show करवाना हैं वह लिखना हैं
  • इस फाइल को आप अपने server पर अपलोड करे और उस लिंक को कॉपी करे
  • उदहारण के लिए वह लिंक इस प्रकार होगी https://yourdomanname/directoryname/MyTestBot.php
<?php

/* 1. Declare Token */
$myToken   = "https://api.telegram.org/bot<HTTP API Token>";

/* 2. this page call when message send by any user to bot or group */
$myContent = file_get_contents("php://input");
$TeleMsg   = json_decode($myContent,true);

/* 3. Read Data from message */
$MyChatID= $TeleMsg["message"]["chat"]["id"];
$message = $TeleMsg["message"]["text"];
$from_id = $TeleMsg["message"]["from"]["id"];
$from_nm = $TeleMsg["message"]["from"]["first_name"];
$date    = $TeleMsg["message"]["date"];

/* 4. Write Your Logic*/



/* 5. Return Message to User on Telegram */
$ReturnMsg = 'Hello ' . $from_nm . 'Your Message is '. $message;  
file_get_contents($myToken."/sendmessage?chat_id=".$MyChatID."&text=".$ReturnMsg );

?>


Step 3 : Set MyTestBot.php to Webhook

अब आपको एक URL बनना हैं और उसे browser पर Execute करना हैं

https://api.telegram.org/bot<HTTP API Token>/setwebhook?url=<YOUR SERVER PHP FILE NAME>
//For Example
https://api.telegram.org/bot<HTTP API Token>/setwebhook?url=https://yourdomanname/directoryname/MyTestBot.php

यदि WebHook सही तरीके से सेट हो गया तो आपको इस Browser पर एक प्रकार का message दिखाई देगा ।

{"ok":true,"result":true,"description":"Webhook was set"}

यहाँ पर आपने अपने PHP पेज को Telegram के WebHook से जोड़ दिया हैं अब जैसे ही Telegram Bot पर कोई मैसेज आएगा वह आपके द्वारा लिखे logic को Execute कर Auto Reply कर देगा ।
set webhook telegram bot php for telegram bot auto send message


Step 4 : Add this Bot to Telegram Group

वैसे तो आप टेलीग्राम Bot पर मैसेज भेज कर Reply प्राप्त कर सकते हैं लेकिन यदि आपका लॉजिक किसी ग्रुप से डाटा रिसीव करना का हैं तो आपको इस Bot को Telegram Group में ऐड करना होगा ।

यदि आप चाहते हैं की आपकी Bot सिर्फ इसी ग्रुप में वर्क करे तो आप $MyChatID की वैल्यू पर php पेज में कंडीशन लिख सकते हैं ।


हमारे अन्य आर्टिकल


Step 5: Test Bot

  • अब टेलीग्राम में BotFather ओपन करे (Bot Father से ही Bot कंट्रोल की जाती हैं )
  • उसमे t.link होगी उस पर क्लिक करे
  • तो जो हमने अभी MyTestBot बनाई वह ओपन हो जाएगी
  • अब स्टार्ट पर क्लिक करे
  • और कोई भी मैसेज टाइप करे तो Telegram Bot आपको Hello के बाद आपका नाम और फिर आपका मैसेज शो कर देगा
Telegram Bot Auto Reply Using PHP

Why Telegram bot not working in group ?

  • Bot बनाने के बाद आपको /mybots टाइप करना हैं , उसके बाद आपको आपके द्वारा बनाई गई Bot को सिलेक्ट करना हैं , जब आप Bot select करेंगे तब वह पर Bot Setting option आएगा , आपको Bot Setting पर Click करना हैं क्लिक करने के बाद Allow Group Option आएगा, आप जैसे ही इस पर Click करेंगे आपकी Bot Groups के लिए भी Enabled हो जाएगी ।

Telegram bot commands list

  • Telegram Command लिस्ट देखने लिए आपको Bot Father open करना होगा , वहाँ पर Menu दिखाई देगा, वहाँ से आप सभी Command की लिस्ट देख सकते हैं।

Best Telegram Bots :

  • आप यदि इस तरह से telegram auto bot बनाएंगे तो यह best telegram bots होती ओर साथ ही मे best telegram bots for groups के लिए भी यह आपको मदद करेगी । आप इसकी सहायता से auto reply to chat messages कर सकेंगे । यह बहुत बड़िया telegram bot example हैं ।

Telegram Bot List

  • पहला तरीका : Telegram bots list देखने के लिए आपको Bot Father ओपन करना होगा और Menu मे जा कर Edit Your Bots पर क्लिक करना होगा
  • दूसरा तरीका : आप Bot Father open कर /mybots भी टाइप कर सभी bots की लिस्ट देख सकते हैं ।

How to Create Bot in Telegram Group

  • Telegram Bots for Groups : आपके द्वारा जो bot बनाई गई हैं यदि उसे ग्रुप मे add कर लिया जाए तो वह Group मे भी Reply का कार्य प्रारंभ कर देगी ,
  • Telegram Bot Add User to Group : जैसे की हम किसी ग्रुप मे person को add करते हैं वैसे ही हमे bot को add करना होता हैं ।
  • Telegram Bot Send Message to Channel : यदि हम किसी Channel मे bot को add करेंगे तो वह उस Channel पर भी Reply करने लगेगी।

Telegram Auto-reply iphone

  • यदि आप एक बार Telegram पर Bot बना लेते हैं तो वह फिर सभी मोबाईल पर telegram reply bot का कार्य करती हैं । यदि आपने bot android मोबाईल से बनाई हैं ओर आप auto-reply iphone पर चाहते हैं तो भी वह Proper Reply करेगी ।

Telegram Bot in PHP (Telegram Bot Auto Reply PHP)

  • User का ऐसा लगता हैं की telegram bot php मे बनती हैं जबकि ऐसा नहीं हैं । telegram webhook के द्वारा हम अपने server की लिंक को Telegram Web Hook पर connect कर देते हैं , फिर आपको server किसी भी technology का हो वह जब भी कोई msg या आपने जो भी programming की हैं उसके अनुरूप आपके द्वारा दी गई लिंक को Call कर देता हैं , इस तरह आप एक telegram chat api in php मे बना सकते हैं । एक तरह से हम इसे telegram bot api भी कह सकते हैं ।

How to Send Message in Telegram Group

  • आप जब भी Bot को Telegram Group मे add कर देंगे तो यह Bot स्वतः ही Message कर Replay या आपने जो भी Programing की होगी उसके अनुसार करना करने लग जाएगा ।

Article कैसा लगा Comment जरूर करे, अपना कीमती समय देने के लिए धन्यवाद् ।

Single Meaning of Multiple Words

  • how to create bot in telegram
  • how to make a bot in telegram
  • how to make a bot on telegram
  • how to make a telegram bot
  • how to make a telegram bot send messages
  • how to make bot in telegram
  • how to make bot on telegram
  • how to make bots in telegram
  • how to make telegram bot
  • how to make telegram bot reply
  • how to make telegram bots









Add a Comment

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