This template checks the price of Bitcoin over at CoinCap, and then sends either a buy or sell alert text based on the price. The Threshold Picker component is set by default to send a sell alert if btc is above $10,000, and a buy alert if btc is below $6,500.


In order for this template to fully run, you will need to enter a recipient phone number into the "Send SMS" components. It is currently set to run every 2 minutes.



This template contains a couple of new components relative to the first 2 templates. We have added a Timer trigger, which makes it execute every <x> time interval (ours is set to 2 minutes), a new external data provider, CoinCap ("Get Asset Details" for the current price of Bitcoin), and a "Switch", which we named "Threshold Picker".


The ability to add an external data provider, CoinCap, into a component is part of our secret sauce. They make an API available, and we were able to consume it and turn it into a component to be used by anybody, easily. Using CircuitBuilder, we are able to send a request to them and perform actions, giving conditions on what the response should be and under what circumstances. This "Get Asset Details" component returns far more than just the current USD price. Check out what it returns, and think about what else you could create with other data in the response!


{
  "data": {
    "id": "bitcoin",
    "rank": "1",
    "symbol": "BTC",
    "name": "Bitcoin",
    "supply": "18147212.0000000000000000",
    "maxSupply": "21000000.0000000000000000",
    "marketCapUsd": "147354905276.9069424942252440",
    "volumeUsd24Hr": "6712794774.5349678888395946",
    "priceUsd": "8119.9748631859782370",
    "changePercent24Hr": "6.9962539795441699",
    "vwap24Hr": "7895.7919346015900457"
  },
  "timestamp": 1578429397433
}

The "Threshold Picker" has multiple outputs, meaning that you can connect different components downstream based on specific conditions. The order of the outputs matches the order of the conditions inside the component. Check out the Settings page here:



When the line that is marked with the "0" is met, then whatever is connected to the topmost output circle from the component (check back on that first circuit shot) will execute, and when the lines that is marked "1" is met, whatever is connected to the second output circle will execute (etc etc).


This one says when Bitcoin's value is between $6,500 and $10,000, no text messages will be sent. If you want to see a text message get sent, double-click the Threshold Picker and set the thresholds to different values.


Let the circuit sit for a bit, and it will execute again. Every 2 minutes. Check out the top of the "Threshold Picker" and you will see the price of Bitcoin as of the last execution!