ZedByl / profile-telegram-mini-app

Home Page:https://profile-telegram-mini-app.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Profile Tg Mini App

Bot

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.

Requirements

  • Telegram Bot
  • Ton Api
  • NodeJs (Latest LTS version recommended)

Getting Started

  1. Prepare Environment Variables
  2. Deploy
  3. Init Telegram Bot API Webhook

Environment Variables

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 like https://<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 as my-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 example https://t.me/<your-bot-name>

Deploy

You need to deploy your app on a platform or a server of your choice.

Deploy on Vercel

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.

Deploy on Server

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.

Run Locally for Development

Set environment variables then run:

npm run dev

Or

docker-compose -f docker-compose-dev.yml up

you can use https://ngrok.com/

Init Telegram Bot API Webhook

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.

About

https://profile-telegram-mini-app.vercel.app

License:MIT License


Languages

Language:TypeScript 89.6%Language:SCSS 8.5%Language:JavaScript 1.5%Language:Dockerfile 0.2%Language:Shell 0.1%