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
-
Create a telegram account if you don't have one. Then start a conversation with @BotFather and send the /newbot command. Save the token you receive somewhere safe, we'll use it later.
-
To get your user ID, talk to @GrammyOnDetaBot and send the /me command. Save your user id somewhere for later.
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
:
BOT_TOKEN
should be the bot token that you saved from step 2(required).
The resulting .env
file should look like this:
BOT_TOKEN=...
ADMIN
should be the the user ID that you saved from step 2(not required).
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:
- Clean your root folder of any build outputs
- Push your environment variables to Deta
- Deploy your app on Deta
- Clean your root folder of any build outputs again
That's all!!!