Usage • Configuration • Deployment • Technology Used • Contributing • Contributors • Credits
The application is powered by Github Actions to automatically push weather notification to a personal telegram bot at specific intervals. It is built on Javascript making use of NodeJS libraries.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
You will need the below installed on your computer
- Git git@2.17.1 or higher
- NodeJS (which comes with npm) node@v12 or higher, npm@6.9.0 or higher
- Telegram Desktop or Telegram App
$ git clone https://github.com/richierich25/weather-bot.git
$ cd weather-bot
$ npm i -
Create a file called
.envin the root directory of your project. OR Note: Instead of creating a.envfile, create a replica of theenv.examplefile provided$ cp env.example .env
-
Inside the
.envfile, add keyWEATHER_API_TOKENobtained from OpenWeather App. One must create an account and copy the API Key from My API Key Section.WEATHER_API_TOKEN = "YOUR OPEN WEATHER API TOKEN HERE"
-
Inside the
.envfile, add keyTELEGRAM_TOKENandTELEGRAM_CHAT_IDobtained from Telegram Bots App. Follow the below steps:- Click BotFather and open in either Telegram Desktop or Mobile App(search for
@BotFather) - After opening it, press
startand type/newbot - Provide a name and a username for the bot. ensure it ends with
botat its end, for instanceRichierich25_bot - It will provide a link to the newly created bot and provide the
HTTP API KeyorTELEGRAM_TOKEN. Open the link provided. important as the bot has to be started for it to receive messages later - Press
startor to start chatting with the newly created bot - To obtain the
TELEGRAM_CHAT_ID, search for the@get_id_botaccount and pressstart - it will provide you your chat id
TELEGRAM_TOKEN = "YOUR TELEGRAM TOKEN HERE" TELEGRAM_CHAT_ID = "YOUR TELEGRAM CHAT ID HERE"
- Click BotFather and open in either Telegram Desktop or Mobile App(search for
-
Inside the
index.js, set theidcorresponding to your city obtained from here.- Enter your desired city name and press
search, for instance,Delhi - Open the first link that pops below
- Now from the URL, obtain the id of the format
https://openweathermap.org/city/1273294where 1273294 will be the ID corresponding to the city
weatherURL.searchParams.set('id', '1273294'); // use the desired id here
- Enter your desired city name and press
When you are done with the setup, and have tested locally, we recommend you to deploy it using Github Actions. We highly recommend to read through the Using Github Actions docs.
-
Inside the
.github/workflows/run-weather-bot.ymlfile, set the desired time interval in CRON FORMAT after which you wish the Application to execute and push further notificationsschedule: - cron: '0 */3 * * *' #after every 3 hours
-
Adding API Tokens and Secrets into the repository
- Open your repository with the application code
- Click on
Settingsfrom the Github Menu options - Press
Secretsfrom the left section - Press
New Secretand add your tokens one by one by giving it a suitableNameandValue - Add
WEATHER_API_TOKEN,TELEGRAM_TOKENandTELEGRAM_CHAT_ID
- NodeJS
- Javascript
If you wish to contribute and make it much better for other developers, please have a look at Issues.
- Add UI for selecting custom City
- Customize the message notification
If you can help us with these. Please don't hesitate to open a pull request.
We encourage you to contribute. Please check out the Contributing guide for guidelines on how to proceed.
![]() Richard Abraham |
- Original Idea from Kristian Freeman


