node-telegram-bot-api-tutorial icon indicating copy to clipboard operation
node-telegram-bot-api-tutorial copied to clipboard

response with Web app button on inline query

Open chillbert opened this issue 1 year ago • 0 comments

how can I reply with the web app button of the bot?


    const results = JSON.stringify([
      {
        type: "article",
        id: "1",
        title: "Echo: " + queryText,
        input_message_content: {
          message_text: "You said: " + queryText,
        },
      },
    ]);

    /* something like this????
    const results = JSON.stringify([
      {
        type: "article",
        id: "1",
        title: "Echo: " + queryText,
        input_message_content: {
          message_text: "You said: " + queryText,
        },
        reply_markup: {
          inline_keyboard: [
            [
              {
                text: "Open Web App",
                web_app: { url: "https://testbot.github.io/TONBot?id=32" }, // Web App URL
              },
            ],
          ],
        },
      },
    ]);
*/
    try {
      /* await sendMessageWithWebAppButton(
        chatId, // you don't have chatID on inline only on message
        "Open Web App using the button below:",
        "https://testbot.github.io/TONBot?id=32",
      ); */

      await fetch(
        `${telegramApi}/answerInlineQuery?inline_query_id=${queryId}&results=${results}`,
      );

      res.sendStatus(200);
    }

chillbert avatar Jan 24 '24 01:01 chillbert