All of the code is written in typescript which is similar to javascript but is type safe. Watch this Youtube Crash Course if you are not familiar.
Click use this template to create a new Repo for your new telegram bot
See .env.example
for example on how to set up your .env
file. Remember to not commit .env
into version control. Read more on .env
Set up env variables in heroku (Production)
The main engine the bot runs on is nodeJS. There is a Youtube Video on how to setup Typescript with Nodejs & Express(not required)
As this bot has a database to read and write information into, you need to set up either a local development database or use your production database for your development work. The latter is not recommended in-case you wipe your production database and cause the bot to lose all memory.
npm install
to install the dependencies
npm run dev
to run the bot in development environment
npm run migrate
to generate a new database migration based on the current database schema
We run the bot on a heroku dyno for free as it also provides free PostgreSQL dB.
Downside of heroku will be how the app will go to sleep if nobody is using, takes <30s for a telegram bot to boot up once someone sends a message to the bot
Article on how to setup free Heroku PostgreSQL
npm run build
to push the dB schema onto the production server and compile the code
npm run start
to start the compiled code
This two commands will be ran automatically by heroku once it receives the code
- Github Repo
- Getting started
- API reference
- Telegram group for Telegraf
- GitHub Discussions
- Dependent repositories
The fastest way to get started with Prisma is by following the Quickstart (5 min).
The Quickstart is based on a preconfigured SQLite database. You can also get started with your own database (PostgreSQL and MySQL) by following one of these guides:
- Heroku plans and pricing
- Link Github Repo to Heroku so that it will automatically push the changes made
- Heroku Command Line Tools (CLI)
- Get Heroku Logs (1500 lines max)
- Heroku Config Vars (
.env
)
Telegraf Prisma PostgreSQL
Hosted on Heroku