Web App
With web app you can render web content
Last updated
Was this helpful?
With web app you can render web content
Last updated
Was this helpful?
Therefore, for critical operations, always use webhooks instead of WebApp.
It is possible render text (html, css, js, json...) content to web. For example:
Go to bot and sent text webExample
. You will have link to this page:
It is possible to pass data from web via url params or via options on WebApp.getUrl
. For example your url is:
api.bots.business/v2/bots/BOT_ID/web-app/index?secret=SECRET
you can add data with:
api.bots.business/v2/bots/BOT_ID/web-app/index?secret=SECRET&key=value&another_key=another_value
In BJS you can access to this data via options:
It is hard to edit html in Java Script. Templates are a good way to organize your web application.
command "index.html
":
You can use bjs tag: <% your BJS code %>
in this template.
We have:
For example we can pass CSS file and test variable.
Command "index
":
command "index.html
":
command "renderCSS
":
command "example.css
":
Our result now:
Why Bot.sendMessage method is not working on Web App?
Bot.sendMessage - it is method for sending message to user in Telegram. The Web App is not a Telegram chat, so there is no user, chat, etc. - anyone can open this web app, the user can share it with other users, etc.
How i can make AJAX requests from my Web App?
This question is now about web development, not bot development. We have jQuery and other methods, libraries (the list is really long). You can include any external js library in your application and use it. Go to the Internet - there is a lot of information there and our help is not the place where this question should be covered
How to use BB Libs in Web App?
BB Libs - it is bot libs not Web app Libs. You can not use libs in Web App
How to display personal user's data on web page?
You need to pass this data via url:
So you will have this data in address and can extract it with JavaScript and window.location.search or etc.
If you want more data or if you need any dynamic content - you can use Webhook to bot (or another WebApp-endpoints) + AJAX requests.
Telegram have now. So BB supports Web Apps too.
WebApp is designed for working with HTML, JavaScript, and simple JSON requests. However, if you need to make important changes, such as transferring balances or assigning game points, use instead.
🔹 are secure URLs containing a secret key for validation. 🔹 WebApp is not protected—anyone can send any request to it.
Possible : text/css, text/csv, text/javascript, text/css, text/html, application/json and etc
You can install Web App in
For another ways please see Telegram
For sending message you need to pass chat id and use something like AJAX request to bot via (it can be more secure) or via another Web App endpoint with .