I tried to use update.sendDocument(chat_id = update.message.chat_id, document = open(something.pdf, 'b'))
but it did not return me a pdf file. Any help?
Question posted in Telegram API
A comprehensive official documentation can be found here.
A comprehensive official documentation can be found here.
2
Answers
For reference, here’s a full working example, that worked for me.
If it still doesnt work, ensure that the pdf docs you send are below 20 MB
as per https://core.telegram.org/bots/api#sending-files
To send document to user you must have the
file_id
of that document.Assuming that the user sent the document to
bot
and you want to send back to user, this is my solution:And on
def main()
you must add:With this last line, your
bot
will understand that when user send it a document, and only a document, it will calldef file_handler
.