Create your first task
A CronDog task allows you to schedule HTTP requests and receive notifications when response conditions are met. This tutorial shows how to create a CronDog task and get an email notification when the Bitcoin price drops below a chosen level.
1. Set up HTTP request
After signing into the CronDog dashboard, click + New task on the All Tasks page. The task creation form opens with Request, Schedule, and Notifications sections.
Under the Request and 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 |
| Schedule | Every 5 minutes | Select the Every schedule option, then choose 5 minutes |
With this setup, the task issues a GET request to CoinDesk's Bitcoin price API every 5 minutes.
2. Set up 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 CronDog can also send notifications by SMS, Slack, or HTTP request.
Under the Notifications section, click Add next to the Email label. The Add email notification dialog opens.
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) | |
| Value | 6000 | Check if Bitcoin price is lower than $6,000 |
| To | [email protected] | The email address to receive notification when the condition is met |
Click Save. The new email notification appears under Notifications with its Condition, Email, and Actions.
3. Save task
Now your task is ready. Click Create at the bottom of the page.
After the task is created, CronDog opens the task detail page. The header shows the task name, a status control that reads Active, and the Settings and History tabs.
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 happens? This is where Run now is helpful. The Run now button triggers the HTTP request right away and sends notifications when the configured conditions are met.
Let us pick a Bitcoin price that is higher than the current price for testing purposes, say 200000. In the Settings tab, go to Notifications and click the pencil icon in the email notification's Actions column.
Change the notification value from 6000 to 200000, then click Save. Now the task should be able to send an email notification when the Bitcoin price is lower than $200,000.
Click Run now at the top of the task page. The task page switches to the History tab, where you can check the HTTP request status in real time. Within a few seconds, you should see the execution status turn into SUCCESS.
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 value back to 6000, and then click Save.
Congratulations! You've successfully set up your first CronDog task as a Bitcoin low price monitor!
