Creating a WebApp
#
Setting Up a YoPhone WebAppFollow these simple steps to unlock the full potential of WebApps:
Create a YoAI Bot.
** Create a new web app entering /newapp command in YoAI
Develop the WebApp.
- Use standard web technologies (HTML, CSS, JavaScript) to build the WebApp.
- Access the YoPhone WebApp API via window.YoPhone.WebApp.
Host the WebApp.
Example Code.
#
Here is a basic example of initializing a YoPhone WebApp:<!DOCTYPE html><html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>My WebApp</title> <script src="https://webapps.yophone.com/js/yophone-web-app.js"></script> </head> <body> <h1>Welcome to YoPhone WebApp</h1> </body></html>
- Security Considerations.
- Always validate initData on your server to prevent spoofing.
- Use HTTPS to serve the WebApp.
- Restrict access using YoPhone user authentication.
By following these steps, you can build interactive and engaging experiences inside YoPhone using WebApps.
Passing Custom Start Parameters
You can pass custom start parameters to your WebApp by appending them to the WebApp URL using the
start_param
query string.Example:
https://webapps.yophone.com/SomeBot/SomeWebApp?start_param=someData
Inside your WebApp, the parameter will be accessible via:
window.YoPhone.WebApp.initDataUnsafe.start_param;