Receive an email when the Bitcoin value changes

This tutorial is a complete example showing how to get a value from the cloud and email it.

This example gets the bitcoin value every minutes and sends an email when the price of bitcoin has a significant change.

Inject

First, add an inject node and edit it to repeat the injection every minute.

Double click it to edit its values.

Request bitcoin value

Next, add httpRequest node in the section functions :

To request the following address:

Compare with the last value

Now, add a function node which takes only the price of bitcoin and compare with the last value.

To do this, the value is saved in a context variable at the beginning and the flow sends an email if there is a big difference (100 $).

// Create the bit coin context
context.bid = context.bid || 0;

var obj   = msg.payload;
var rates = obj.USD.global_averages;
var bid   = rates.bid;
//var ask = rates.ask;

if ((bid >= (context.bid + 100)) || (bid <= (context.bid - 100))){
    var Newmsg = { payload: "ALERT new bid : "+bid };
    context.bid = bid;
    return Newmsg;
}

Send an email

Add an email node:

Add to whom send the email, the user email address with his password and his service.

The final flow

This is the final flow :

Back to top