Node-telegram-bot-api: Users send me a message and I reply to him

Created on 15 Feb 2017  路  4Comments  路  Source: yagop/node-telegram-bot-api

How Can I Take Users Messages and reply to him?
This is my Code:

bot.onText(/\Contact Us/, function ContactUs(msg) {
  const opts = {
    reply_to_message_id: msg.message_id,
    reply_markup: JSON.stringify({
      keyboard: StartKeyboard,
      resize_keyboard:true,
      one_time_keyboard: true
    })
  };
  bot.sendMessage(msg.chat.id, 'Please Write your Messages:', opts);
});
question

All 4 comments

@saeedhei Sorry for the long time take to respond. I will have to respond to this at a later date with a more complete solution that will work for you.

Hi @saeedhei,

Maybe this will fit your needs? Actually I am stuck with the kinda the same question right now and this is what I've came up with that far:

bot.onText(/\Contact Us/, function ContactUs(msg) {
  const opts = {
    reply_to_message_id: msg.message_id,
    reply_markup: JSON.stringify({
      keyboard: StartKeyboard,
      resize_keyboard:true,
      one_time_keyboard: true
    })
  };
  bot.sendMessage(msg.chat.id, 'Please Write your Messages:', opts)
    .then(() => {
    bot.on('message', function(reply) {
// do some stuff with reply.text
})
})
});

UPDATE: check out the issue GochoMugo/tgfancy#5. Am addressing it there.

Solved, You Can Find Awnser in This Link.

Was this page helpful?
0 / 5 - 0 ratings