Skip to content

Template to fork telegraf prisma postgresql telegram bots

Notifications You must be signed in to change notification settings

HavenOfExcellence/telegraf-PostgreSQL-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Template-telegram-bot

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.

Getting started with template

Click use this template to create a new Repo for your new telegram bot

Setup environment

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)

Nodejs

The main engine the bot runs on is nodeJS. There is a Youtube Video on how to setup Typescript with Nodejs & Express(not required)

NodeJS Download

Database

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.

PostgreSQL Download

Developing

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

Production

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

Resources

Telegraf

Prisma

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

Built with

Telegraf Prisma PostgreSQL

Hosted on Heroku

About

Template to fork telegraf prisma postgresql telegram bots

Topics

Resources

Stars

Watchers

Forks