Closed moshed closed 1 year ago
Files can be downloaded automatically if you configure the download directory in the receiver node. Please provide more information: what was received in your case?
in my case I am looking to download the file id only when requested. for reference I am trying to build a voice transcriber that can be set to transcribe all voice notes sent to a group or only when tagged. So if someone tags a voice note I would like to pull the weblink from the replied to message (containing the voice note) by using getFile and the file_id and send that file to the transcriber.
as you mentioned I can save the links to to every voice note ever sent but that seems a bit heavy handed.
Well this is not possible right now but i can add thst function if you need it
I would love that! thanks so much for your quick response!
Please open it again so that I wont forget it
re-opened. thanks!
should be fixed in 11.6.0 see examples folder
@windkh is there a way to just return the url path of the file? My workaround has been to send an http request using the file_id
with the url 'https://api.telegram.org/bot[token]/getFile?file_id=' + file_id
which then returns msg.payload.result.file_path
which I can then download or send directly through the api without having to download the file to my local device
@moshed I am not sure, but this feature is there for ages. I just had a look at the sources and yes, the link can be found here: msg.payload.weblink. The link is valid for one hour.
@windkh the weblink is available only when you receive the initial message but I am trying to get the filepath after the original message was already been sent. (I am trying to transcribe a voicenote when a user responds to the voice note with a /transcribe
command)
If you send an http request to 'https://api.telegram.org/bot[token]/getFile?file_id=' + [file_id]
you will receive a JSON object with msg.payload.result.file_path
this is what im looking for so I can send this url directly to the transcribing service I use without downloading locally to my device.
Understood. But you need to store the file_id anyway from the original message to be able to later on respond to the command. How should your command node return a weblink without knowing the file_id? Or do you need a new file node then? For downloading just blobs via a file_id?
How should your command node return a weblink without knowing the file_id?
the file_id
is returned in the object when a user replies to a message in msg.originalMessage.reply_to_message.voice.file_id
. So if a user replies to a message with /transcribe I would be able to fetch the file_id and use that to return the weblink
Or do you need a new file node then? For downloading just blobs via a file_id?
A new node might be helpful. Not sure. what im looking for is the same functionality provided by the https://core.telegram.org/bots/api#getfile endpoint so that I could return the weblink without having to download the file locally to my device.
hey @windkh any update on this? sorry to bother you. if you're not interested in implementing this thats totally fine!
I thought that this was already closed... just to be sure what you mean: you want to convert a file_id to a weblink?
should be included in next version see getfile.json example
@windkh appears to be a typo in the example you used gefile (with no t) but on read me you use getfile. When I trying using gefile I get nothing, it just outputs the same message from the sender node with added key value of gefile.
When I trying using getfile I receive below error
"TypeError: Cannot read properties of undefined (reading 'fileId')"
using https://github.com/windkh/node-red-contrib-telegrambot/blob/9e69fd871fbe98521fe8a9287bb092a448eed67d/README.md#downloading-files-manually works as intended do I know there is no issue with the file_id
I thought that this was already closed... just to be sure what you mean: you want to convert a file_id to a weblink?
yes this is exactly what I want
@windkh sorry to be a nudge but can this be reopened? it seems the getfile method doesn't work due a typo as mentioned in previous comment
Thanks, I fixed the typo.
if you call getfile then a property weblink is added to the msg.payload.weblink. You can forward that one.
This is exactly the example which is can be found here https://github.com/windkh/node-red-contrib-telegrambot/blob/master/examples/getfile.json
I am trying to get the the weblink for a voice message the someone responds to the message but currently can only pull the file_id. is there any way to manually trigger the getfile API so I can pull the weblink?
https://core.telegram.org/bots/api#getfile