Create your first task
An iHook task allows you to schedule HTTP requests, and receive notifications based on response condition. This tutorial will show you how to set up an iHook task, and get an email notification when Bitcoin price drops to a certain level.
1. Setup HTTP request
After signing into iHook dashboard, click the CREATE TASK
button at the top left corner. Then you will see the task creation form:
Under the Request Settings
and Request Schedule
sections, provide the following values:
Field | Value | Notes |
---|---|---|
Task Name | Bitcoin price monitor | The name of the task (optional) |
URL | https://api.coindesk.com/v1/bpi/currentprice.json | CoinDesk API for Bitcoin price |
Request Method | GET | |
Request Headers | None | No headers are needed |
Request Schedule | Every 5 minutes | The task will run once every day |
With this setup, you are telling the task to issue a GET
request to CoinDesk's Bitcoin price API every 5 minutes.
2. Setup notification
The above URL returns the following Bitcoin price data in JSON format:
{
"time":{
"updated":"Oct 25, 2020 18:16:00 UTC",
"updatedISO":"2020-10-25T18:16:00+00:00",
"updateduk":"Oct 25, 2020 at 18:16 GMT"
},
"disclaimer":"This data was produced from the CoinDesk Bitcoin Price Index (USD). Non-USD currency data converted using hourly conversion rate from openexchangerates.org",
"chartName":"Bitcoin",
"bpi":{
"USD":{
"code":"USD",
"symbol":"$",
"rate":"12,997.0150",
"description":"United States Dollar",
"rate_float":12997.015
},
"GBP":{
"code":"GBP",
"symbol":"£",
"rate":"9,962.8359",
"description":"British Pound Sterling",
"rate_float":9962.8359
},
"EUR":{
"code":"EUR",
"symbol":"€",
"rate":"10,956.3927",
"description":"Euro",
"rate_float":10956.3927
}
}
}
Let us set up a notification condition around the U.S. dollar property, so that we can be notified when Bitcoin price drops to our desired level. We'll choose email in this example, but you can also receive notifications via Slack.
Under the Notification
section, click on ADD
button next to Email
label:
Then a notification setup dialog will show up:
Then provide the following values in the dialog:
Field | Value | Notes |
---|---|---|
Source | Response Body (JSON) | Parse the response body as JSON |
Property | bpi.USD.rate_float | JSON path for the Bitcoin price property measured in U.S. dollars |
Comparison | less than (number) | |
Target Value | 6000 | Check if Bitcoin price is lower than $6,000 |
[email protected] | The email address to receive notification when the condition is met |
Click SAVE
, you will see the new notification appear under the Notification
section:
3. Save task
Now your task is ready, click CREATE
at the bottom of the page:
Then you'll see your task has been created and in ACTIVE
status:
4. Test task
Now you might be wondering: how do I make sure my task settings are properly configured, so I won't miss the Bitcoin price drop event when it actually happened? This is where TEST
button becomes helpful. The TEST
button will trigger the HTTP request right away, and send notifications when the configured conditions are met.
Let us pick a Bitcoin price that is higher than current price for testing purpose, say 20,000
. Under your newly created task, let us modify the email notification by clicking the edit button:
Change the Target Value
field from 6000
to 20000
, then click SAVE
. Now, our task should be able to send out an email notification when Bitcoin price is lower than $20,000. Let us see that in action. Now click TEST
at page top, the task page will switch to History
tab, where we can check the HTTP request status in real-time. Within a couple of seconds, you should see the execution status turn into COMPLETED
:
At this point, you should receive an email triggered by the task:
Nice! Looks like our notification logic is correct, now you can revert the email notification by changing the Target Value
back to 6000, and then click SAVE
.
Congratulations! You've successfully set up your first iHook task as a Bitcoin low price monitor!