Home

Awesome

Grammy Bot on Deta.sh Template

This is a template to deploy a telegram bot using grammY and deploy it on Deta using typescript

How to use

Click the Use this template button to have your copy, clone the newly generated repo locally and do your changes as you see fit.

Configuration

Step 1. Create a Deta Account and Install Deta cli locally

Step 2. Get your Telegram bot token and your user ID

Step 3. Setting Up Environment Variables

Copy the .env.example file from this directory to .env (which will be ignored by Git):

cp .env.example .env

Then set each variable on .env:

The resulting .env file should look like this:

BOT_TOKEN=...

The resulting .env file should look like this:

BOT_TOKEN=...
ADMIN=...

Step 4. Run grammY in development mode

npm install
npm run dev
# or
yarn install
yarn dev

Your bot should be up and running on http://localhost:8080! If it doesn't work, post on GitHub discussions.

Create a Deta.sh micros

As of now, you have yet to link your local to a micros on Deta cloud:

npm run build
deta new -n
#or
yarn build
deta new -n

Deploy Your Local Project

To deploy your local project to Deta, simply run the deploy command:

npm run deploy
#or
yarn deploy

This will do 3 things for you:

  1. Clean your root folder of any build outputs
  2. Push your environment variables to Deta
  3. Deploy your app on Deta
  4. Clean your root folder of any build outputs again

That's all!!!