CryptoView Pro can send real-time notifications to your Telegram account for price alerts, ML predictions, and trading signals.
Overview
The Telegram notifier (utils/telegram_notifier.py) supports:
- 📊 Price change alerts - Get notified of significant price movements
- 🔮 ML prediction alerts - Receive forecast updates from your models
- 📈 Trading signal alerts - RSI, MACD, and technical indicator signals
- ⚠️ Custom threshold alerts - Configure your own trigger conditions
Quick Setup
Step 1: Create a Telegram Bot
- Open Telegram and search for @BotFather
- Send
/newbot command
- Choose a name for your bot (e.g., “CryptoView Alert Bot”)
- Choose a username (must end in ‘bot’, e.g., “cryptoview_alerts_bot”)
- Save the Bot Token provided by BotFather
Example token format: 1234567890:ABCdefGHIjklMNOpqrsTUVwxyz
Step 2: Get Your Chat ID
- Start a chat with your new bot (click the link BotFather provides)
- Send any message to your bot (e.g., “/start”)
- Visit this URL in your browser (replace YOUR_BOT_TOKEN):
https://api.telegram.org/botYOUR_BOT_TOKEN/getUpdates
- Look for
"chat":{"id": in the response - that’s your Chat ID
Example Chat ID: 123456789
Your Chat ID is typically a 9-10 digit number. If you’re setting up alerts for a group, the group Chat ID will be negative (e.g., -987654321).
Add your bot credentials to .env:
TELEGRAM_BOT_TOKEN=1234567890:ABCdefGHIjklMNOpqrsTUVwxyz
TELEGRAM_CHAT_ID=123456789
Step 4: Test Connection
Run this test to verify your setup:
from utils.telegram_notifier import TelegramNotifier
from config.settings import TELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID
notifier = TelegramNotifier(
bot_token=TELEGRAM_BOT_TOKEN,
chat_id=TELEGRAM_CHAT_ID
)
if notifier.test_connection():
print("✅ Telegram setup successful!")
else:
print("❌ Connection failed - check your credentials")
You should receive a test message in Telegram (utils/telegram_notifier.py:163-171).
Alert Configuration
Configure alert thresholds in config/settings.py:78-83:
ALERT_THRESHOLDS = {
'price_change_pct': 5.0, # Alert on 5% price change
'rsi_overbought': 70, # RSI overbought threshold
'rsi_oversold': 30, # RSI oversold threshold
'volume_spike': 2.0 # Alert on 2x volume spike
}
Modify these values to customize when alerts trigger.
Using the Notifier
The TelegramNotifier class provides several alert methods.
Initialize Notifier
from utils.telegram_notifier import TelegramNotifier
notifier = TelegramNotifier(
bot_token="YOUR_BOT_TOKEN",
chat_id="YOUR_CHAT_ID"
)
See utils/telegram_notifier.py:8-23 for initialization details.
Send Basic Message
Send a custom text message:
notifier.send_message(
message="Bitcoin just broke $50,000!",
parse_mode='Markdown' # or 'HTML'
)
Supports Markdown formatting:
*bold*
_italic_
[link text](url)
`code`
See implementation at utils/telegram_notifier.py:25-49.
Price Change Alerts
Send alerts when price thresholds are crossed:
notifier.send_alert(
crypto="BTC/USDT",
alert_type="Price Change",
current_value=52000.00,
threshold=50000.00,
condition="Greater than"
)
Example message received:
🚨 ALERTA CRYPTOVIEW PRO
💰 BTC/USDT
📊 Tipo: Price Change
🎯 Condición: Greater than 50000.00
📈 Valor actual: 52000.00
⏰ 2026-03-07 14:30:45
_Configura tus alertas en CryptoView Pro_
See utils/telegram_notifier.py:51-83 for implementation.
ML Prediction Alerts
Send forecast notifications from your ML models:
notifier.send_prediction_alert(
crypto="ETH/USDT",
current_price=3200.00,
predicted_price=3520.00,
hours=24,
change_pct=10.0,
confidence=87.5
)
Example message received:
🔮 PREDICCIÓN ML - CRYPTOVIEW PRO
💰 ETH/USDT
📊 Precio Actual: $3,200.00
📈 Predicción (24h): $3,520.00
📈 Cambio Esperado: +10.00%
🎯 Confianza: 87.5%
⏰ 2026-03-07 14:30:45
_Generado por modelos híbridos XGBoost + Prophet_
Uses dynamic emoji (📈 for positive, 📉 for negative predictions).
See implementation at utils/telegram_notifier.py:85-122.
Trading Signal Alerts
Send technical indicator signals:
notifier.send_signal(
crypto="BTC/USDT",
signal="COMPRA", # or "VENTA", "NEUTRAL"
current_price=51500.00,
rsi=32.5,
macd_signal="Bullish crossover"
)
Example message received:
🟢 SEÑAL DE TRADING
💰 BTC/USDT
💵 Precio: $51,500.00
🎲 Señal: COMPRA
📊 Indicadores:
• RSI: 32.5
• MACD: Bullish crossover
⏰ 2026-03-07 14:30:45
⚠️ _No es asesoría financiera. Investiga antes de operar._
Color-coded emoji:
- 🟢 Green for COMPRA (buy)
- 🔴 Red for VENTA (sell)
- 🟡 Yellow for NEUTRAL
See implementation at utils/telegram_notifier.py:124-161.
Alert Examples
RSI Oversold Alert
Detect oversold conditions and send alerts:
from config.settings import ALERT_THRESHOLDS
current_rsi = 28.5
if current_rsi < ALERT_THRESHOLDS['rsi_oversold']:
notifier.send_alert(
crypto="ADA/USDT",
alert_type="RSI Oversold",
current_value=current_rsi,
threshold=ALERT_THRESHOLDS['rsi_oversold'],
condition="Below"
)
Volume Spike Alert
current_volume = 150000
average_volume = 60000
volume_ratio = current_volume / average_volume
if volume_ratio > ALERT_THRESHOLDS['volume_spike']:
notifier.send_alert(
crypto="SOL/USDT",
alert_type="Volume Spike",
current_value=volume_ratio,
threshold=ALERT_THRESHOLDS['volume_spike'],
condition="Ratio above"
)
Automated Prediction Alerts
Send daily forecast summaries:
import schedule
import time
def send_daily_forecast():
# Your prediction logic here
predictions = get_predictions('BTC/USDT')
notifier.send_prediction_alert(
crypto='BTC/USDT',
current_price=predictions['current'],
predicted_price=predictions['forecast_24h'],
hours=24,
change_pct=predictions['change_pct'],
confidence=predictions['confidence']
)
# Schedule daily at 9 AM
schedule.every().day.at("09:00").do(send_daily_forecast)
while True:
schedule.run_pending()
time.sleep(60)
Advanced Configuration
Group Notifications
To send alerts to a Telegram group:
- Add your bot to the group
- Make it an administrator (optional but recommended)
- Get the group Chat ID (negative number)
- Use the group Chat ID in your notifier:
notifier = TelegramNotifier(
bot_token=TELEGRAM_BOT_TOKEN,
chat_id="-987654321" # Group Chat ID
)
Multiple Recipients
Create multiple notifier instances for different recipients:
admin_notifier = TelegramNotifier(
bot_token=TELEGRAM_BOT_TOKEN,
chat_id=ADMIN_CHAT_ID
)
user_notifier = TelegramNotifier(
bot_token=TELEGRAM_BOT_TOKEN,
chat_id=USER_CHAT_ID
)
# Send critical alerts to admin
admin_notifier.send_signal(...)
# Send forecasts to user
user_notifier.send_prediction_alert(...)
Custom Alert Templates
Create your own message formats:
def send_custom_alert(notifier, data):
message = f"""
🎯 *CUSTOM ALERT*
💰 Pair: {data['symbol']}
📊 Metric: {data['metric']}
📈 Value: {data['value']}
⏰ {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
"""
return notifier.send_message(message)
Bot URL Helper
Generate a direct link to your bot:
from utils.telegram_notifier import create_telegram_bot_url
bot_url = create_telegram_bot_url(TELEGRAM_BOT_TOKEN)
print(f"Open your bot: {bot_url}")
See utils/telegram_notifier.py:174-185.
Troubleshooting
Bot Not Responding
Error: No message received after test_connection()
Solutions:
- Verify bot token is correct
- Check you’ve sent at least one message to the bot first
- Confirm Chat ID is accurate
- Ensure bot is not blocked
Unauthorized Error
Error: 401 Unauthorized
Solution: Your bot token is invalid. Create a new bot with @BotFather.
Forbidden Error
Error: 403 Forbidden: bot was blocked by the user
Solution:
- Open Telegram
- Search for your bot
- Click “Unblock” or “Start”
- Send a message to re-enable
Bad Request Error
Error: 400 Bad Request: chat not found
Solution: Your Chat ID is incorrect. Follow Step 2 again to get the correct ID.
Error: Can't parse entities
Solution:
- Check your Markdown syntax
- Escape special characters:
_, *, [, ], (, )
- Or switch to HTML parse mode
Rate Limiting
Error: 429 Too Many Requests
Solution:
- Telegram limits: 30 messages/second to same chat
- Add delays between bulk messages:
import time
for alert in alerts:
notifier.send_alert(**alert)
time.sleep(1) # 1 second delay
Security Best Practices
Never commit your bot token to version control! Anyone with your token can control your bot.
Secure Token Storage
- Store token in
.env file only
- Add
.env to .gitignore
- Use environment variables in production
- Rotate tokens if compromised
Token Management
If your token is exposed:
- Open @BotFather in Telegram
- Send
/mybots
- Select your bot
- Choose “API Token”
- Click “Revoke current token”
- Update
.env with new token
Chat ID Privacy
- Don’t share your Chat ID publicly
- Use group IDs for team notifications
- Consider separate bots for different projects
API Reference
TelegramNotifier Class
class TelegramNotifier:
def __init__(self, bot_token: str, chat_id: str)
def send_message(self, message: str, parse_mode: str = 'Markdown') -> bool
def send_alert(self, crypto: str, alert_type: str, current_value: float,
threshold: float, condition: str) -> bool
def send_prediction_alert(self, crypto: str, current_price: float,
predicted_price: float, hours: int,
change_pct: float, confidence: float) -> bool
def send_signal(self, crypto: str, signal: str, current_price: float,
rsi: float, macd_signal: str) -> bool
def test_connection(self) -> bool
Helper Functions
def create_telegram_bot_url(bot_token: str) -> str
Full implementation available in utils/telegram_notifier.py.
Next Steps
Configuration Settings
Configure alert thresholds and timeframes
Exchange Setup
Set up exchange API access