Building my first telegram bot and it’s going to be quite complex.
Part of workflow needs to open a webview within telegram that will require user interaction, return to bot chat altering chat with data received from user.
Reading through the entire api, SO, github, I’m having trouble finding anything about the viewing webpages, much less if we can interact. Before I get deep into this project it would be awesome to have some starting direction.
-
Can you create web views (like you see for “instant view” articles, google maps, etc), and if so can you get data from user to use back at the chat bot?
-
Another option is possibly using a “game”. In our case, it won’t be a conventional game, but maybe we could use the html5 game to render what we need, and interact with the user. I know it can pull scores, names, etc to update message, maybe we could somehow make this work?
I’m currently working through the api. This is one of my first apps, and my first telegram bot. I really appreciate any assistance on how to get started here.
This is in Rails, using https://github.com/telegram-bot-rb/telegram_bot_app as a starter. Mostly needing to know if this concept it possible, but anything more specific would be great, too. Thanks!
2
Answers
You can’t create web view with the bot API and you don’t need to do that. You can simply link to a web page using simple links or inline buttons and the page will open in Telegram’s inline browser (Depending on user’s settings).
If you include the user ID in the URL you will know who is using the webpage. e.g example.com?uid=1234
Now that you know who is using the webpage, you can use the ID to send messages or anything else in Telegram chat while user is on the webpage.
At the end you can redirect the user back to your bot URL (telegram.me/botusername).
Update
You can now use Seamless Telegram Login to link to a web page and log in the user. This feature can also be used in groups
Try the new Telegram Web App API
It can open a web page on the bottom sheet, which you can expand almost to the full screen.
You can configure the web app open button by following these steps: