Build a Telegram Bot That Talks to the Blockchain (Part 5)
You’ve built something real.
From a few PHP scripts and the Allbridge Core API, you now have a Telegram bot that can track liquidity rewards, alert you when they cross your threshold, and display all your balances inside a single, simple chat window.
This is the final step in the journey - where your bot stops being a local experiment and becomes a real DeFi assistant.
And yes, you can try it live.

A quick recap of the journey
It all began with a simple idea: "what if Telegram could tell me when it’s time to claim my liquidity rewards?"
Here’s how that idea evolved through the series:
- Part 1: You installed the Allbridge Core REST API locally, created a Telegram bot via @BotFather, and implemented
/subscribeto capture blockchain, token, wallet address, and alert settings. - Part 2: You connected the bot to MySQL and added
/subscriptions- a live list of every wallet being tracked. - Part 3: You introduced a rewards table and taught the bot to record on-chain balances and rewards over time.
- Part 4: You automated it all - running
process_rewards.phpin cron to calculate differences and send alerts or daily summaries.
Now it’s ready for the real world.
🟢 Live bot: @allbridge_lp_bot
What the bot can already do
1. Add and monitor wallets
The /subscribe command walks users through every step: choose a chain, token, wallet address, reporting frequency, and threshold.
The bot saves all of this in wallets.
2. Fetch real on-chain data
The cron task queries the Allbridge Core API (/chains + /liquidity/details) to read liquidity positions and rewards.
Each result is stored in rewards as a historical snapshot.
3. Send smart notifications
When rewards rise beyond the threshold or when a scheduled report is due, the bot sends a clear Telegram message:
🎉 Your reward for Main Wallet increased by 5.3 USDT
Now claimable: 268.24 USDT
Balance: 1347.76 USDT
4. Act as a dashboard
The /subscriptions command shows every wallet with live balances and rewards in Markdown, complete with inline buttons for refresh or management.
You can edit, delete, or inspect wallets instantly - no dashboards, no browser tabs.
How it feels to use
The whole experience fits inside a conversation.
/start- welcomes you and lists available commands./subscribe- an interactive setup for any LP wallet./subscriptions- a clean, dynamic summary with management tools.
That’s it - no browser, no wallet connect, no network switching.
Your DeFi portfolio lives in one chat.
Under the hood
Telegram commands
StartCommand– friendly onboarding.SubscribeCommand– conversation-based setup wizard.SubscriptionsCommand– interactive dashboard.
System command
CallbackqueryCommand – handles every inline button (details, edit, delete, refresh).
Database
wallets- user + chain + token + address + rules.rewards- time series of balances and reward changes.
Automation
process_rewards.php - fetches data, stores snapshots, compares values, sends Telegram alerts.
It’s a full pipeline: on-chain → API → PHP → MySQL → Telegram.
What’s next - turning the bot into a DeFi analyst
Right now the bot focuses on your wallets.
But with a few extra scripts and queries, it can begin reading the market itself.
Here’s what can you implement next:
1. Watch all pools and alert on APR changes
Every 30 minutes:
- Fetch all pools from
/chains. - Store liquidity + reward data in pool_stats.
- Compare new APR values to previous ones.
If any pool’s APR jumps more than 5%, send a notification:
🚀 APR Alert
Pool: ETH/USDC
Chain: Ethereum
APR ↑ from 18 % to 23 % (+5 %)
Might be worth checking for new LP opportunities.
Your personal tracker just became a signal engine.
2. Monitor transaction flow for early insights
Go beyond static rewards - analyze pending transactions to spot:
- Arbitrage windows - detect large swaps or liquidity moves that momentarily distort prices.
- Trend signals - measure inflows/outflows every 30 minutes to see where liquidity is moving.
Rebalancing hints - combine your positions with APR data and flow direction:
💡 Strategy Hint
Your ETH/USDC on Ethereum → APR 14 %
Polygon ETH/USDC → APR 22 %, inflow +50 k USDC last hour
Consider partial rebalancing for better yield.
3. Portfolio-level reporting
The rewards table already stores history - aggregate it:
- Total LP across chains
- Daily reward growth
- Week-over-week performance
Send a digest once a day:
📈 Portfolio Summary
Total wallets: 4
24h reward change: +12.4 USDC
Current TVL: 6 842.9 USDC
Or visualize it later in a small web dashboard - Telegram stays your command center.
4. From personal tracker to community tool
Scale it for groups or projects:
- Auto-post public APR updates in channels.
- Publish health reports for bridges or pools.
- Add admin analytics commands: active users, top tracked pools, API errors, etc.
Same backend - bigger impact.
Final thoughts
It began as a side project - a couple of scripts, one database table, and curiosity.
Now you have:
- A fully working Telegram bot.
- A modular backend ready to scale.
- A clear roadmap to analytics, alerts, and insights.
You’ve built something simple yet powerful:
A chat-native DeFi assistant that monitors liquidity across chains, tracks your earnings, and talks to you when it matters.
And maybe - just maybe - you’ve learned something else along the way:
PHP isn’t that bad after all.
It can talk to blockchains, run crons, and even DM you about your rewards. Who knew?
So next time someone says "PHP is dead" show them a bot that tracks on-chain liquidity in real time and quietly whispers: "Rewards crossed your threshold."
Because your liquidity now has a voice - and apparently, it speaks PHP.
GitHub repository is available here.




-0a4714b2-c0f8-4c92-a0ea-e47c5d800587.png)