Is there any way to send a voice command to Telegram bot?
I want to send voices to my bot and use google API to convert them to text and then translate and send back.
In order to do this, I need to get the voice first. Is there any way to send the voice to the bot?
You can find file_id from Voice update, and then obtain download path via the getFile method.
This object represents a file ready to be downloaded.
The file can be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>.
In above instance, you can download from https://api.telegram.org/file/bot485609210:mySecret/voice/file_178.
You can send a voice message to the bot, which would be stored on your server. Than convert it to text using Google API, translate and send back. Do you want to send it back as text?
Related
My organisation is using Google Chat for internal communication. In one of the group in the app I am sending the report of daily automation test run using webhook. Currently the report consist of only text message containing the pass/ fail count.
But I want to send the html report as well with that. I could not found any source which tell the information about how to send the attachment in the bot messages in Google chat.
Please help me if someone knows how to send the attachment report using Google Chat Bot or Webhook.
Per documentation, Bots have limited message types they can send. (Only simple text, or Cards)
I would suggest sending a link to download the report, which is feasible with the bot. See Including links in message text
I am using telethon and I have a question that how telegram knows where to send the request?
I have created a bot on telegram. When the user sends a message to the bot then how telegram knows where to redirect that message. I run my program in my local and also on a server. But in the code, we don't mention anything about the server. But the program is working fine on it also.
Need to understand the flow.
Telethon uses what’s called MTProto to communicate with Telegram servers. It connects just like an actual client would (like TDesktop or Webogram, for instance). Once the connection is made, instead of using a phone number, the authentication is made with the bot token. Then, everything else is standard procedure: Ask Telegram for any new message and Telegram responds with all the messages people sent to the bot or to groups your bot is in (if you have that enabled through BotFather). To cut down on traffic, if there’s an open connection, Telegram may send updates automatically.
That’s the general process flow. For more in-depth explanation of how MTProto works, all the technical information is available on their website. The portion about updates is here: https://core.telegram.org/api/updates
Every handler have an arg, i named it here event , e.g:
#client.on(events.NewMessage)
asynce def handler(event):
This event have all information in it, text of message, message id and etc.
There is an applet which allows to send text messages from telegram to some email. Unfortunately there is a limitation: it only works with text.
I would like to have the same functionality, but for images, video and may be audio. I suppose media content should be attached to the email.
Is there a tool for this task? If no, what is the easiest way to implement it?
You need split this idea to a few and search for each of following topics:
echo bot using python-telegram-bot
python-telegram-bot and Telegram object types (photo, video, etc.)
how to send email using python and SMTP
how to add attachments email using python
After that you'll be able to understand what else is missing.
I have developed a chatbot in Telegram to get user's photo sent using the following API:
https://core.telegram.org/bots/api#sendmessage
And able to get the file use the following API:
https://core.telegram.org/bots/api#getfile
However, the file downloaded lost the EXIF attributes. Is telegram strip all the data? Or is there any way to get the original file?
No there is no way to get original image. Telegram optimize photo for user display.
but if user send the photo as file (document) then you can get the image without any change/optimize from Telegram.
I am working on an telegram bot, and looking for the exact URL schema to popup the "Share / Select Group / Send to" dialogue in the telegram client.
I have seen this link in #pollbot, for which I took following screenshots.
A bit more details:
What I want is to give end-user an easy way to add the bot to their group, just like what PollBot does: When a poll being created, PollBot will return a special like to the user. Any by clicking that link, the user could easily add PollBot to a group. So I'm looking for the exact URL schema of that link.
I then check that link PollBot sent to me in telegram web client, and found out it's a tg protocol url: tg://resolve?domain=PollBot&startgroup=5148bed5f90678b93246464b3e132052. So I tried to resend this url via bot.sendMessage. But it turned out Telegram api server won't parse the tg://resolve url.
So, how could the bot manage to send such a link to the user?
The link there works with deeplinking, please read about it here:
https://core.telegram.org/bots#deep-linking
the url has the following scheme:
https://telegram.me/<YourBotUsername>?startgroup=<Payload>
the startgroup part (parameter) of the url tells telegram to open the 'add to group' dialog.
when you choose a group there (and you can add bot's to it) the bot will be added to the group and /start PAYLOAD will be send to that group.
The Payload is what you defined as value of the startgroup parameter, so your bot can assosiate it with something and send the matching reply.
please mind, that the Payload can only contain certain characters and don't mind that the telegram clients might internaly convert that link to an tg:// url.
you can also use start instead of startgroup to open a private chat.