Telegram Botapi, Send Message to Multiple Chat_Id

Telegram BotApi, Send message to multiple chat_id



There is no way to make bot to sendMessage to multiple chat id but there is a trick that can fix it for now :)

Why not sending each chat id a message ?!

Let's look at this example in PHP :

<?php
$message = "Hi John";
$chatIds = array("xxx","xxx","xxx"); // AND SOME MORE
foreach($chatIds as $chatId) {
// Send Message To chat id
file_get_contents("https://api.telegram.org/botTOKKEN/sendMessage?chat_id=$chatId&text=".$message);
}
?>

Reply to multiple users telegram (Message Id) PHP Bot

each message has a different id, and you should reply to each message of any user separately.

https://api.telegram.org/mytoken/sendMessage?chat_id=user1ID&parse_mode=HTML&text=test&reply_to_message_id=user1MessageID
https://api.telegram.org/mytoken/sendMessage?chat_id=user2ID&parse_mode=HTML&text=test&reply_to_message_id=user2MessageID

telegram api send message to specific user

You cannot send a user specific message in a group. Still you have other options:

  • Send a link to the group and mention the user to start your bot with that link for their message
  • Send a message with inline button that would only work for that specific user. Then when the user clicks on that button, a callback alert appears with the message.

How to send '#' to chat with Telegram bot API?

You did not url-encode the string properly, it should be

Hello%20%23%20World

Instead off

Hello+%23+World

The complete url:

https://api.telegram.org/bot<TOKEN>/sendMessage?chat_id=<CHAT-ID>&text=Hello%20%23%20World

Sample Image

Python / Send message to specific telegram user?

you already have a bot and its token

after that you need to get the chat_id:

  1. write message in the chat
  2. Visit https://api.telegram.org/bot<YourBOTToken>/getUpdates and get the chat_id under the key message['chat']['id']
    import requests

def telegram_bot_sendtext(bot_message):

bot_token = ''
bot_chatID = ''
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + bot_chatID + '&parse_mode=Markdown&text=' + bot_message

response = requests.get(send_text)

return response.json()

test = telegram_bot_sendtext("Testing Telegram bot")
print(test)

more info - https://medium.com/@ManHay_Hong/how-to-create-a-telegram-bot-and-send-messages-with-python-4cf314d9fa3e

Send Telegram bot messages with formatted text

Use one * instead of two as detailed in the official documentation.



Related Topics



Leave a reply



Submit