skip to Main Content

I’m making a telegram bot with telegraf frame work ( it means Node.js )
So I want when someone send good morning The bot will reply to his own msg, I searched alot but i didn’t find the answer

Example:-
I want the reply to be like this

enter image description here

2

Answers


  1. The documentation for telegraf is here: https://www.npmjs.com/package/telegraf

    From what I have read, this should work:

    const { Telegraf } = require('telegraf')
    
    const bot = new Telegraf(process.env.BOT_TOKEN)
    bot.hears('good morning', (ctx) => ctx.reply('Good morning to you too!'))
    bot.launch()
    
    // Enable graceful stop
    process.once('SIGINT', () => bot.stop('SIGINT'))
    process.once('SIGTERM', () => bot.stop('SIGTERM'))
    

    This is edited code from the first example in the docs.

    Login or Signup to reply.
  2. You can do something like

    bot.command(key, (ctx) => {
        ctx.reply('A Reply', {
            reply_to_message_id: ctx.message.message_id
        })
    })
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search