99 seconds to make bitcoin call your phone number
Using Gitlab-CI with IFTTT (Illustrated step by step)

Level : All levels
Requirements : Any web browser
[Unedited]
Got 99 seconds? cool, Let’s get bitcoin to call your number.
We explained previously how to create periodic jobs, then how to create a webhook using Gitlab-CI, now is the time to connect it to IFTTT; the well known automation service. This tutorial assumes that you NEVER looked at the previous tutorials and will guide you from the very beginning to create a bitcoin price alert, the easy way.
When the price of bitcoin is between certain price levels, Canadian Dollars, an alert will be posted to IFTTT service, IFTTT of course can ring your number, email you , post to social media in your behalf, or trigger 100s of other connected smart devices and services.

I though it would be fun to get a phone call when the price of bitcoin reaches a certain level, but if you don’t have a US based phone number, it’s also trivial to configure IFTTT to instead send you an email, tweet in your behalf or even change the colour of your smart lights.
Let’s get you started
Here is what’re going to do at IFTTT side:
- We will create a free account to create an IFTTT Maker applet that will receive the price alert from gitlab
- Get an IFTTT key so we are able to trigger it from gitlab
A Gitlab side :
- Create a gitlab project with 2 files to retrieve bitcoin price and post it to IFTTT
- Select a daily schedule to run this on Gitlab-CI
- Create a free account at IFTTT (5 seconds)
- Create a new applet: (28 seconds) click on my applets














3. Get your IFTTT Webhook receiver key : (10 seconds) We’re not done yet with IFTTT, the last step is to get the KEY that we will use at Gitlab to trigger our applet. You have 2 options to get the key:
- Either browse directly to this URL : https://ifttt.com/services/maker_webhooks/settings
- Or the other way is to click on the Webhook icon in the applet we’ve just created


Your key (a hash of digits and charcters) is the last part of the URL that you see in the following format:
https://maker.ifttt.com/use/MY_IFTTT_KEY

We’ve created the applet, but let’s test that it works, browse to this address you see displayed in the above page (instead of MY_IFTTT_KEY you will see your actual IFTTT key): https://maker.ifttt.com/use/MY_IFTTT_KEY

If all goes according to the plan, this test should show a success message and trigger a phone call to your number, an email or a tweet, depending on the choice you’ve made earlier in step 2. If the test was successful, move on to the next step, otherwise go through the above steps again and make sure that you followed each step.
Copy your key, it will be displayed at the top of the page above in place of MY_IFTTT_KEY, we will need it for the next step.
Congrats, you’re done with the demanding part, from here on it’s easy going.
If you have followed the instructions in one of these previous tutorials or the other and have created a project in gitlab, then you just need to go back to your project in Gitlab and take alook at step 6 below to edit the btc-price-alert.sh file, and look at step 7 to save your IFTTT key as a Secret Variable in Gitlab , if this is your first run, no worries, we will go through the gitlab part again step by step.
here we go:
4. Sign in (or create a new account) at Gitlab.com (10 seconds)
5 . Create a new Project : Click on New Project button to create a new repo, in the name field type btc-webhook or any other name. (9 seconds)

Then save it By clicking on Create Project (1 second)


6. Create a btc-price-alert.sh file in this new project : Click on New File, copy and paste the following snippet into the btc-price-alert.sh file then click save (10 seconds)

#!/bin/bash echo 'request Bitcoin price'; btc=$(curl https://min-api.cryptocompare.com/data/price?fsym=BTC\&tsyms=CAD)
echo 'removing all non digit from the response' btc=${btc//[^0-9\.]/}
echo 'Bitcoin price is CA$ '"$btc"
echo 'removing decimals from the price' btc=${btc%.*}
echo 'checking if the price within the defined range'
if [ "$btc" -ge 10000 -a "$btc" -lt 14000 ]; then echo 'price is within range, will also post to IFTTT' curl -X POST \ https://maker.ifttt.com/trigger/BTC_PRICE_EVENT/with/key/$IFTTT_KEY \ -H 'Content-Type: application/json' \ -d '{"value1": "Bitcoin price is CA$ '"$btc"'"}' else echo 'Price is not within range, no alert posted this time'
fi
This will check if the price of bitcoin above CA$ 10,000 and less than CA$ 14,000 . feel free to customize it or switch the currency from CAD to USD, EUR or your local currency if supported
7. Save your IFTTT key as a Secret Variable in Gitlab : now you will need your IFTTT key that you copied from step 3 above. (5 seconds)


8. Create another file, call it .gitlab-ci.yml file : (10 seconds) Click on the home menu icon to go back to your project’s home page.



test:
script:
- bash btc-price-alert.sh
this is a simple commands, to run the bash file that we’ve created
Click on the Commite changes button, this will trigger it to build and run.
9. Schedule it to check price everyday : click on the CI/CD icon to expand the menu, select Schedules to set up a name and a timer for your webhook to trigger. (11 seconds)




Congrats! you’re done. if the price within the range you’ve specified, this webhook will post to IFTTT Webhook Receiver and trigger the action that you have defined in your IFTTT applet (a phone call, an email or a tweet)
But that’s not all, now that you have an IFTTT Webhook Receiver triggered by the price of bitcoin, you can use the same Webhook Receiver to create other IFTTT applets which triggers any of the other IFTTT services.
This job will run everyday as long as your free 2000/month build minutes do not run out.
In a previous tutorial I’ve explained that sometimes you won’t be able to use IFTTTT, either because the trigger you want is not available, or because of the cap limits on the number of actions imposed by IFTTT.
This is why in the next tutorial, instead of posting to an IFTTT applet, we will go old school and have Gitlab-CI post directly to a service of our choice. We will have Gitlab send out a Telegram message, either directly to you, to a Telegram group or a Telegram channel.