Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

245
Views
Telegraft (Javascript) : How do I return the function in telegram keyboard or inline keyboard?

I want to return a function I tried replacing the "Yes" It doesn't work, when I look at the function itself, it only accepts string,

thus I'm puzzled, because if I use bot.hear in telegraf, any person who says yes, will activate the command.

is there anyway to call a function ?

 bot.command("report", (ctx) => {
            ctx.reply("Are you sure? using this will have a refresh timeout of 2 minutes.", {
                reply_markup: {
                    keyboard: [
                        /* Inline buttons. 2 side-by-side */
                        [{ text: "Yes", callback_data: test() }, { text: "No", callback_data: "No" }],

                        /* One button */
                        [{ text: "Next", callback_data: "next" }],

                        /* Also, we can have URL buttons. */
                        [{ text: "Open in browser", url: "telegraf.js.org" }]
                    ]
                }
            });

        });
    const test = () => {
       console.log("test")
    }

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!