Build a Crypto Price Alert System with Telegram and AWS Lambda

·

In today’s fast-moving cryptocurrency markets, staying on top of price fluctuations is essential—especially if you're watching for specific entry or exit points. Manually tracking prices is time-consuming and inefficient. That’s where automation comes in.

This guide walks you through building a fully automated crypto price alert system using Telegram, AWS Lambda, and serverless infrastructure. The result? Real-time notifications whenever a cryptocurrency hits your target price—no app downloads, no subscriptions, and no constant screen-watching.

👉 Discover how to automate crypto alerts without manual monitoring.


Why You Need a Crypto Price Alert System

Whether you're a casual investor or actively trading digital assets, timing can make a significant difference in your returns. Imagine wanting to sell Ethereum when it reaches $4,000—or buy Bitcoin if it dips below $60,000. Instead of refreshing exchange pages every few minutes, wouldn’t it be better to get an instant notification?

A crypto price alert system eliminates guesswork and emotional decision-making by automating alerts based on predefined thresholds. It’s lightweight, cost-efficient (thanks to serverless computing), and runs 24/7 without user intervention.

Best of all, you can build this entire system using free-tier eligible AWS services and open-source tools.


Core Components of the System

The architecture combines several modern technologies into a seamless workflow:

Each component plays a role in making the system reliable, scalable, and easy to customize.


Defining the Price Alert Structure

Every alert must carry enough information to evaluate market conditions and trigger actions. Here's the core data model:

type PriceAlertCondition = "more" | "less"

export type PriceAlert = {
  id: string
  asset: string
  targetPrice: number
  condition: PriceAlertCondition
  isNotified: boolean
}

Key Fields Explained

This structure ensures each alert is self-contained and easy to process during execution.


Setting Up Alerts with TypeScript

To define which coins and prices you're monitoring, use a simple script like setPriceAlert.ts. This example sets two Ethereum alerts:

const rules = [
  {
    asset: "ethereum",
    targetPrice: 3800,
    condition: "less",
  },
  {
    asset: "ethereum",
    targetPrice: 4000,
    condition: "more",
  },
]

// Clears old alerts and inserts new ones
await deleteAllPriceAlerts()
await Promise.all(priceAlerts.map(alert => putPriceAlert(alert)))

This script clears outdated rules and seeds the database with fresh alerts—perfect for one-time setup or scheduled updates.


Managing Alerts in DynamoDB

We use DynamoDB as our persistence layer due to its low latency and seamless integration with AWS Lambda. CRUD operations are handled via helper functions:

export const getAllPriceAlerts = async () => { /* scans table */ }
export const putPriceAlert = (alert) => { /* inserts item */ }
export const deletePriceAlert = (id) => { /* removes item */ }
export const updatePriceAlert = (id, fields) => { /* partial update */ }

These functions abstract away AWS SDK complexity while ensuring safe, efficient database interactions.


Fetching Real-Time Crypto Prices

We rely on the CoinGecko Public API to retrieve up-to-date pricing data. A dedicated function fetches prices for multiple assets at once:

const assetPrices = await getAssetPrices({
  ids: ["bitcoin", "ethereum"],
  fiatCurrency: "usd"
})

Under the hood:

  1. Constructs a URL with query parameters.
  2. Sends an HTTPS request using queryUrl.
  3. Flattens nested responses using recordMap for easier access.

Result: A clean object like { ethereum: 3950 }, ready for comparison.

👉 Learn how real-time data powers smarter crypto decisions.


Sending Instant Alerts via Telegram

When a price crosses your threshold, you’ll receive a message instantly through Telegram. Using the node-telegram-bot-api library:

const bot = new TelegramBot(process.env.TELEGRAM_BOT_TOKEN)
await bot.sendMessage(process.env.TELEGRAM_BOT_CHAT_ID, "ethereum price: 4001")

You only need two environment variables:

No frontend required—just text alerts delivered straight to your phone.


Environment Variable Management

To avoid hardcoded secrets and ensure consistency across environments, we use a centralized getEnvVar utility:

export const getEnvVar = (name: string): string => {
  const value = process.env[name]
  if (!value) throw new Error(`Missing ${name} environment variable`)
  return value
}

Used for:

This enforces secure, predictable configuration management.


Running the Watcher Logic

The heart of the system is runPriceWatcher, which executes periodically via CloudWatch Events:

export const runPriceWatcher = async () => {
  const alerts = await getAllPriceAlerts()
  const assets = alerts.map(a => a.asset)
  const prices = await getAssetPrices({ ids: assets })

  await Promise.all(alerts.map(async alert => {
    const currentPrice = prices[alert.asset]
    const conditionMet = 
      alert.condition === "more" ? currentPrice > alert.targetPrice :
      currentPrice < alert.targetPrice

    if (conditionMet && !alert.isNotified) {
      await sendPriceChangeAlert({ price: currentPrice, asset: alert.asset })
      await updatePriceAlert(alert.id, { isNotified: true })
    } else if (!conditionMet && alert.isNotified) {
      await updatePriceAlert(alert.id, { isNotified: false })
    }
  }))
}

This function:

  1. Loads all active alerts.
  2. Fetches current prices.
  3. Evaluates conditions.
  4. Sends notifications only once per trigger.
  5. Resets flags when market reverts.

Efficient, idempotent, and scalable.


Automating Deployment with Terraform

Instead of manual setup, we define infrastructure as code using Terraform:

This approach ensures reproducible deployments across stages (dev, prod) and minimizes human error.


Frequently Asked Questions (FAQ)

How often does the system check prices?

The Lambda function runs every 10 minutes using a CloudWatch scheduled event. You can adjust this interval in Terraform settings.

Can I monitor multiple cryptocurrencies?

Yes! Just add more entries in the setPriceAlert.ts script with different asset IDs (e.g., "bitcoin", "solana").

Is there a cost involved?

Most components fall within AWS Free Tier limits:

Total estimated monthly cost: under $1 for typical usage.

What happens if AWS Lambda fails?

We integrate Sentry for error tracking. Any unhandled exceptions trigger immediate alerts so you can debug quickly.

Can I receive alerts in other apps?

Currently supports Telegram only. However, the notification module is decoupled—you could extend it to support email, Slack, or mobile push.

Do I need coding experience to set this up?

Basic knowledge of Node.js, AWS, and CLI tools helps. But the full source code is available on GitHub—just configure environment variables and deploy.

👉 Start building intelligent crypto automation tools today.


Final Thoughts

By combining serverless computing, real-time APIs, and instant messaging, we’ve created a powerful yet minimalistic solution for tracking crypto prices. This system runs autonomously, scales effortlessly, and gives you peace of mind knowing you won’t miss critical market moves.

With under 200 lines of logic code and infrastructure defined in Terraform, it's also highly customizable—perfect for extending into portfolio trackers, arbitrage detectors, or DeFi yield monitors.

Ready to stop staring at charts? Deploy your own crypto price watcher and let automation do the work.

Keywords: crypto price alert, AWS Lambda cryptocurrency, Telegram crypto bot, serverless crypto monitoring, real-time price tracker, automated crypto alerts, CoinGecko API integration, DynamoDB crypto data