I create a bot, add that bot to my group and now I can send messages to group via api:
https://api.telegram.org/bot' + token + '/sendMessage' + '?chat_id=' + chat_id + '&text=' + text
And that message is visible to everyone in a group.
How can I send a message in a group that is visible only to a specific user (I have a user id)?
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.
Related
Hi I am trying to build a website login system where users are able to log in using their telegram. I would like to achieve this workflow:
User selects to login/sign up via telegram.
User enters their username (#ExampleJoe).
A 6-digit verification code is sent to them via my Telegram bot (#ExampleBot).
The user enters the received 6-digit code into my website and is allowed to enter.
I have issues with steps 2-3 where my bot can send them a direct message (not in a group chat) with only their username. I am aware that sendMessage method in the Telegram bot API requires a chat_id and that a user_id is also suitable. However, I do not know how to get the user_id with just the user's username.
That's not possible with the Bot API. You'd have to use a userbot for that. Note however, that TG provides a native login widget that you can use instead.
I'm working on a project where the user enters their phone number on a website. And the conformation is done through a telegram bot, which the user initiates a conversation with first. The user sends the confirmation code displayed on the site to the bot.
So here is my question, is there any way that I can compare the phone number the user provided with the confirmation code message the user sent to the bot? Or is there any way that I can get the user_id from the phone number, the user provided, so that I can compare it with the message sent by the user?
You can send Keyboard with request_contact=True that will ask user to share phone number (documentation).
Then your bot can get an Update with it (example how to do that) and compare with desired phone number.
I just need that my telegram bot would sent a message to my e-mail. For example, my bot has a form that user need to fill out, and I just want to get results from bot to be appeared in my e-mail. The form of the bot was developed in ManyBot. I have found several results on passing e-mail message into telegram
Now I need to send the message to the people:
That we custom their properties.For example whether the email is activated after they register,if they have activated the email then they can receive the notification but the inactivated one cant,we set the properties when the user login their account ,if the first one who has already activated their Email ,then if we send the notification that with that receiver who activated email tab ,then the phone can receive notification .and then we changed the account that haven't activated the email,then send the same notification ,and then the phone still can receive the notification ,and also if we send the message in a not activated email tab ,the phone cant receive the notification.
I want to the the reason of this problem and the ways of solve it .
Thank you for your help.
Edit:
if someone have registered through some specific key like email which will be stored in my database...i could send notifications to them..!
I want to say to clients to start my chat bot and send me username and password, then I store chat_id of them, and use it whenever I want to send a message to one of them.
Is it possible? or chat_id will be expire?
If the chat_id is the same as the Telegram user_id for that client, then yes you can.
SendMessage:
chat_id [Required] [Integer] Unique identifier for the target chat
text [Required] [String] Text of the message to be sent
If you want to identify each user with a unique constant you can use user_id.
user_id: User identifier in Telegram.
chat_id: Unique identifier for the target chat.
user_id and chat_id wil never expire or change on Telegram. But a user may use your bot from a private chat or from a group. You may get two different values from the same user. So i suggest you to use user_id to do that.
When a user register on telegram, server choose a unique chat_id for that user! it means the server do this automatically. thus if the user send /start message to your bot for the first time, this chat_id will store on bot database (if you code webhook which demonstrates users statastics)
The answer is if the user doesnt blocked your bot you can successfully send him/her a message. on the other hand if the user had delete accounted no ways suggest for send message to new chat id!
i hope you got it 😉