You can use bot.on listener with message("text") or any other filter
Note
bot.on("message"|"other_type") has been deprecated. It may be removed in future versions. So prefer new filters.
You can see all available filters here or your code editor will suggest you.
Here is an example how to use filters
import { message } from "telegraf/filters";
bot.on(message("text"), async (ctx, next) => {
// next is added because other listners below this wont work if await next(); is not added
await next();
});You can also add multiple listeners using array like given below:
bot.on([message("text"), message("photo")], async (ctx) => {
ctx.reply("Received Text or Photo");
});You can check if ctx has a filter like this.
if(ctx.has(message("text")){
ctx.reply("It is text");
}
else if(ctx.has(message("photo")){
ctx.reply("It is photo");
}