A simple Telegram mini app that lets you take notes.
- Text formatting capabilities.
- Supports Telegram entities: usernames, hashtags, and others.
- Ability to share the notes as Telegram messages.
The front end is powered by React and Lexical. The back end persists data in a PostgreSQL database, and can host a Bot API webhook at the same time.
To work on this project, you first need to:
-
Install Git, Deno, Node.js, and optionally pnpm if you don’t already have them. Docker will also be needed if you don’t already have a PostgreSQL server running and you want to follow the guide here to setup one.
-
Have a bot with a Web App configured properly. We’ll guide you through this, so you don’t need to worry it for now. All you need is a Telegram account.
If you don’t already have access to a running PostgreSQL server, you can start one using Docker this way:
docker run -d --name notes-app_postgres -p 127.0.0.1:5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust -e POSTGRES_DB=main -d postgres
This will pull a recent version of the postgres image and start an instance of it under the name notes-app_postgres and start listening for connections on localhost, port 5432. The URI for connecting to it would be postgresql://postgres@127.0.0.1/main.
- Clone the repository.
git clone --depth 1 https://github.com/roj1512/notes-app.git
- cd into the clone and create a .env file.
cd notes-app/
touch .env
- Add the required variables to the .env file you just created in the following format.
BOT_TOKEN=1234567890:ABCDEFGHIJKLMNOPQRSTUVWXYZ
POSTGRESQL_URI=postgres://postgres@127.0.0.1/main
POLLING=1 # Whether to use polling
The BOT_TOKEN is the bot token @BotFather gave you. The POSTGRESQL_URI is your PostgreSQL connection URI, and it is postgres://postgres@127.0.0.1/main if you have set up your PostgreSQL server by following the above guide.
-
Open the Telegram app, and switch to test servers.
- Telegram Desktop: Open the menu using the button in the top left corner, right click Add Account while holding Alt+Shift, and choose Test Server.
- Telegram macOS: Sequentially click Settings in the tab bar until the debug menu opens, and click Add Account while holding Cmd.
- Telegram iOS: Sequentially tap Settings in the tab bar until the debug menu opens, open Accounts > Login to another account > Test.
-
Enter your phone number to sign up or log in.
-
Send /newbot to @BotFather, and answer the questions to create a bot.
-
Use the /newapp command to create a Web App. Choose the bot you’ve just created, follow the instructions, and when prompted for the URL, send the following URL.
http://localhost:3000
- Edit your .env to include the following variable.
TEST=1
- Since the app has features that leverage inline mode, you will also have to enable inline mode using the /setinline command.
-
Use a traffic tunneling service like Pagekite, Cloudflare Tunnel or ngrok to route a public https endpoint to your localhost:3000.
-
Send /newbot to @BotFather, and answer the questions to create a bot.
-
Use the /newapp command to create a Web App. Choose the bot you’ve just created, follow the instructions, and when prompted for the URL, send it the URL provided by your tunnel service.
-
Since the app has features that leverage inline mode, you will also have to enable inline mode. To do that, use /setinline.
- To watch the front end source and rebuild it on each change, open a terminal, cd into the app/ directory, install the dependencies if you haven’t already, and run the dev script.
cd app/ # Run this from the notes-app/
pnpm install # You can use any other package manager, but pnpm is recommended
pnpm dev
- To start the back end, open another terminal, cd into the app/, and run the dev task.
cd api/ # Run this from notes-app/
deno task dev
A publicly available image of this project can be found on Docker Hub.
- Copy docker-compose.yml to the machine where you plan to deploy the project on.
- Create .env file next to the docker-compose.yml, and specify the following variables.
# Only BOT_TOKEN is required.
BOT_TOKEN=1234567890:ABCDEFGHIJKLMNOPQRSTUVWXYZ
# The public https URL where the app will be available at. Recommended but not necessary.
WEB_APP_URL=https://your-domain.com
# You can also specify where the server will accept connections from. Don't forget to edit docker-compose.yml if you set a different port.
HOST=127.0.0.1
PORT=3000
- Create a volume named
notes-app
.
docker volume create notes-app
- Start the containers.
docker compose up -d
-
Setup a reverse proxy for localhost:3000 using a web server like NGINX or Caddy, connect it to your domain, and setup TLS.
-
Change the Web App URL in @BotFather to where your deployment is accessible from.
This project is licensed under the BSD-3-Clause license.