How to Get Telegram Crypto Alerts from Your Local AI Agent
Getting Telegram crypto alerts from your local AI agent is one of the most practical things you can set up this weekend. Instead of constantly checking price apps or paying for premium alert services, your OpenClaw agent watches markets 24/7 and pings your phone the moment something worth seeing happens. This guide covers the complete setup: creating your Telegram bot, wiring it to OpenClaw, and configuring alerts that actually matter.
Why Telegram? Not Email, Not Push Notifications
Telegram is the best notification layer for a crypto agent because:
- Instant delivery — Telegram messages typically arrive in under 1 second. Email can take minutes.
- Formatted messages — Telegram supports Markdown, so your alerts look clean with bold headers and emojis.
- Free Bot API — Telegram's Bot API has no rate limits or paid tiers for personal use.
- Phone + desktop — Your alerts reach you everywhere simultaneously.
- No tracking — Unlike email, Telegram doesn't scan your messages for ads.
- Open ecosystem — The Bot API is simple, well-documented, and stable.
Step 1: Create Your Telegram Bot (5 Minutes)
Creating a Telegram bot is genuinely simple:
- Open Telegram and search for @botfather
- Send
/newbot - Choose a name for your bot (e.g., "My Crypto Agent")
- Choose a username ending in
bot(e.g.,mypaarthurnaxbot) - BotFather returns your Bot Token — copy it immediately
Your token looks like: 1234567890:ABCdefGhIJKlmNoPQRstUvwXyz
Get your Chat ID:
- Start a conversation with your new bot (search for it in Telegram, click Start)
- Visit:
https://api.telegram.org/bot{YOUR_TOKEN}/getUpdates - Send any message to your bot
- Refresh the URL — you'll see your
chat_idin the response
import requests
def get_chat_id(bot_token):
"""Get your chat ID after sending a message to your bot."""
url = f"https://api.telegram.org/bot{bot_token}/getUpdates"
response = requests.get(url)
updates = response.json()
if updates["result"]:
chat_id = updates["result"][-1]["message"]["chat"]["id"]
print(f"Your Chat ID: {chat_id}")
return chat_id
else:
print("No messages found. Send a message to your bot first.")
return None
Step 2: Test Basic Message Sending
Before wiring in market data, test that your bot sends messages correctly:
import requests
import os
TELEGRAM_TOKEN = os.environ.get("TELEGRAM_BOT_TOKEN") # Set this env var
TELEGRAM_CHAT_ID = os.environ.get("TELEGRAM_CHAT_ID") # Set this env var
def send_message(text, parse_mode="Markdown"):
"""Send a Telegram message."""
url = f"https://api.telegram.org/bot{TELEGRAM_TOKEN}/sendMessage"
payload = {
"chat_id": TELEGRAM_CHAT_ID,
"text": text,
"parse_mode": parse_mode
}
response = requests.post(url, json=payload)
if response.status_code == 200:
return True
else:
print(f"Error sending message: {response.text}")
return False
# Test it
send_message("✅ *OpenClaw Agent Online*\n\nCrypto monitoring active. You'll receive alerts here.")
Step 3: Set Up Price Alerts
The most useful alert type: notify when a coin moves more than X% in Y hours.
import requests
import json
from datetime import datetime
from pathlib import Path
ALERT_STATE_FILE = Path("alert_state.json")
def get_prices(coins):
"""Fetch current prices from CoinGecko."""
url = "https://api.coingecko.com/api/v3/simple/price"
params = {
"ids": ",".join(coins),
"vs_currencies": "usd",
"include_24hr_change": "true",
"include_1hr_change": "true"
}
return requests.get(url, params=params).json()
def load_alert_state():
if ALERT_STATE_FILE.exists():
return json.loads(ALERT_STATE_FILE.read_text())
return {}
def save_alert_state(state):
ALERT_STATE_FILE.write_text(json.dumps(state, indent=2))
def check_price_alerts(coins, threshold_1h=3.0, threshold_24h=10.0):
"""
Send Telegram alerts when price moves exceed thresholds.
Args:
coins: List of CoinGecko coin IDs
threshold_1h: Alert if 1h change exceeds this % (absolute)
threshold_24h: Alert if 24h change exceeds this % (absolute)
"""
prices = get_prices(coins)
state = load_alert_state()
alerts_sent = []
for coin, data in prices.items():
change_1h = data.get("usd_1h_change", 0) or 0
change_24h = data.get("usd_24h_change", 0) or 0
price = data.get("usd", 0)
# Check 1-hour threshold
if abs(change_1h) >= threshold_1h:
last_1h_alert = state.get(f"{coin}_1h_alert_time")
# Only alert once per hour per coin
if not last_1h_alert or (datetime.utcnow().timestamp() - last_1h_alert) > 3600:
direction = "📈" if change_1h > 0 else "📉"
message = (
f"{direction} *1H MOVE ALERT: {coin.upper()}*\n\n"
f"Price: ${price:,.2f}\n"
f"1H Change: {change_1h:+.1f}%\n"
f"24H Change: {change_24h:+.1f}%"
)
send_message(message)
state[f"{coin}_1h_alert_time"] = datetime.utcnow().timestamp()
alerts_sent.append(f"{coin} 1h: {change_1h:+.1f}%")
# Check 24-hour threshold
if abs(change_24h) >= threshold_24h:
last_24h_alert = state.get(f"{coin}_24h_alert_time")
# Only alert once per 4 hours
if not last_24h_alert or (datetime.utcnow().timestamp() - last_24h_alert) > 14400:
direction = "🚀" if change_24h > 0 else "🔥"
message = (
f"{direction} *24H MOVE ALERT: {coin.upper()}*\n\n"
f"Price: ${price:,.2f}\n"
f"24H Change: {change_24h:+.1f}%\n"
f"⚡ Large daily move detected"
)
send_message(message)
state[f"{coin}_24h_alert_time"] = datetime.utcnow().timestamp()
alerts_sent.append(f"{coin} 24h: {change_24h:+.1f}%")
save_alert_state(state)
return alerts_sent
# Run it
check_price_alerts(["bitcoin", "ethereum", "solana"], threshold_1h=3.0, threshold_24h=10.0)
Step 4: Gas Fee Alerts
For DeFi users, Ethereum gas fee alerts are the most practical tool. Know when gas is cheap before you need to transact:
import os
ETHERSCAN_KEY = os.environ.get("ETHERSCAN_API_KEY")
def get_eth_gas():
"""Get current ETH gas prices from Etherscan free API."""
url = f"https://api.etherscan.io/api?module=gastracker&action=gasoracle&apikey={ETHERSCAN_KEY}"
data = requests.get(url).json()
result = data.get("result", {})
return {
"fast": int(result.get("FastGasPrice", 0)),
"standard": int(result.get("ProposeGasPrice", 0)),
"slow": int(result.get("SafeGasPrice", 0))
}
def check_gas_alert(threshold_gwei=20):
"""Alert when ETH gas is cheap."""
gas = get_eth_gas()
if gas["fast"] <= threshold_gwei:
message = (
f"⛽ *GAS ALERT: ETH Gas Is Cheap!*\n\n"
f"Fast: {gas['fast']} Gwei\n"
f"Standard: {gas['standard']} Gwei\n"
f"Slow: {gas['slow']} Gwei\n\n"
f"Good window for DeFi transactions.\n"
f"Threshold: {threshold_gwei} Gwei"
)
send_message(message)
return True
return False
check_gas_alert(threshold_gwei=20)
Step 5: Daily Market Summary
Set up a daily briefing that runs at 9 AM your time:
from datetime import datetime
def send_daily_briefing(coins=["bitcoin", "ethereum", "solana"]):
"""Send comprehensive daily market summary."""
prices = get_prices(coins)
gas = get_eth_gas()
date_str = datetime.utcnow().strftime("%Y-%m-%d")
message = f"🌅 *Daily Crypto Briefing — {date_str}*\n\n"
for coin, data in prices.items():
price = data.get("usd", 0)
change_24h = data.get("usd_24h_change", 0) or 0
change_1h = data.get("usd_1h_change", 0) or 0
trend = "📈" if change_24h > 0 else "📉"
message += f"{trend} *{coin.upper()}*: ${price:,.2f} ({change_24h:+.1f}%)\n"
message += f"\n⛽ *ETH Gas*: {gas['standard']} Gwei (standard)\n"
# Simple sentiment
btc_change = prices.get("bitcoin", {}).get("usd_24h_change", 0) or 0
if btc_change > 5:
sentiment = "🟢 Bullish — BTC leading up"
elif btc_change < -5:
sentiment = "🔴 Bearish — BTC under pressure"
else:
sentiment = "🟡 Neutral — Range-bound"
message += f"\n📊 *Sentiment*: {sentiment}"
send_message(message)
send_daily_briefing()
Step 6: Run as an OpenClaw Skill
To run these alerts continuously inside OpenClaw, save the above as a skill file and add a schedule:
# openclaw_telegram_alerts.py
import schedule
import time
# Daily briefing at 9 AM
schedule.every().day.at("09:00").do(send_daily_briefing)
# Price alerts every 15 minutes
schedule.every(15).minutes.do(lambda: check_price_alerts(
["bitcoin", "ethereum", "solana"],
threshold_1h=5.0,
threshold_24h=15.0
))
# Gas check every 30 minutes
schedule.every(30).minutes.do(lambda: check_gas_alert(threshold_gwei=20))
print("OpenClaw Telegram Alerts running. Press Ctrl+C to stop.")
while True:
schedule.run_pending()
time.sleep(60)
Pre-Built Skills
Rather than building all this yourself, the OpenClaw Skills Hub has pre-built versions already tested and packaged:
- Gas Fee Monitor (Free) — Telegram alert when ETH gas drops below threshold
- CryptoScanner (Free) — Daily price summary for top 50 coins
- TechAnalyzer ($9) — RSI/MACD alerts with confidence scores
- Whale Alert Listener ($19) — On-chain large wallet movement alerts
Browse them at: https://paarthurnax970-debug.github.io/cryptoclawskills/
Get the complete Telegram alert setup with the Home AI Agent Kit — includes all bot configuration scripts and alert templates pre-built.
Disclaimer: Price alerts are informational tools only. Nothing in this article constitutes financial or investment advice. Cryptocurrency markets are highly volatile. Always do your own research before making financial decisions.
Top comments (0)