I am attempting to send a message/photo message after a successful payment has been made, but I am thrown the following error:
Error: Telegraf: "replyWithPhoto" isn't available for "pre_checkout_query::"
My code as follows:
bot.on('pre_checkout_query', (ctx) => {
ctx.answerPreCheckoutQuery(true)
.then(() => {
let photo = //setup photo...
let options = //setup caption and image url...
ctx.replyWithPhoto(photo, options)
})
})
Is there absolutely no way to follow up with some message after a successful payment has been made via the Telegram Bot API?
EDIT:
bot.on('pre_checkout_query', (ctx) => {
let data = ctx.update.pre_checkout_query
ctx.answerPreCheckoutQuery(true)
.then(() => {
let message = 'Thanks for the purchase!'
bot.telegram.sendMessage(data.from.id, message)
})
})
2
Answers
Managed to figure out how to do it thanks to this post.
To send a message after the 'You have just successfully transferred $XXX to ...' banner, we need to listen for
successful_payment
message. Here's the implementation:You can use
Telegraf.telegram.sendMessage(chatId, text)
to handle this orTelegraf.telegram.sendPhoto(chatId, photo)
to reply with photo