Back to Blog

Build a Telegram Bot for Pokemon Card Price Alerts

PokemonPriceTracker Team

2 min read
Build a Telegram Bot for Pokemon Card Price Alerts

Build a Telegram Pokemon Price Alert Bot

Why Telegram Bots?

  • 300M+ active users (popular internationally)
  • Excellent bot API with webhooks
  • Built-in push notifications
  • Free serverless deployment

Quick Start

npm init -y
npm install telegraf dotenv axios

Create bot via @BotFather/newbot

Complete Bot Code

const { Telegraf } = require('telegraf');
const axios = require('axios');

const bot = new Telegraf(process.env.TELEGRAM_BOT_TOKEN);
const API_KEY = process.env.POKEMON_API_KEY;
const API_BASE = 'https://www.pokemonpricetracker.com/api/v2';

// Store user alerts in memory (use database in production)
const userAlerts = new Map();

// /price command
bot.command('price', async (ctx) => {
  const cardName = ctx.message.text.split(' ').slice(1).join(' ');

  if (!cardName) {
    return ctx.reply('Usage: /price <card name>');
  }

  const response = await axios.post(
    `${API_BASE}/parse-title`,
    { title: cardName },
    { headers: { 'Authorization': `Bearer ${API_KEY}` } }
  );

  if (response.data.matches?.[0]) {
    const card = response.data.matches[0].card;
    ctx.reply(
      `💰 *${card.name}*\n` +
      `Set: ${card.setName}\n` +
      `Price: $${card.prices.market.toFixed(2)}`,
      { parse_mode: 'Markdown' }
    );
  }
});

// /alert command
bot.command('alert', async (ctx) => {
  const args = ctx.message.text.split(',');
  if (args.length < 2) {
    return ctx.reply('Usage: /alert <card name>, <target price>');
  }

  const cardName = args[0].replace('/alert', '').trim();
  const targetPrice = parseFloat(args[1].trim());

  const userId = ctx.from.id;

  if (!userAlerts.has(userId)) {
    userAlerts.set(userId, []);
  }

  userAlerts.get(userId).push({
    cardName,
    targetPrice,
    chatId: ctx.chat.id
  });

  ctx.reply(`✅ Alert set for ${cardName} at $${targetPrice}`);
});

bot.launch();

// Check alerts periodically
setInterval(async () => {
  for (const [userId, alerts] of userAlerts.entries()) {
    for (const alert of alerts) {
      // Check current price
      const response = await axios.post(
        `${API_BASE}/parse-title`,
        { title: alert.cardName },
        { headers: { 'Authorization': `Bearer ${API_KEY}` } }
      );

      if (response.data.matches?.[0]) {
        const currentPrice = response.data.matches[0].card.prices.market;

        if (currentPrice <= alert.targetPrice) {
          bot.telegram.sendMessage(
            alert.chatId,
            `🔔 *Price Alert!*\n${alert.cardName} is now $${currentPrice}!`,
            { parse_mode: 'Markdown' }
          );
        }
      }
    }
  }
}, 3600000); // Check hourly

Deploy to Vercel

// api/telegram-webhook.js
module.exports = async (req, res) => {
  if (req.method === 'POST') {
    await bot.handleUpdate(req.body);
    res.status(200).send('OK');
  } else {
    res.status(200).send('Bot is running');
  }
};

Related Tutorials

Get Free API Key →

PokemonPriceTracker Team

Related Articles

Pokemon Card API: Complete Developer's Guide to Card Data APIs (2025)
API & Development
August 8, 2025

Pokemon Card API: Complete Developer's Guide to Card Data APIs (2025)

Complete Pokemon card API guide for developers. Learn about available APIs, integration methods, pricing data access, and how to build Pokemon card applications.

PokemonPriceTracker Team

Pokemon Card API Comparison 2025 - Find the Best API for Your Project
API & Development
January 20, 2025

Pokemon Card API Comparison 2025 - Find the Best API for Your Project

Honest comparison of Pokemon card APIs - PokemonPriceTracker vs PokemonTCG.io vs JustTCG vs PriceCharting. Performance benchmarks, feature matrix, and migration guides.

PokemonPriceTracker Team

Parse Title API - Fuzzy Match Pokemon Cards for Marketplace Integration
API & Development
January 18, 2025

Parse Title API - Fuzzy Match Pokemon Cards for Marketplace Integration

Learn how to use the Parse Title API for fuzzy matching Pokemon card descriptions. Perfect for eBay listing enhancement, marketplace integration, and bulk card processing.

PokemonPriceTracker Team

Stay Updated

Subscribe to our newsletter for the latest Pokemon card market trends, investment opportunities, and exclusive insights delivered straight to your inbox.