Skip to content

Transform your vocabulary with LexiBot - search words with AI, save definitions, get daily learning prompts, and build your lexicon collaboratively on Telegram.

Notifications You must be signed in to change notification settings

letsbegincode/Lexibot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“š Collaborative Vocabulary Bot

A Telegram bot powered by AI that helps users build and manage their vocabulary collaboratively. Built with Node.js, Prisma, and Google's Gemini AI.

✨ Features

πŸ€– Core Functionality

  • AI-Powered Word Search: Get detailed word information using Google Gemini AI
  • Collaborative Vocabulary: Share and manage words with authorized users
  • Smart Word Management: Add, search, find, and delete vocabulary words
  • Daily Automation: Morning prompts and evening recaps
  • Interactive Commands: Easy-to-use Telegram commands

πŸ“– Word Management

  • Search & Save (/sw [word]): Search for word definitions and automatically save them
  • Add Manually (/w): Add custom words with your own definitions
  • Find Words (/f [term]): Search through your vocabulary database
  • Delete Words (/delete [word]): Remove words from your collection
  • Recent Words (/dayX): View words added in the last X days

πŸŒ… Daily Features

  • Morning Prompts: Daily motivational quotes and word suggestions
  • Evening Recaps: Summary of all words added during the day
  • Word Suggestions: AI-generated vocabulary recommendations

πŸ” Search Capabilities

  • General Queries (/sq [query]): Ask anything and get AI-powered responses
  • Word Definitions: Comprehensive word information including pronunciation, meaning, examples, synonyms, and antonyms
  • Database Search: Find words by partial matches in word or description

πŸ› οΈ Tech Stack

  • Backend: Node.js with ES modules
  • Database: PostgreSQL with Prisma ORM
  • AI Integration: Google Gemini AI
  • Bot Framework: node-telegram-bot-api
  • Deployment: Vercel
  • Scheduling: Vercel Cron Jobs

πŸš€ Quick Start

Prerequisites

  • Node.js 18.x or higher
  • PostgreSQL database
  • Telegram Bot Token
  • Google Gemini API Key

1. Clone the Repository

git clone https://github.com/letsbegincode/Lexibot.git cd collaborative-bot-main

2. Install Dependencies

npm install

3. Environment Setup

Create a .env file in the root directory:

# Database DATABASE_URL="postgresql://username:password@localhost:5432/vocabulary_bot" # Telegram Bot TELEGRAM_BOT_TOKEN="your_telegram_bot_token" AUTHORIZED_USERS="user_id1,user_id2,user_id3" # AI Integration GEMINI_API_KEY="your_gemini_api_key"

4. Database Setup

# Generate Prisma client npx prisma generate # Run database migrations npx prisma migrate dev # (Optional) Seed database npx prisma db seed

5. Development

# Start development server npm run dev

πŸ“± Bot Commands

Command Description Example
/start or /help Show help menu /help
/sw [word] Search & save word /sw serendipity
/sq [query] Ask general questions /sq what is etymology?
/w Add word manually /w
/f [term] Find words in database /f creative
/delete [word] Delete word /delete serendipity
/dayX Recent words (X days) /day7
/test Test bot connection /test

πŸ”§ Configuration

Environment Variables

Variable Description Required
DATABASE_URL PostgreSQL connection string βœ…
TELEGRAM_BOT_TOKEN Your Telegram bot token βœ…
AUTHORIZED_USERS Comma-separated user IDs βœ…
GEMINI_API_KEY Google Gemini API key βœ…

Database Schema

model Word {  word String @id @unique  description String  addedByUserId BigInt  addedByName String  createdAt DateTime @default(now()) @db.Timestamptz(3) }

πŸš€ Deployment

Vercel Deployment

  1. Connect Repository: Link your GitHub repository to Vercel
  2. Environment Variables: Add all required environment variables in Vercel dashboard
  3. Build Settings:
    • Build Command: npm run build
    • Output Directory: api
  4. Deploy: Vercel will automatically deploy your bot

Webhook Setup

After deployment, set your Telegram webhook:

https://api.telegram.org/bot<YOUR_BOT_TOKEN>/setWebhook?url=https://your-vercel-app.vercel.app/api/bot 

πŸ“… Scheduled Tasks

The bot includes automated daily tasks:

  • Morning Prompt (3:30 AM): Sends motivational quotes and word suggestions
  • Evening Recap (5:30 PM): Summarizes all words added during the day

These are configured in vercel.json using Vercel Cron Jobs.

πŸ”’ Security Features

  • User Authorization: Only authorized users can access the bot
  • Environment Variables: All sensitive data stored securely
  • Input Validation: Proper validation for all user inputs
  • Error Handling: Comprehensive error handling and logging

πŸ“Š API Endpoints

Endpoint Method Description
/api/bot POST Main bot webhook handler
/api/search-query POST General search queries
/api/search-word POST Word-specific searches
/api/morning-promt GET Morning automation
/api/evening-recap GET Evening automation

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ†˜ Support

If you encounter any issues:

  1. Check the Issues page
  2. Verify your environment variables are set correctly
  3. Ensure your database is properly configured
  4. Check the bot logs in Vercel dashboard

πŸ™ Acknowledgments


Happy learning! πŸ“šβœ¨

About

Transform your vocabulary with LexiBot - search words with AI, save definitions, get daily learning prompts, and build your lexicon collaboratively on Telegram.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published