Upload a file in a Telegram Bot

(Daniel Beckett) #6

You would need a New File Trigger:

And then a HTTP request (I’m using the GET method where I send the value in the URL, e.g. ?file={{new_file.file_url}})

The last part really depends on what you’re doing at the webhook end point so I can’t really give an example but if I was sending from Flow XO to Flow XO then the output would look something like this:

Upload Image with telegram
(Antonio) #7

Hi Daniel,
in my screen does not appear such a choice you indicated
I see the following choices:

???

(Antonio) #8

how can I implement this??

(Antonio) #9

EUREKA,
Finally I found it !!!
I had to start a new flow! Instead I was trying to add the upload file to my existing flow!!!
Ok, now Telegram api is receiving the upoladed file …

but still does not work ! see the output

What am I missing in the http request settings??

(Antonio) #10

Hi Daniel,
I must be wrong somewhere in my logic.
I do not understand how do I have to set the HTTP Request with post method, in order to let file be uploaded into my server.
The script responsible for the upload work is named “upolad.php”. I pass it, with its complete url path, in the HTTP setting:

then, in the settings, I indicate the file to be uploaded:

So in my bot I attach a file (which is correctly passed to Telegram Api) but I do not find it in my server’s folder where it is supposed to be moved by the php script.

I really do not understand how to proceed.

(Sarah Palombo) #11

From what I can see the URL is taken from the task ‘New file’ and passed into the Make a HTTP Request
In the HTTP settings, you’d use {{new_file.file_url}} rather than {{allega_file.file_url}}

You can always share your flow if this hasn’t helped (support@flowxo.com)

I’ll help :slight_smile:

Sarah

(Antonio) #12

Hi Sarah,
thanks for your reply.
allega_file.file_url is correct because I changed the flow name:


that’s why my Make a HTTP Request settings is:
.

How can I share my flow with you? I did not find any command to do that.

(Karen Barker) #13

Hi @ansfo2013

I see you’ve sent this into our support team so we’ll take this over to email now to try and get to the bottom of the issue :thumbsup:

(Dima Azizbekov) #14

Why this method doesn’t working yet?

(Daniel Beckett) #15

@_dima Which method are you referring to? You can use the New File trigger to capture files. Have you ran into a certain issue with one of your flows?

(Dima Azizbekov) #17

@DanielBeckett I created new flow with Webhook. When Webhook Accepted, I took WebHook Url and than created new flow with new file. Repited all what you did. Whan I checked Interactions of Flow with New File(after sending image to bot direct) in utput I saw “Success” with 200 only. When I checked Global Interactions, there my Flow with Webhook runed too. There I saw “No input and output data”. In your example there must be import URL of my sended Image. I don’t know why your example doesn’t work now. I did it before, but now it doesn’t working. Can you help me with it?

(Daniel Beckett) #18

Sorry, that’s not too clear what’s going wrong. Could you perhaps share some screenshots of the errors that you’ve seen?

If it’s easier, you can email support@flowxo,com and we’ll pick it up from there.

(Dima Azizbekov) #19

@DanielBeckett I sent all about it to your support email.

(Tô Huy) #20

Hi @DanielBeckett,
I user “Make a HTTP Request” for upload image.
But It return ESOCKETTIMEDOUT.



Please help me.

(Tô Huy) #21

Oh, I resolve it. Thanks

(Seve Ho) #22

Hello @To_Huy Can you please share your solution? Or at @DanielBeckett or anyone of the support team can you please provide documentation of how to get the FormData object of an uploaded file so that I can use it inside a webhook?

(Daniel Beckett) #23

Hi @SeveHo

To capture an uploaded file you’ll need a flow that’s using the ‘New File’ trigger. In that flow, once a file has been uploaded there will be an output for the file URL that ca be used in other actions.

Is that what you’re looking for?

Thanks,
Dan

(Seve Ho) #24

Hi @DanielBeckett,

kind of.
In order to upload the file to an other destination I need something like a Blob, FormData or File object. So I’m struggling with figuring out on how to get an object like this from the file url.
If I do a GET request on the file url I get the raw file inside the body of the response. But after that I dont’t know how to use the raw body to upload the file again as multipart/formdata to a desired destination.

Regards,

Severin

(Sarah Palombo) #25

Unfortunately you can’t access any objects or data to be able to ‘get the file’

When the new file is triggered, The only outputs available are:
File URL
File Type
file_name
file_extension": “pdf”,
file_type": “application/pdf”,
file_size": 83453,

The way to do this, is to have an online service that you can use to forward the file URL. this service would then need to get and save the file. To_Huys screen shot above shows that he’s forwarding a file using the HTTP service (which is the right way). I don’t know what kind of services there are to suggest unfortunately but that would be the idea :slightly_smiling_face:

Sarah

(Seve Ho) #26

Ok thanks for the help!

How long are the files saved on the server?
And it would be also nice to have some kind of protection so that only bot owner can access the files related to their flows. Something like an access secret.