This repository contains a Telegram bot implemented in JavaScript, deployed using Netlify and AWS Lambda Functions.
- Node.js installed locally
- A Telegram bot token obtained from BotFather
- GitHub account for version control
-
Clone the repository
git clone https://github.com/yourusername/telegram-bot.git cd telegram-bot
-
Install dependencies
npm install
-
Configuration
- Rename
.env.example
to.env
and replace<your_bot_token>
with your Telegram bot token obtained from BotFather.
- Rename
-
Create a new site on Netlify
- Login to Netlify and select "New site from Git".
- Choose GitHub as your Git provider and select the repository where you pushed your bot code.
-
Environment Variables Setup
- Navigate to your Netlify site dashboard.
- Go to "Site settings" > "Build & deploy" > "Environment" > "Environment variables".
- Add a new environment variable:
- Key: BOT_TOKEN
- Value: Your Telegram bot token obtained from BotFather.
-
Deploy
- Click on "Deploy site" in the Netlify dashboard.
- Verify deployment status (ensure it shows "Published").
-
Configure Telegram Webhook
- Replace
<your_bot_token>
and<your_site_name>
in the following URL:For example:https://api.telegram.org/bot<your_bot_token>/setWebhook?url=https://<your_site_name>.netlify.app/api/bot
https://api.telegram.org/bot5594307469:AAEx9aeF6KeOMaQeAGJ79xa-tAB5RkWOdlg/setWebhook?url=https://venerable-alfajores-c6f46a.netlify.app/api/bot
- Replace
-
Verification
- After navigating to the generated URL, you should receive a response:
{"ok":true,"result":true,"description":"Webhook was set"}
- After navigating to the generated URL, you should receive a response:
- Send
/start
command to your Telegram bot. It should reply with a message such as "Hi" indicating it's working correctly.
- If deployment fails, check the deployment logs in Netlify for errors.
- Ensure environment variables are correctly set in Netlify and triggers a redeploy if updated.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Have questions, suggestions, or want to collaborate? Feel free to reach out to me at mehmetabak@proton.me. We'd love to hear from you!
This project is licensed under the MIT License.