When developing bot for Telegram is there any way to get user timezone? Date field in Message object contains UNIX timestamp only. I want to create bot sending some messages an fixed time of day to subscribed user. User can have different time zones and I don't want to force users to explicit send their timezone to bot in message.
It's imposible by standard Bot API.
You can ask user for location, and next, from this location calculate timezone for user.
I've added /set_utc_offset command to my bot where users enter the time difference in minutes compared to UTC
Related
Today when I as usually run my client to read income messages of my Telegram Bot I get the error
{"ok":false,"error_code":401,"description":"Unauthorized"}
I had been successfully used Telegram API every day during a year and never seen this error. I also didn't change any settings
What may happened?
At the page https://core.telegram.org/api/errors I read it's possible to get more detailed error description like AUTH_KEY_UNREGISTERED, AUTH_KEY_INVALID, USER_DEACTIVATED and so on.
But how can I do that?
Is it possible just to add something in the address bar to the request like https://api.telegram.org/bot<MY_TOKEN>/... ?
It may be helpful for someone.
I was not using my main account of Telegram associated with my phone number more than a year. That's why Telegram deleted my main account and accordingly my Telegram bot.
I have an email application where you can see mails in threads view or mail view. I would like to provide information to the business whether users are using mail client with threads view or mail view. The problem is mail application can run for days and weeks before any user interaction. if I send GA event when the user switch to thread/mail view that event can be registered for the day it was sent (lets say it is 1st of January) but the client can keep looking at the mail list for a month. Lets say business guys make a query for the last week of January the event won't be counted and they won't know there was an active user.
My solution is to send this event every day by some time service which will monitor for day changes but I think there could be better solution to this problem and you can tell me about it
I've been using a Telegram BOT to send notifications for a group, and for users.
I already know i can get Chat ID by receiving a message from the user on my bot, using getUpdates.
I also know i can get Group ID using the same method...
But what i really need is:
There is three users in my group.
My bot.
Me.
Another user that didn't sent any messages to my bot so it does not appear on getUpdates
Is it possible to get this third user his ID?
PS: I am the group owner, and also added my bot as Admin...
The third user is a normal user.
Can someone help me?
Thanks!
That's not possible with the offical Telegram Bot API
Possible Workarounds:
Hold a list of your own. If a user is joining (new_chat_member), lefting (left_chat_member), somebody is sending a message in the group, and so on. Check Message for more information.
Check if a user is a member of the group with getChatMember.
Also may be helpful: getChatMembersCount and getChatAdministrators
I know that a telegram bot can't start conversation with the user. So user should click "/start" first. But for how long bot can respond to the user after the last message? Do any limitations exist like 24/48 hours?
Do any limitations exist like 24/48 hours?
No. After a user starts a conversation with a bot, the bot can send messages to that user until one of the following actions occur:
User 'Stop and blocks' the bot (See picture below)
User account gets deleted
For example, using the Desktop version, the user can 'Stop and block' a bot by pressing the following button:
I'd like to set up a authentication through telegram using it's deep linking api.
In order to authenticate, in my app I ask users to click on a link like:
https://telegram.me/myloginbot?start=somesecretkey
If I understand the docs correctly, I should expect the bot to echo back somesecretky to my server.
Now, this step of the docs is unclear to me:
Configure the webhook processor to query Memcached with the parameter that is passed in incoming messages beginning with /start
If I understand correctly, I need to configure myloginbot so that when the user clicks start button on the bot's page, the bot echos back to my server a url containing somesecretkey and some user info. But I don't know how to do so.
In this answer, it is suggested that:
Let the bot retrieve the username by querying the database or key-value storage for unique_code.
But I don't know how can I make the bot query the (presumably remote) database.
So really appreciate your hints.
My understanding to deep linking is this:
You have a database of users. Each user has an ID. Suppose you want your Telegram bot to communicate with user 123. But you don't know his Telegram chat_id (which the bot needs in order to send messages to him). How do you "entice" him to talk to the bot, thus revealing his chat_id? You put a link on a web page.
But the link has to be "personalized". You want each user to press on a slightly different link, in order to distinguish them. One way to do that is to embed user ID in the link. However, user IDs are not something you want to expose, so you generate a (temporary) key associated with each user ID, and embed that key in the link. For example, user 123 has the key abcde. His personalized link will be:
https://telegram.me/myloginbot?start=abcde
Someone clicks on the link, and is led to a conversation with your bot. At the same time (or when he presses the START button), your bot will receive a message:
/start abcde
On receiving that message, the bot sees that abcde is associated with user 123. Telegram chat_id can also be extracted from the message. Now, the bot knows user 123's chat_id, and can send him messages afterwards.
To experiment with deep linking, you need a bot that can handle /start messages, supported by a "datastore" that remembers the key-ID associations. When Telegram docs say "memcache", they just mean something that stores the key-ID associations. For an experiment, it may be as simple as a dictionary, or an associative array. In real life, it may be Memcached (the memory caching software), or a database table.
If you use Python, I recommend taking a look at telepot, a Python framework for Telegram Bot API. It does not do deep linking per se, but it does help you in receiving messages for a bot, and other bot operations in general. I also have an example there demonstrating how to output a personalized link, set up a webhook, and parse the incoming /start command with the key.