Mini Profile is a project that allows you to create a mini app for Telegram, the messaging app with over 500 million active users, that connects to your TON Connect.
It uses Next.js, a React framework for building fast and scalable web applications, and the Telegram Bot API.
You can use this project as a template to customize your mini app with your own branding, products, and features, or modify the API to connect any other online store that supports RESTful web services. This project is open source and free to use. You can find the source code, documentation, and installation instructions here on GitHub.
- Telegram Bot
- Ton Api
- NodeJs (Latest LTS version recommended)
- Prepare Environment Variables
- Deploy
- Init Telegram Bot API Webhook
To use this project, you need to set the following environment variables:
NEXT_PUBLIC_BASE_PATH
This is the base URL of your deployment. For example, if you are deploying on Vercel, it can be something likehttps://<your-username>.vercel.app
.TELEGRAM_BOT_TOKEN
This is the access token that you get from @BotFather when you create your Telegram bot. -TELEGRAM_BOT_SECRET
This is a password that you set to secure your APIs. It can be any string, such asmy-pass
or a randomly generated hash. Please make sure to keep it secret. -NEXT_PUBLIC_TON_ADDRESS
This is you a wallet address to receive Ton. -NEXT_PUBLIC_TELEGRAM_BOT_URL
Url of your Bot. For examplehttps://t.me/<your-bot-name>
You need to deploy your app on a platform or a server of your choice.
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js. You need to fork this repository first.
Check out Next.js deployment documentation for more details.
If you prefer to deploy your app on your own server, you need to copy example.env
to .env
in the root of the project and fill the variables. Then, you need to run the following commands:
npm run build
npm run start
This will build and start your app on the port specified by the PORT
variable in .env
.
Set environment variables then run:
npm run dev
Or
docker-compose -f docker-compose-dev.yml up
you can use https://ngrok.com/
This is the last step! You need to set up a webhook for your Telegram bot to receive updates from Telegram. To do this, you just need to make a POST request to the following URL:
curl -X POST https://<your-deployment-url>/api/telegram-hook/init?secret_hash=<the-secret-password-from-env-var>
Replace <your-deployment-url>
with the base URL of your deployment and <the-secret-password-from-env-var>
with the value of TELEGRAM_BOT_SECRET
in your environment variables or .env
.