How to know telegram web app opened from an inline button, was closed?

Viewed 31

I successfully open a web app using an in-line button from my Telegram bot. When the "work" is complete in the web app, it persists the data to a DB via an API call and then closes itself (the web app) using Telegram.WebApp.close(). Upon the closing of the Web app my bot then needs to automatically refresh some information shown in the private chat from where the web app was launched.

Question: How can my bot know that the web app has been closed? Or how can I send a "notification" from the web app to the bot to let it know that it should refresh the data.

Supposedly I should be using answerWebAppQuery but search as I may, I cannot find any examples of how to use this. The closest example I could find is "In our case, we need to send data via answerWebAppQuery, without any servers, using the bot API: https://api.telegram.org/${yourBotToken}/answerWebAppQuery, options. You will need query_id from initData to send data using this approach.". I tried it and it just gives a 404 error.

I would appreciate any help or pointers to where I can find the info I need.

0 Answers
Related