How to Send Yourself Weather Info of a City via Telegram

Using the WhatsMate Telegram Gateway REST API

Posted on September 21, 2016

Last Modified: March 31, 2017

This article shows you how to write a simple Python script to retrieve the weather condition of a city from Yahoo APIs and send it to yourself.

Before you can receive the Telegram message, you will need to register with the WhatsMate Telegram Gateway. Instructions are available on the official site. Unregistered users will never receive messages from the Gateway.

Prerequisites:

You have access to a Linux (such as Ubuntu) machine.

Your machine has Python and the requests library installed.

You know some basic Python. Actually, it’s alright even if you don’t because our code looks like simple English.

You know how to set up a cron job. Actually, it’s alright even if you don’t because we will tell you how.

Steps:

Take a look at this script: weather-reminder-via-telegram.py. It gets the current weather information of Mountain View in California and sends it to a designated Telegram number.

Customize the script to your liking. At least, specify your target number on line 52.

Take note of the location of your script. For example: /home/pikachu/weather-reminder-via-telegram.py