Answer the question
In order to leave comments, you need to log in
How to pass arguments to action function via callback_data in telegraf js?
you need to pass input parameters to bot.action via callback_data
bot.hears('all users chat with phone number', async (ctx) => {
const allChats = await mongoMessages.find().exec()
const keyboardArray = new Array()
allChats.forEach(chat => {
keyboardArray.push([ { text: `${chat.userName}: ${chat.phoneNumber}`, callback_data: `findUserByPhoneNumber` } ])
}),
ctx.reply('all users:', {
reply_markup: {
inline_keyboard: keyboardArray
}
})
})
bot.action('findUserByPhoneNumber', async (ctx) => {
console.log(ctx)
const chat = await mongoMessages.find({ phoneNumber: ctx.message.text }).exec()
ctx.reply(chat)
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question