DEV Community

Cover image for Building a Crypto Price Alert Bot with n8n and CoinGecko
Raizan
Raizan

Posted on • Originally published at chasebot.online

Building a Crypto Price Alert Bot with n8n and CoinGecko

What You'll Need

  • n8n Cloud or self-hosted n8n
  • Hetzner VPS or Contabo VPS for self-hosting
  • Namecheap if setting up a domain
  • CoinGecko API (free tier available at coingecko.com)
  • A messaging platform (Discord, Telegram, or email)

Table of Contents


Understanding the Architecture

I've been building crypto automation workflows for about two years now, and I can tell you: price alert bots are deceptively simple on the surface but incredibly powerful when done right. The basic architecture is straightforward: a trigger fires on a schedule, you fetch current prices, compare them against thresholds you've set, and notify the user if conditions are met.

Here's what happens behind the scenes:

  1. Trigger: A schedule executes every N minutes
  2. Data fetch: Call CoinGecko API for real-time prices
  3. Logic: Compare prices against your alert thresholds
  4. Action: Send a notification if the alert fires

The beauty of building this in n8n Cloud is that you get a visual workflow editor, built-in nodes for HTTP requests, and native integrations with Discord, Telegram, and email—no custom code required (though you can add it if you want).

If you're deploying to production, you might consider self-hosting n8n on a Hetzner VPS or learning how to deploy n8n with Docker on any VPS. That gives you full control over execution and cost savings at scale.


Setting Up Your First Webhook Trigger

Log into n8n Cloud and create a new workflow. The first node will be your trigger—I'm using a Schedule node set to run every 5 minutes.

Click the + icon on your canvas and search for "Schedule". Add the node and configure it like this:

Trigger Type: Every X minutes
Interval: 5
Enter fullscreen mode Exit fullscreen mode

This means your workflow will execute every 5 minutes automatically. You could also use a Webhook trigger if you want external systems to kick off the workflow, but for a price alert bot, a schedule makes more sense—you want continuous monitoring, not event-driven checks.

Now connect your Schedule node to your next step. We're going to fetch live price data.


Fetching Live Crypto Prices from CoinGecko

The CoinGecko API is free and doesn't require authentication for basic endpoints. This is crucial because it means zero setup friction. Add an HTTP Request node right after your Schedule trigger.

Configure the HTTP node like this:

Node: HTTP Request

Method: GET
URL: https://api.coingecko.com/api/v3/simple/price
Authentication: None
Query Parameters:
  ids: bitcoin,ethereum,cardano
  vs_currencies: usd
  include_market_cap: true
  include_24hr_vol: true
  include_24hr_change: true
Enter fullscreen mode Exit fullscreen mode

The response will look like:

{
  "bitcoin": {
    "usd": 42150,
    "usd_market_cap": 831000000000,
    "usd_24h_vol": 24000000000,
    "usd_24h_change": 2.5
  },
  "ethereum": {
    "usd": 2250,
    "usd_market_cap": 270000000000,
    "usd_24h_vol": 9000000000,
    "usd_24h_change": 1.8
  },
  "cardano": {
    "usd": 0.95,
    "usd_market_cap": 33000000000,
    "usd_24h_vol": 450000000,
    "usd_24h_change": -0.5
  }
}
Enter fullscreen mode Exit fullscreen mode

This single API call gives you everything you need. You can request as many coins as you want in the ids parameter—just separate them with commas. For a comprehensive list of supported coins, check the best free APIs for building automation workflows in 2026 guide, which includes CoinGecko benchmarks.

💡 Fast-Track Your Project: Don't want to configure this yourself? I build custom n8n pipelines and bots. Message me with code SYS3-DEVTO.


Building the Price Alert Logic

Now we need to add logic. You'll want to store your alert thresholds somewhere—for this example, I'm storing them in a Function node as JavaScript, but in production, you'd use a database or external config file.

Add a Function node after your HTTP Request node:

const priceData = $input.all()[0].json;
const alerts = [
  { coin: "bitcoin", targetPrice: 40000, direction: "below" },
  { coin: "ethereum", targetPrice: 2000, direction: "below" },
  { coin: "cardano", targetPrice: 0.80, direction: "below" }
];

const triggeredAlerts = [];

for (const alert of alerts) {
  const currentPrice = priceData[alert.coin].usd;

  if (alert.direction === "below" && currentPrice < alert.targetPrice) {
    triggeredAlerts.push({
      coin: alert.coin.toUpperCase(),
      currentPrice: currentPrice,
      targetPrice: alert.targetPrice,
      change24h: priceData[alert.coin].usd_24h_change
    });
  } else if (alert.direction === "above" && currentPrice > alert.targetPrice) {
    triggeredAlerts.push({
      coin: alert.coin.toUpperCase(),
      currentPrice: currentPrice,
      targetPrice: alert.targetPrice,
      change24h: priceData[alert.coin].usd_24h_change
    });
  }
}

return triggeredAlerts;
Enter fullscreen mode Exit fullscreen mode

This function compares each coin's current price against your thresholds. It supports both "above" and "below" directions, so you can alert on pumps or dumps. The output is an array of triggered alerts—empty if no alerts fire.

Next, add an IF node to check if any alerts were triggered:

Condition: triggeredAlerts.length > 0
Enter fullscreen mode Exit fullscreen mode

If this evaluates to true, proceed to your notification nodes. If false, the workflow ends silently—no spam.


Sending Notifications

Connect your IF node to a Discord node (or Telegram/email—your choice). I'll show Discord because it's the most popular for crypto communities.

Add a Discord node and configure it:

Node: Discord

Authentication: Select your Discord webhook
Message Type: Text
Text:
🚨 CRYPTO PRICE ALERT 🚨

{{ $json[0].coin }} just hit your target!
Current Price: ${{ $json[0].currentPrice }}
Target Price: ${{ $json[0].targetPrice }}
24h Change: {{ $json[0].change24h }}%

Action now or miss the move! 📈
Enter fullscreen mode Exit fullscreen mode

The $json[0] syntax references data from the previous node. For multiple alerts in one message, you'd loop through the array. Here's a more advanced version using a Code node to format multiple alerts:

Node: Function (for formatting)

const alerts = $input.all()[0].json;

let message = "🚨 **CRYPTO PRICE ALERTS** 🚨\n\n";

for (const alert of alerts) {
  message += `**${alert.coin}**\n`;
  message += `Current: $${alert.currentPrice}\n`;
  message += `Target: $${alert.targetPrice}\n`;
  message += `24h Change: ${alert.change24h.toFixed(2)}%\n\n`;
}

message += "Check your exchange now! ⚡";

return { message: message };
Enter fullscreen mode Exit fullscreen mode

Then pass {{ $json.message }} to your Discord node's Text field.

If you want text-to-speech notifications on mobile, consider piping alerts through Edge TTS: The Free Text-to-Speech Engine, which integrates beautifully with n8n for voice alerts.


Advanced: Multi-Exchange Price Comparison

If you want to level up, fetch prices from multiple exchanges and alert when spreads widen. Add a second HTTP Request node that calls a different endpoint:

Method: GET
URL: https://api.coingecko.com/api/v3/simple/price
Query Parameters:
  ids: bitcoin,ethereum
  vs_currencies: usd
  include_exchanges: true
Enter fullscreen mode Exit fullscreen mode

Then use a Function node to calculate spreads:

const prices = $input.all()[0].json;

const analysis = {
  bitcoin: {
    current: prices.bitcoin.usd,
    volatility: prices.bitcoin.usd_24h_change
  },
  ethereum: {
    current: prices.ethereum.usd,
    volatility: prices.ethereum.usd_24h_change
  }
};

if (analysis.bitcoin.volatility > 5) {
  return { alert: true, message: `Bitcoin is volatile (${analysis.bitcoin.volatility}%)` };
}

return { alert: false };
Enter fullscreen mode Exit fullscreen mode

This triggers alerts on high volatility, not just price thresholds—much smarter for active traders.


Error Handling & Rate Limiting

CoinGecko's free API allows 10-50 calls per minute depending on your region. With a 5-minute schedule and a single endpoint, you're safe. But add error handling anyway:

try {
  const response = $input.all()[0].json;
  if (!response.bitcoin) throw new Error("API returned incomplete data");
  return response;
} catch (error) {
  return { error: error.message, timestamp: new Date().toISOString() };
}
Enter fullscreen mode Exit fullscreen mode

Then add an IF node that checks for error in the response and sends you a Slack message if something breaks.


Getting Started

Ready to build? Here's your action plan:

  1. Sign up for n8n Cloud (free tier covers most use cases)
  2. Create a new workflow
  3. Add Schedule → HTTP Request → Function → IF → Discord/Telegram node
  4. Test with manual trigger (click the play button)
  5. Adjust alert thresholds based on your trading strategy
  6. Turn on Active toggle to run your bot 24/7

If you're planning to run this bot constantly without cloud costs, explore deploying n8n with Docker on a Hetzner VPS—you'll pay ~$3-5/month instead of n8n Cloud's subscription.


Outsource Your Automation

Don't have time to build this yourself? I specialize in production-ready n8n workflows, WhatsApp bots, and fully automated YouTube Shorts pipelines. Hire me on Fiverr—mention SYS3-DEVTO for priority handling and 20% off. Or reach out directly at chasebot.online and let's discuss your specific needs.

I've built crypto bots that handle multi-exchange arbitrage, Discord raid alerts, and even automated position management. Whatever you're trying to automate, I can make it work.


Pro tip: Save your workflow


Originally published on Automation Insider.

Top comments (0)