This is a template to deploy a telegram bot using grammY and deploy it on Deta using typescript
Click the Use this template
button to have your copy, clone the newly generated repo locally and do your changes as you see fit.
-
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.
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=...
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.
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
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!!!