Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to reply a photo with caption in nodejs telegram bot (telegraf)

I'm writing a telegram bot with telegraf. I want to send a photo with a text under it in the reply message. I have written this:

    serviceDetailsScene.on('callback_query', async ({replyWithPhoto}) => {
        await replyWithPhoto({url: <url>})
}

It works and sends image properly, but I don't know how to append the message to it.

Thanks for any help.

like image 430
Kamran Hosseini Avatar asked Oct 15 '25 22:10

Kamran Hosseini


1 Answers

You can do this for replying with image src and caption:

bot.hears('photo', ctx.replyWithPhoto({ source: <pic-src> }, { caption: "cat photo" });

And if you want to send image url you can write this:

bot.hears('photo', ctx.replyWithPhoto({ url: <pic-url> }, { caption: "cat photo" });
like image 102
Mohamed Jawad Avatar answered Oct 18 '25 13:10

Mohamed Jawad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!