What if you could lend, borrow, and interact with DeFi protocols — just by chatting with an AI on Telegram?
That’s exactly what we explored in this hands-on workshop!
Learn how to build a DeFi-focused AI agent that interacts with lending and borrowing protocols on the Metis using Alith SDK.
In this workshop, we demonstrated building an AI-powered Telegram bot that can execute DeFi actions such as lending and borrowing via natural language, all while utilizing Alith’s agent framework.
Workshop Recording: Watch it on YouTube
Source Code: DEFI_Agent GitHub Repository
Prefer a written guide instead of watching the full recording? This blog and repo are perfect for you!
By the end of this tutorial, you’ll have your own agent that lends and borrows assets on Metis just by chatting!
Here’s what we’re building:
Natural Language → Blockchain Transactions — in a few simple steps!
Before you begin, ensure you have:
git clone https://github.com/Gmetisl2/DEFI_Agent.git
cd DEFI_Agent
Ensure that Python 3.x is installed on your system.
If not, download it from python.org.
Note: Python 3.x is required for compatibility.
python -m venv venv
source venv/bin/activate # On Linux/Mac
venv\Scripts\activate # On Windows
pip install -r requirements.txt
Create a .env file in the root directory:
PRIVATE_KEY=your_wallet_private_key
PUBLIC_ADDRESS=your_wallet_address
ALCHEMY_RPC_URL=https://andromeda.metis.io/?owner=1088
TELEGRAM_TOKEN=your_telegram_bot_token
LLM_API_KEY=your_deepseek_or_openai_api_key
project-root/
├── assets/ # ABI files for token contracts
├── defi_integration.py # Web3 transaction handling (lending, borrowing, repaying)
├── agent_runner.py # Main file to run the AI Agent
├── utils.py # Helper utilities
├── requirements.txt # Python dependencies
├── .env # Environment variables
└── README.md # Project documentation
1. Activate your virtual environment:
source venv/bin/activate
2. Run the AI Agent:
python Agent.py
The bot will:
Execute transactions on-chain!
In Telegram:
You: “Lend 1 USDC”
Bot: “Transaction approved. 1 USDC lent successfully.”
You: “Borrow 1 USDC”
Bot: “Transaction approved. 1 USDC borrowed against your collateral.”
At this stage, manual testing is recommended:
Coming Soon:
Make sure environment variables are correctly loaded.
Follow us on X for more updates: @MetisDevs
Feel free to join our developer community, collaborate, and ask questions!
We welcome contributions! Please:
Document any new functions or integrations
This project is licensed under the MIT License – see the LICENSE.md file for details.
By completing this project, you learned how to build an AI-driven DeFi agent that interacts with blockchain protocols using natural language prompts over Telegram.
You now have a working base to extend: add more DeFi integrations, improve AI strategies, or create your own trading bot!
Want to level up? Check out the Alith Agent Advanced Tutorials.