Skip to main content

Overview

In this guide, you’ll learn how to build a Telegram bot that sends real-time liquidation alerts for perpetual trading positions. This is useful for:
  • Traders who want to monitor market liquidations for trading signals
  • Risk managers tracking leverage exposure in the market
  • Analysts studying liquidation patterns and market dynamics

Prerequisites

  • A Mobula API key (Get one here)
  • A Telegram Bot Token (create via @BotFather)
  • Node.js 18+ or Bun runtime
  • Basic TypeScript knowledge

Step 1: Create Your Telegram Bot

  1. Open Telegram and search for @BotFather
  2. Send /newbot and follow the prompts
  3. Save your Bot Token (looks like 123456789:ABCdefGHIjklMNOpqrsTUVwxyz)
  4. Create a channel or group for alerts and add your bot as admin
  5. Get the Channel ID (you can use @userinfobot or check the URL)
For public channels, the ID is usually -100 followed by numbers. For private channels, you can get the ID by forwarding a message to @userinfobot.

Step 2: Set Up Your Project

Create a tsconfig.json:

Step 3: Build the Liquidation Bot

Create src/index.ts:

Step 4: Run Your Bot

Or with Bun:
You should see:

Step 5: Customize Your Alerts

Add Market Order Alerts

Extend your bot to also alert on large market orders:

Filter by Specific Markets

Add Rate Limiting

To avoid Telegram rate limits (30 messages/second):

Order Data Model

Here’s the full data structure you receive for perp orders:

Deployment

Using PM2

Using Docker

Support

Need help? Reach out to our team:

Support

Telegram

Support

Slack

Need help?

Email