I built a Telegram Bot with Node.js only!
In the ever-expanding world of blockchain and decentralized technologies, Telegram bots have become powerful tools for simplifying complex tasks. My journey of building a Telegram bot has been nothing short of transformative, blending creativity with technical problem-solving. Here, I share the insights, challenges, and roadmap that shaped this project.
The Vision
The idea was to create a bot that not only simplifies blockchain tasks but also provides a seamless user experience (UX). Key goals included:
- Wallet Creation: Allowing users to create wallets directly in the bot without redirecting to browsers.
- Token Management: Enabling users to create and mint tokens effortlessly.
- NFT Integration: Providing a robust platform for creating and managing NFTs.
- Permanent Image Storage: Leveraging Arweave for storing images securely.
- Liquidity Pools: (In v2) Implementing token liquidity pools to enhance token utility.
Key Features
1. Permanent Image Storage
- Users can upload images up to 5 MB, with a limit of 5 free images per user.
- Images are stored on Arweave, ensuring permanence and reliability.
2. Token Launchpad
- Users can create tokens by providing essential metadata such as name, symbol, description, and decimals.
- Wallet integration is a prerequisite to ensure security and usability.
3. NFT Launchpad
- Users can create either collectible or regular NFTs with ease.
- Metadata input for NFTs is handled with UX optimizations, including cancel and go-back options.
4. AI-Powered Chat
- An AI assistant to guide users through commands and processes.
5. Future Features (v2)
- Liquidity pools for tokens, accessible via the
/launchPool
command. - A marketplace for buying and selling NFTs and tokens.
The Development Process
1. Wallet Creation
- Wallet creation is integral, with strict warnings to users against sharing their secret keys.
- User’s public and private keys are stored securely in a database, with the private key hashed using the user’s password as a key.
2. Image Uploads
- Users can upload images directly or provide URLs.
- To mitigate Telegram’s compression issue, images are uploaded to Arweave for better quality preservation.
3. Token Creation
The /createToken
command prompts users for:
- Token name
- Image URL (or use
/uploadToArweave
to get one) - Description
- Symbol
- Decimals
Mint accounts are created with the wallet as the mint authority.
4. NFT Creation
- The
/createNFT
command distinguishes between collectible and regular NFTs. - Metadata collection is streamlined to ensure smooth processing.
5. Managing UX Challenges
- Inline keyboards with loading messages help users navigate time-intensive processes.
- Cancel and go-back options enhance usability.
6. Edge Cases and Code Quality
- Rigorous testing ensures all commands handle errors gracefully.
- Users are warned not to send conflicting commands during critical operations.
- Comprehensive fixes for start commands and user registration ensure seamless onboarding.
Commands Overview
General Commands
/start
: Introduces the bot and displays available commands along with the user’s balance.
Token Commands
/createToken
: Initiates token creation./mintToken
: Mints tokens to the user’s account or another specified account.
NFT Commands
/createNFT
: Guides users through creating collectibles or regular NFTs.
Image Storage Commands
/uploadToArweave
: Uploads images to Arweave and provides the link.
Lessons Learned
- User Experience is Paramount: Redirecting users out of Telegram disrupts the flow. Keeping processes within the bot ensures a better UX.
- Database Design: Restricting user actions (like free uploads) required a robust database schema to track usage metrics.
- Error Handling: Adding checks for edge cases and warnings against conflicting commands improved reliability.
- Security Matters: Hashing private keys and storing them securely is non-negotiable.
- Iterative Development: The roadmap for v2 includes advanced features like liquidity pools and marketplaces, highlighting the importance of phased development.