Saeed Heidarizarei
Saeed Heidarizarei

Reputation: 8916

Telegram Bot Send PDF File via Node.js

I'm Trying To Send a File With ID But does not Work For Some Files, I'm Using node-telegram-bot-api module.

bot.sendDocument(msg.chat.id, "BQADBAADFAADAllAUeZn_0YHHRjNAg");     //ok
bot.sendDocument(msg.chat.id, "http://kmmc.in/wp-content/uploads/2014/01/lesson2.pdf");//ok

bot.sendDocument(msg.chat.id, "BQADBAADAgAD8jBJUZjgAdwyxsADAg")  //  Not Ok

I Have This Error:

Unhandled rejection Error: 400 {"ok":false,"error_code":400,"description":"Bad Request: Wrong file identifier/HTTP URL specified"}

Upvotes: 0

Views: 6767

Answers (1)

Saeed Heidarizarei
Saeed Heidarizarei

Reputation: 8916

Telegram reference: Here
Sending by file_id,
file_id is unique for each individual bot and can't be transferred from one bot to another.

Do these steps:
1: Send a PDF file to your bot.
2: Get that file id via forwarding to raw bot (@RawDataBot) or ...
3: send via node-telegram-bot-api Module.
Example:

bot.sendDocument(msg.chat.id, "BQADBAADAgAD8jBJUZjgAdwyxsADAg") 

Upvotes: 2

Related Questions