2025-10-08
admin
Diperbarui 2025-10-11

Cara Mudah Membuat Bot Telegram AI dengan Texa AI (5 Menit!)

Ingin punya bot Telegram AI sendiri? Ikuti panduan cepat ini untuk membuat bot dengan Texa AI dan Gemini API dalam hitungan menit! Dapatkan token, konfigurasi, dan kode siap pakai.
Cara Mudah Membuat Bot Telegram AI dengan Texa AI (5 Menit!)

🚀 Quick Start Guide - Texa AI Telegram Bot

Get your bot up and running in 5 minutes! ⚡

📋 Prerequisites Checklist

  • [ ] Node.js 18+ installed (Download)
  • [ ] Telegram account
  • [ ] Text editor (VSCode recommended)

🎯 Step-by-Step Setup

1️⃣ Get Telegram Bot Token (2 minutes)

  1. Open Telegram
  2. Search dan chat dengan @BotFather
  3. Send command: /newbot
  4. Enter bot name: Texa AI (or any name you want)
  5. Enter username: texa_ai_bot (must end with 'bot')
  6. Copy the token that looks like: 123456789:ABCdefGHIjklMNOpqrsTUVwxyz

Token saved! Keep it secret!

2️⃣ Get Google Gemini API Key (2 minutes)

  1. Visit: https://makersuite.google.com/app/apikey
  2. Click "Create API Key"
  3. Select "Create API key in new project"
  4. Copy the key that starts with AIzaSy...
  5. (Optional) Create 2-3 more keys for backup

API Key saved!

3️⃣ Setup Project (1 minute)

# Create project folder
mkdir texa-telegram-bot
cd texa-telegram-bot

# Create package.json
npm init -y

# Install dependencies
npm install node-telegram-bot-api @google/generative-ai

4️⃣ Create Bot File

Create file bot.js and paste the complete code from the artifact above, OR download from repository.

5️⃣ Configure Bot

Option A: Using .env file (Recommended)

  1. Create .env file:
TELEGRAM_BOT_TOKEN=your_telegram_token_here
GEMINI_API_KEY_1=your_gemini_key_here
GEMINI_API_KEY_2=your_backup_key_here
  1. Install dotenv:
npm install dotenv
  1. Add to top of bot.js:
require('dotenv').config()

Option B: Direct edit

Edit lines 10-15 in bot.js:

const TELEGRAM_TOKEN = 'YOUR_TOKEN_HERE'
const GEMINI_API_KEYS = [
    'YOUR_PRIMARY_KEY',
    'YOUR_BACKUP_KEY',
]

6️⃣ Run Bot! 🚀

npm start

You should see:

🤖 Texa AI ONLINE! Ready to vibe! ✨
📱 Bot username: @your_bot_username
✨ Start chatting: https://t.me/your_bot_username

7️⃣ Test Your Bot

  1. Open the bot link in Telegram
  2. Click START or send /start
  3. Bot should reply with welcome message!
  4. Try sending:
  • Text: Halo!
  • Image: Send any photo
  • Command: /help

🎉 Success!

Your bot is now live! 🔥

📱 What to Try Next

Basic Features

Send: Halo!
Send: Siapa kamu?
Send: /help
Send: /vibe
Send: /joke

Media Features

  • 📸 Send a photo with caption
  • 🎬 Send a video
  • 🎤 Send voice message
  • 📍 Share your location
  • 😄 Send stickers

Fun Commands

  • /vibe - Get random vibe
  • /joke - Random joke
  • /quote - Inspirational quote
  • /stats - Bot statistics
  • /forget - Reset conversation

🔥 Pro Tips

1. Multiple API Keys for Stability

GEMINI_API_KEY_1=primary_key
GEMINI_API_KEY_2=backup_key
GEMINI_API_KEY_3=third_key

Bot will auto-rotate if one fails!

2. Keep Bot Running 24/7

Using PM2:

npm install -g pm2
pm2 start bot.js --name texa-bot
pm2 startup
pm2 save

Using Screen (Linux):

screen -S texa-bot
node bot.js
# Press Ctrl+A then D to detach

Using nohup:

nohup node bot.js > output.log 2>&1 &

3. Monitor Bot Activity

# View logs
tail -f logs/bot.log

# Check bot status
pm2 status

# Restart bot
pm2 restart texa-bot

4. Update Bot Personality

Edit genZPhrases in bot.js:

const genZPhrases = {
    greetings: [
        'Your custom greetings!',
        'Add more here!'
    ],
    // ... customize more
}

5. Change Bot Name

const BOT_NAME = 'YourBotName'

🐛 Common Issues & Fixes

❌ Error: Invalid Token

Solution:

  • Check token from @BotFather
  • Make sure no spaces or extra characters
  • Token format: number:letters

❌ Error: Polling failed

Solution:

# Stop all node processes
killall node

# Restart bot
npm start

❌ Bot tidak merespon

Solution:

  1. Check logs: tail -f logs/bot.log
  2. Verify API keys are valid
  3. Check internet connection
  4. Restart bot

❌ Error: Cannot find module

Solution:

# Reinstall dependencies
rm -rf node_modules
npm install

❌ API Key quota exceeded

Solution:

  • Add more backup API keys
  • Wait for quota reset (usually 24h)
  • Check usage at Google AI Studio

📊 Monitor Performance

Check Statistics

Send /stats to bot:

📊 Bot Statistics ✨

👥 Total Users: 15
💬 Total Messages: 234
🔑 Active API Keys: 3
⏱️ Uptime: 125 minutes

Keep vibing! 🔥

View Detailed Logs

# Real-time monitoring
tail -f logs/bot.log | grep "✅"  # Success
tail -f logs/bot.log | grep "❌"  # Errors
tail -f logs/bot.log | grep "💬"  # Messages

# Count user interactions today
grep "$(date +%Y-%m-%d)" logs/bot.log | grep "💬" | wc -l

🚀 Deploy to Production

Free Hosting Options

1. Railway.app

# Push to GitHub first
git init
git add .
git commit -m "Initial commit"
git push

# Then deploy on Railway
# 1. Go to railway.app
# 2. New Project → Deploy from GitHub
# 3. Add environment variables
# 4. Deploy!

2. Render.com

  • Free tier available
  • Auto-deploy from GitHub
  • Easy environment variables setup

3. Heroku

# Create Procfile
echo "worker: node bot.js" > Procfile

# Deploy
heroku create texa-bot
git push heroku main
heroku config:set TELEGRAM_BOT_TOKEN=your_token
heroku config:set GEMINI_API_KEY_1=your_key

4. Your Own VPS (DigitalOcean, Linode, AWS)

# SSH to server
ssh user@your-server-ip

# Clone and setup
git clone your-repo-url
cd texa-telegram-bot
npm install

# Run with PM2
npm install -g pm2
pm2 start bot.js --name texa-bot
pm2 startup
pm2 save

📚 Next Steps

Enhance Your Bot

  1. Add Custom Commands
  • Edit handleCommand function
  • Add your own commands
  1. Customize Responses
  • Modify systemContext in chatWithAI
  • Change personality traits
  1. Add Database
  • Install MongoDB/PostgreSQL
  • Store user preferences
  • Save conversation history
  1. Add More Features
  • Weather updates
  • News fetching
  • Translation
  • Games/Quizzes
  1. Improve Analytics
  • Track popular commands
  • User engagement metrics
  • Response time monitoring

Learning Resources

💡 Creative Ideas

Bot Customization Ideas

  1. Theme-Based Bots
  • Gaming bot (esports updates, game tips)
  • Study bot (homework help, study tips)
  • Fitness bot (workout plans, motivation)
  • Music bot (recommendations, lyrics)
  1. Add Special Features
  • Daily motivational messages
  • Reminder system
  • Group chat moderation
  • Meme generator
  • Birthday reminders
  1. Integration Ideas
  • Weather API
  • News API
  • Spotify API
  • YouTube API
  • Twitter/X API

🎯 Success Checklist

  • [x] Bot token obtained
  • [x] Gemini API key obtained
  • [x] Dependencies installed
  • [x] Bot configured
  • [x] Bot running successfully
  • [x] Tested basic chat
  • [x] Tested media upload
  • [x] Commands working
  • [ ] Bot deployed to production
  • [ ] Monitoring setup
  • [ ] Backup keys configured

🆘 Need Help?

Resources

Debug Checklist

# 1. Check if Node.js is installed
node --version

# 2. Check if dependencies are installed
npm list

# 3. Check logs for errors
tail -n 50 logs/bot.log

# 4. Test API key manually
curl -H "Content-Type: application/json" \
  -d '{"contents":[{"parts":[{"text":"Hello"}]}]}' \
  "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp:generateContent?key=YOUR_API_KEY"

# 5. Check bot token
curl https://api.telegram.org/bot<YOUR_TOKEN>/getMe

🎊 Congratulations!

You now have a fully functional AI Telegram bot! 🎉

Keep building, keep learning! 🚀✨

Made with 💖 for Gen Z & Gen Alpha

Remember: Keep your tokens secret, keep your vibes positive! 🔥

blog teknologi artificial-intelligence programming admin

Artikel Terkait