Tutorial: How to Create Customizable Alerts with Whale Alert’s WebSocket API & IFTTT

Whale Alert
10 min readSep 6, 2023

--

Whale Alert is famous for its crypto alerts on Twitter and Telegram, but as a trader or developer you might be interested in alerts for different coins or alerts that don’t show up there very often. With our new WebSocket API developers can now create their own custom alerts for their favorite assets and set their own value limits. You could create alerts for every SHIB burn for instance or any ALGO transfer above $10,000. You can also get the alerts that show up on our social media if you’d like to do something cool with those.

In this tutorial, we’ll walk you through integrating our API with IFTTT to create a versatile alert system. Want to receive an SMS or email when a big transfer happens for your favorite coin? Or maybe you want to post alerts in a Discord chat? You can even make your smart home do cool stuff like change the color of the lights in your room or play a custom sound on your smart speakers when a big coin burn happens. This tutorial will guide you through the entire process of creating your own alerts setup.

This is what it will look like when we are done:

Whale Alert API -> Our Tutorial Program -> IFTTT

Prerequisites

  • An IFTTT account: Don’t have one? You can make one for free here.
  • Whale Alert Alerts-plan: We offer a 7 days free trial. Sign-up here.
  • Some Programming Knowledge: You should know some basic programming.
  • Optional: a Raspberry Pi or Digital Ocean account in order to receive alerts even when your computer is turned off.

IFTTT Setup

IFTTT (If This Then That) is a powerful platform that lets you automate tasks between different apps and services. Simply put, IFTTT makes different apps talk to each other. In this tutorial, we will use IFTTT to send an email each time an alerts is generated by our Go-based Whale Alert client. Sending an email is just one of the things it can do. You can check out other other things it can connect to here.

We will start by setting up IFTTT to receive the alerts and send an email.

Setting up Webhooks in IFTTT

  1. Log in to IFTTT: Go to https://ifttt.com/join and join IFTTT if you haven’t already.
  2. Create a Trigger: Navigate to https://ifttt.com/create and click on “Add”. Choose “Webhooks” from the list of available services. Then choose the option named “Receive a web request”.
  3. Connect: If this is your first webhooks applet you will have to click “Connect” now.
  4. Configure Webhook: You’ll be prompted to configure the webhook. For the event name, enter whale_alerts. This name will be used in your Go code to identify which IFTTT event to trigger. Click on “Create Trigger” once done.
  5. Set up an Action: After setting the trigger, click on “Then That” to set up the corresponding action. We’ll choose Email as the action. This means you’ll receive an email every time a Whale Alert is triggered. You can always go back and choose another action here.
  6. Format the email: Choose “Send me an email”. Copy and paste the following into the “Subject” field:
    New Whale Alert ({{Value2}} {{Value3}} )
    And the following into the “Body”:
    {{Value1}}
    Click “Create Action” and then “Continue” to save your changes.
  7. Finalize the Applet: Review your configurations and click on “Finish” to create the IFTTT Applet.

Retrieve Your Webhook URL

  1. Go to IFTTT Webhooks Settings and click Connect if you haven’t already connected Webhooks to your IFTTT account.
  2. You should now see your unique Webhook URL. It will look something like https://maker.ifttt.com/use/YOUR_UNIQUE_KEY_HERE.
    Note: Save this key somewhere, as we will use it in our Go client to send POST requests to IFTTT.

Whale Alert API Setup

Getting access to the Whale Alert API is the next step in building your custom alert system. Follow these steps to get an API key:

  1. Log In or Sign Up: If you’re new to Whale Alert you can sign up here.
  2. Choose Your Plan: Subscribe to the Alerts Plan, which comes with a 7-day free trial. You will need a credit card for this step, but you can cancel anytime but still enjoy the trial period.
  3. Generate API Key: Once subscribed, you can create an API key which we will use later on.

Creating and Running the Client

Now let’s build a small program that listens for crypto alerts from Whale Alert and forwards them to your IFTTT setup, which will then send you the alert through email.

We’ll use Go, a programming language made by Google, for this. You can run this on your own computer, or keep it going 24/7 using a cloud server or a Raspberry Pi.

Running On Your Computer

The easiest way to get started is by running the program on your own machine. Just note that alerts will stop if you turn off your computer or close the program.

For this part we assume you are using Windows.

Setting Up Go

  1. Setting up Go: Download and install Go from its official site.
  2. Download and Install Git: Download and install Git from here. Use the default settings during install.
  3. Project Setup: Open the command prompt by clicking Start and typing cmd, then press Enter. Next, navigate to the folder where you want your code and create a new folder and blank project file by entering the following commands:
cd Documents  
mkdir whale-alert && cd whale-alert && type nul > main.go

Adding the Tutorial Code

  1. Get the Tutorial Code: Copy the code from here.
  2. Insert Code: Find the newly created main.go file using the File Explorer and open it using Notepad or you favorite editor and paste the code.

Configuring the Alerts

Now we need to enter our API keys into the file and configure what alerts we want to receive.

  1. API Keys: In the main.go file replace YOUR_WHALE_ALERT_API_KEY with the Whale Alert API key you created. Also replaceYOUR_IFTTT_API_KEY in the file with the IFTTT webhook key we have gotten earlier.
  2. Alert Subscription Settings: Find the subscription variable and edit the Blockchains, Symbols, Types and MinValueUSD values to your liking. By default an alert is triggered for any transaction with a value above 10M USD for any blockchain, any symbol and any transaction type. Save and close the file

Building

Now that we have finished configuring the program we can build it so that we can run it.

  1. Initialize Project: Return to the command prompt we opened and enter the following to initialize the project:
go mod init whale-alert

2. Download Packages: Enter the following to download needed packages:

go get -u

3. Build the program: Finally, build the program:

go build

4. Run: Double-click the newly created whale-alert.exe file.

You should now be receiving whale alerts to your email for as long as the program is running. Depending on the values you entered for the subscription configuration it might take a while to pick something up.

Note that with low USD values you might receive too many alerts in a short time. The Whale Alert API has a limit to how many alerts you can receive per hour. Also, to prevent accidently spamming IFTTT’s servers the provided tutorial code also has a limit to how often an alert is send to their servers.

Congratulations, you’re all set up! If you’ve successfully built your custom alert system, we’d love to see it in action. Share your setup on Twitter and tag us so we can celebrate your achievement: Whale Alert Twitter.

(Optional) Running on Digital Ocean

If you’d like to ensure you receive alerts 24/7, running your program on a cloud server is a good solution. We recommend Digital Ocean, which we use extensively at Whale Alert. They offer a great balance between performance and cost. As a bonus, creating a new server is really easy.

Creating a cloud server

  1. Creating an Account: If you don’t already have a Digital Ocean account, create one here. If you are a new user they will give you some free credit for 60 days.
  2. Creating a Droplet: In the Digital Ocean dashboard, click on “Create” and choose “Droplet” from the list. For the operating system, select Ubuntu. Go for the most cost-efficient option: a shared CPU with 512 MB RAM, and 10 GB of regular SSD storage for $4/month. While SSH key authentication is more secure, you can select password authentication for simplicity’s sake in this tutorial. Enter a password for the droplet and provide any hostname for the droplet and click on “Create Droplet”.
  3. Connecting to the Droplet: After the droplet is created, copy its IP address. On your local machine, open a terminal (In Windows click the Start menu then type cmd in the search box and press enter) and execute:
ssh root@YOUR_DROPLET_IP

Accept the security prompt and enter the password set earlier.

If you don’t have SSH installed on your machine you can find instructions to install it here.

Setting up Go

Now that we are connected to our new cloud server we can start install Go and build our program

  1. Environment Setup: Run the following command to update package lists and install Go:
apt update -y && apt install -y golang-go

2. Project Setup: Create a directory for your project and navigate into it:

mkdir whale-alert && cd whale-alert

To edit your main.go file, use nano or any other text editor you prefer:

nano main.go

Next copy the tutorial code from here and paste it into the file.

Configuring the Alerts

Now we need to enter our API keys into the file and configure what alerts we want to receive.

  1. API Keys: In the main.go file replace YOUR_WHALE_ALERT_API_KEY with the Whale Alert API key you created. Also replaceYOUR_IFTTT_API_KEY in the file with the IFTTT webhook key we have gotten earlier.
  2. Alert Subscription Settings: Find the subscription variable and edit the Blockchains, Symbols, Types and MinValueUSD values to your liking. By default an alert is triggered for any transaction with a value above 10M USD for any blockchain, any symbol and any transaction type.
  3. Save the modified main.go file by hitting “ctrl-x” and then “y” followed by the enter key.

Building

Now that we have finished configuring the program we can build it so that we can run it.

  1. Initialize Project: Enter the following to initialize the project:
go mod init whale-alert

2. Download Packages: Enter the following to download needed packages:

go get -u

3. Build the program: Finally, build the program:

go build

4. Run it by entering ./whale-alert in the command prompt.

You should now be receiving whale alerts to your email for as long as the program is running. Depending on the values you entered for the subscription configuration it might take a while to pick something up.

Note that with low USD values you might receive too many alerts in a short time. The Whale Alert API has a limit to how many alerts you can receive per hour. Also, to prevent accidently spamming IFTTT’s servers the provided tutorial code also has a limit to how often an alert is send to their servers.

Keep it Running

Now we have to make sure the program keeps running, even after we log out or the machine reboots. Hit ctrl-c to stop the program if it was still running.

  1. Create a new service:
nano /etc/systemd/system/whale-alert.service

Paste the following:

[Unit]
Description=whale alert

[Service]
Restart=always
RestartSec=10
ExecStart=/root/whale-alert/whale-alert
WorkingDirectory=/root/whale-alert

[Install]
WantedBy=multi-user.target

Hit ctrl-x then y and enter to save.

Now start the service with:

systemctl start whale-alert && systemctl enable whale-alert

The program has started and will be automatically restarted after a crash or reboot.

You can see the logs by entering the following:

cat /var/log/syslog

To stop the service enter:

systemctl stop whale-alert

Securing your server

If you intent to keep your server running for a while it is a good idea to secure it further. Digital Ocean has a good series of tutorials on this topic here.

Congratulations, you’re all set up! If you’ve successfully built your custom alert system, we’d love to see it in action. Share your setup on Twitter and tag us so we can celebrate your achievement: Whale Alert Twitter.

(Optional) Running on a Raspberry Pi

Another option to receive alerts 24/7, is to use a Raspberry Pi. These are small, cheap, but powerful machines that can run a variety of useful programs. The rest of this tutorial assumes that you have a Raspberry Pi with Raspberry Pi OS on it installed and you can SSH into it.

Setting up Go

Connect to your Pi first so that we can start setting up Go.

  1. Environment Setup: Follow the direction here.

2. Project Setup: Create a directory for your project and navigate into it:

mkdir whale-alert && cd whale-alert

To edit your main.go file, use nano or any other text editor you prefer:

nano main.go

Next copy the tutorial code from here and paste it into the file.

Configuring the Alerts

Now we need to enter our API keys into the file and configure what alerts we want to receive.

  1. In the main.go file change YOUR_WHALE_ALERT_API_KEY with the Whale Alert API key you created.
  2. Now change YOUR_IFTTT_API_KEY in the file with the IFTTT webhook key.
  3. Find the subscription variable and edit the Blockchains, Symbols, Types and MinValueUSD values to your liking. By default an alert is triggered for any transaction with a value above 10M USD for any blockchain, any symbol and transaction type.
  4. Save the modified main.go file by hitting “ctrl-x” and then “y” followed by the enter key.

Building

Now that we have finished configuring the program we can build it so that we can run it.

  1. Return to the command prompt we opened and enter the following to initialize the project:
go mod init whale-alert

2. Download needed packages:

go get -u

3. Build the program:

go build

4. Run it by entering ./whale-alert in the command prompt.

You should now be receiving whale alerts to your email as long as the program is running. Depending on the values you entered for the subscription configuration it might take a while to pick something up.

With too low USD values you might receive too many alerts in a short time. With the Whale Alert API there is a limit to how many alerts you will receive. Also, in the program there is a built in limit to how often an alert is send to IFTTT to prevent accidently spamming their servers.

Keep it Running

Now we have to make sure the program keeps running, even after we log out or the machine reboots. Hit ctrl-c to stop the program if it was still running.

  1. Create a new service:
sudo nano /etc/systemd/system/whale-alert.service

Paste the following (you might have to change the ExecStart and WorkingDirectory:

[Unit]
Description=whale alert

[Service]
Restart=always
RestartSec=10
ExecStart=/home/pi/whale-alert/whale-alert
WorkingDirectory=/home/pi/whale-alert

[Install]
WantedBy=multi-user.target

Hit ctrl-x then y and enter to save.

Now start the service with:

sudo systemctl start whale-alert && sudo systemctl enable whale-alert

The program has started and will be automatically restarted after a crash or reboot.

You can see the logs by entering the following:

cat /var/log/syslog

To stop the service enter:

systemctl stop whale-alert

--

--

Whale Alert
Whale Alert

Written by Whale Alert

The worlds largest blockchain tracking and analytics provider.

No responses yet