Estimated Time: 30 minutes
Difficulty Level: ⭐⭐ Beginner
Difficulty Level: ⭐⭐ Beginner
Objective
Build a bot that monitors token prices and sends automatic notifications: Feature Checklist:- ✅ Subscribe to real-time price stream
- ✅ Set price change trigger conditions (> X%)
- ✅ Send Telegram notifications
- ✅ Support multi-token monitoring
Tech Stack
Prerequisites
- ChainStream account (to get Access Token)
- Node.js 18+
- Telegram Account
Step 1: Connect WebSocket
1.1 Install Dependencies
1.2 Create Project Structure
1.3 Configuration Files
.env:1.4 WebSocket Connection
index.js:Step 2: Set Trigger Conditions
Trigger conditions are configured inconfig.js:
Advanced Trigger Conditions
Can be extended to more complex conditions:Step 3: Send Notifications
3.1 Create Telegram Bot
1
Create Bot
Search for
@BotFather in Telegram, send /newbot2
Get Token
Follow prompts to create Bot, get Bot Token
3
Get Chat ID
- Send a message to your Bot
- Visit
https://api.telegram.org/bot<TOKEN>/getUpdates - Find
chat.id
3.2 Telegram Notification Module
bot.js:Verify Installation
Run Bot
Expected Output
Trigger Test
Temporarily set threshold to 0.01% for quick testing:Extension Suggestions
- Multi-Token Monitoring
- Persistent Storage
- Web Dashboard
- Multi-Channel Notifications
FAQ
WebSocket connection failed?
WebSocket connection failed?
- Check if Access Token is correct
- Confirm network can access ChainStream
- Check if firewall is blocking WebSocket
Not receiving Telegram notifications?
Not receiving Telegram notifications?
- Confirm Bot Token is correct
- Confirm Chat ID is correct
- Make sure you’ve sent a message to the Bot (activate conversation)
How to monitor more tokens?
How to monitor more tokens?
Add more configurations to the
WATCH_TOKENS array in config.js.Related Documentation
WebSocket API
WebSocket subscription details
Webhook Fundamentals
Use Webhook instead of WebSocket

