Track Your Favorite Crypto Prices in Slack With This Node.js Bot

Hero Image

Whether you're into Bitcoin, Ethereum, Tether, or any other cryptocurrency, you have to admit that keeping track of highs/lows and overall trends can influence your buy/sell trading strategy. I am a novice in the crypto space and only dabble with small amounts, so please don't take any of this as financial advice. But I was curious whether I could build a bot that would track a given coin's market price and let me know when it exceeds or dips below its 10-day moving average.

I didn't want to settle for any of the off-the-shelf solutions I found for the following reasons:

  • I wanted direct control of the data so I can specify the exact comparison criteria and time ranges
  • I wanted the flexibility to do more sophisticated calculations
  • I want to (eventually) add the ability to make this a crypto trading bot to automate trading via API

Luckily, I had Fusebit at my disposal, which made this task trivial. Fusebit lets me write a small JavaScript function where I can execute my calculations and decide whether to send a notification via Slack. It also lets me connect to any public API, so I relied on CoinAPI, which lets you get market data on different crypto coins in close to real-time from different exchanges (including Coinbase, Bitfinex, and Binance) for free. Fusebit is based on Node.js, which means I can also use tons of free JS libraries on the npm package registry.

Creating a simple crypto price tracking bot

First, you need to obtain a free CoinAPI key, which you will need later in this post.

Once you have your key, sign up for Fusebit:

Sign up for Fusebit for free

  1. Select Slack Crypto Bot when creating a new integration and specify the API key you obtained earlier
  2. Click the Edit button and then Run once the editor loads
  3. Finally, you will need to authorize access to a Slack workspace and the bot will then send you a DM with the current price for Bitcoin

Slack message sent by bot

If you got this far, then congrats, everything is working! But the fun is just beginning. This bot will only run on demand (when you hit the Run button), so let's learn how to make this a regular check, and how to make other customizations.

Customizing the bot

To get the bot to run regularly on a schedule:

  1. Select Configuration in the Fusebit Editor
  2. Add a similar section to the object. (Useful reference for the cron string)
"schedule": [
"cron": "0 * * * *",
"endpoint": "/check-delta",
"timezone": "America/Los_Angeles"

You may also want to check for the value of another crypto coin. Simply change the following line to a different symbol. You need to be familiar with Node.js and JavaScript to make this change.

const ticker = 'BTC';

You may want to get data for multiple symbols at once, you can repeat the following lines in the source code to get data and construct a response message.

const range = await get10dayRange(ctx, ticker);
const rate = await getRate(ctx, ticker);
const message = printTickerMessage(ticker, rate, range.high, range.low);

What's next

This is just a very basic example and I'm eager to expand what this Fusebit bot can do. In particular, I'm curious if we can enable Node.js-based algorithmic trading.

What other capabilities should we add? Any cool usage examples you're willing to share? Contact us at @fusebitio on Twitter.


Most Recent

19 May 2022
How to Use the Gmail API in Node.js - A Step-by-Step Tutorial

Follow this guide to setting up and using Gmail API in Node.js to read, drafts, and send emails.

19 May 2022
Create Your First Node.js GitHub Action, a How-To Guide

In this post, you'll learn what GitHub Actions are and how to create your first GitHub Action for your Node.js application.

17 May 2022
New Express 5 Features to Try

Express.js 5 is currently in Beta. In this article, we will cover the new Express.js 5 features and why Node.js developers should try them out.