Acquire URL to upload a file to chat
To upload a file to chat you should follow these three steps:
- acquire URL for a file upload;
- upload a file to a previously acquired URL;
- send an uploaded file to a chat.
Acquire URL for a file upload
To get an URL you should use this method. No additional parameters are required to use it.
Upload a file to a server
To upload a file you should perform an HTTP POST request with request body containing your file to a previously acquired URL.
In case of IMAGE file type, token to be used for attachment creation is returned as response of file upload request.
See Step 2 – uploading photos via HTTP POST
Send an uploaded file to a chat
Some time needed by a server to process an uploaded file. File should be sent to a chat after a short timeout (a couple of seconds)
When a file was successfully uploaded you can send it to any available chat via graph.user.messages method.
A following structure with required type should be passed in attachment part of a request body: