Co-WIN Vaccine Availability Checker — VacciDate | Part 3

Arpit Jain
4 min readMay 23, 2021

Hello again! We have come a long way. We saw how to set up Telegram BOT and Telegram Channel in Part 1 of this series. We also saw how to set up the codebase and schedule a cronjob on your local system in Part 2.

Part 1: Create a Telegram BOT and Channel

Part 2: Code setup and execution on Local system

In this article, we will move to the final part of this series and configure a free cloud instance to run our application on.

Part 3: Code setup and execution on Cloud instance

We talked about the challenges of running the BOT on your local system. Your job will stop if you turn off your system or your internet goes down. This makes our application prone to errors.

To make this solution reliable, you can put it on a cloud instance. I am using an instance from Linode. Linode provides you free credits of $100 for a period of 2 months. Open your free account on Linode from here.

Sign-up with your email id and create a new account. After you complete the process of account creation, navigate to the home screen of Linode and you will see an option to “Create Linode”. Click on that to get started.

Create Cloud Instance

  1. Choose a Distribution: Select the Image of distribution of your choice. We have selected “Ubuntu 20.04 LTS”
  2. Select Region: Select a region where you want your cloud instance to be hosted. Choose the one closest to you to reduce latency.
  3. Select Linode Plan: Select the smallest plan as our program doesn't need high storage or RAM. We have selected “Nanode 1 GB”
  4. Linode Label: Give a label to the Linode you created.
  5. Password: Set the root password and save it. We will need that when we ssh into the instance.
  6. Create Linode: Once all the steps are complete, click on “Create Linode” and wait for the instance to be provisioned.

Setup the Cloud Instance

  1. ssh into the created instance from your terminal. Enter the password you set at the time to instance setup when asked.
ssh root@ip_address

2. Once you are inside the remote machine, run the below commands to create a secondary user. Using root users always is not recommended.

sudo adduser newusername

3. select a new password for the user created.

4. Provide sudo access to the new user-created

usermod -aG sudo newusername

5. Exit out of the remote machine and now try to login using the new user name in place of root. Feed-in the new password when asked.

ssh newusername@ip_address

6. Once you are logged in with the new user created in step 2, run the below set of commands to initialize the setup.

sudo apt update && sudo apt upgrade -y

Setup Codebase on Cloud Instance

  1. Clone the GIT repo.
git clone https://github.com/arpitkjain7/VacciDate.git

2. Navigate to the folder where we have “env” and open it using “vim” editor. Update Telegram Bot token in “telegram_bot_token” and Telegram Channel Id in “telegram_chat_id”.

3. Install all the required libraries and load the environment variables using the below commands.

pip3 install -r requirements.txt
source ./env

4. Check the values to Token and Channel Id by running below command:

echo $telegram_bot_token
echo $telegram_chat_id

5. Now execute below command to start the program:

python main.py -d <district_id>

To get all the details on different modes available, refer to

Part 2: Code setup and execution on Local system of this series.

Schedule Cronjob on Cloud Instance

  1. Execute the below command on your terminal.
env EDITOR=nano crontab -e

2. This will open up a “nano” editor on your terminal. Enter the below command in the editor and save by pressing ^

* * * * * cd path_to_main.py_in_code_base && export telegram_bot_token="your_BOT_api_token" && export telegram_chat_id=channel_chat_id && /usr/bin/python3 main.py -d <district_id> -a <age_group> -dose <dose_number> >> path_where_you_need_your_log_files_to_be_saved 2>&1

The above command will execute “main.py” every minute. “* * * * *” is a special command, which executes the job every minute. Refer to the documentation for more details.

3. Get the list of scheduled jobs by executing the below command.

crontab -l

Conclusion

Congratulation!!! We have finally set up the VacciDate Bot for our location on Cloud Instance. You will now get notifications on your channel whenever the Vaccination Slot is available in your area.

Word of caution

  1. Keep your passwords and tokens safe.

2. Keep an eye on the usage of the instance and make sure you are not crossing the $100 free promotional limit on Linode.

Hope this series was informative and the Bot helps you get your vaccination slot soon. Stay Safe.

--

--