You can use iHook to monitor the weather forecast data by consuming the OpenWeather API. In this example, we'll create an iHook task that sends you an email notification when it's going to rain.
1. Create a free OpenWeather account
First, register a new OpenWeather account here. The API key will be sent to you in a confirmation email. You'll need this API key to call the OpenWeather API. You may also find your API keys under the account page.
2. Create an iHook scheduled task
After logging into the iHook dashboard, click the
CREATE TASK button at the top left corner, then you will see the task creation form:
Request Settings and
Request Schedule sections, provide the following values:
|Task Name||Weather monitor||The name of the task|
|URL||https://api.openweathermap.org/data/2.5/onecall?lat=YOUR_LATITUDE&lon=YOUR_LONGITUDE&units=imperial&exclude=current,minutely&appid=YOUR_API_KEY||OpenWeather API that returns weather forecast for the upcoming days. |
|Request Headers||None||No headers are needed|
|Request Schedule||Every 1 day||The task will run once every day|
This task fetches the weather forecast data from the OpenWeather server once every day.
3. Create email notification
The API response body carries the weather forecast data in JSON format. Next let us set up an email notification so we can get notified when it's going to rain. In this case, we will check the
weather object under the
daily section in the response body.
Notification section, click the
ADD button next to the
Then a notification setup dialog will show up:
Then provide the following values in the dialog:
|Source||Parse the API response as JSON|
|JSON path||JSON path of the weather property for tomorrow|
|Your email address|
|Subject||The email subject|
|Message||You can leave this field as-is||The email body|
This tells iHook to send an email notification when the OpenWeather forecast data indicates that it's going to rain tomorrow.
SAVE, you will see the new email notification appear under the
4. Save task
CREATE button at the bottom of the task creation page:
You'll see the created task in
5. Test task
To make sure your task settings such as URL and notification rules are properly configured, it's recommended to test your task at least once.
You can perform the test by clicking the
TEST button at the top of your task page. The
TEST button will trigger the HTTP request right away, and evaluate all configured notification conditions.
If everything went smooth, you should see the weather data appear in the
Response Body section of the execution detail:
Notification Status section of the execution history page, you can check the
conditionEvaluatedResult to make sure the JSON path is evaluated properly.
Congratulations! You can now sit back and wait for the iHook email notification when it's going to rain.