I’m developing a Telegram bot in nodejs. I create an instance of node-telegram-bot-api and I’m using the method on(‘photo’) to manage if a user sends a photo to my bot.
The problem is when a user sends more than one photo together by multi selecting photos from the gallery because my bot responses as many times as the photo sent. I think that this happens because the bot executes the on(‘photo’) method as many times as the photo sent.
bot.on('photo', function (msg) {
var fileId = msg.photo[2].file_id;
bot.downloadFile(fileId, folder);
bot.sendMessage(chatId, "I got the photo", keyboard);
bot.sendMessage(chatId, "Do you want to go to the next step of the procedure?", keyboard);
//I would like that the bot sends the last message only once
I would like that the bot responses just one time.
Do you have any suggestions?
2
Answers
You can check if the response is photo second time.
you can ask user if wants to use latest photo or the old one