botserver/docs/src/chapter-01/README.md

179 lines
4.1 KiB
Markdown
Raw Normal View History

2025-11-21 12:13:48 -03:00
# Chapter 01: Run and Talk
2025-11-23 17:02:22 -03:00
**Zero to chatbot in 60 seconds.** This chapter gets BotServer running with a working bot you can talk to immediately.
2025-11-21 12:13:48 -03:00
2025-11-23 17:02:22 -03:00
## The One-Command Install
```bash
2025-11-21 12:13:48 -03:00
./botserver
```
2025-11-23 17:02:22 -03:00
That's literally it. First run triggers auto-bootstrap that:
- Installs PostgreSQL, cache, storage, vector DB
- Downloads AI models
- Creates default bot
- Starts web server
2025-11-21 12:13:48 -03:00
2025-11-23 17:02:22 -03:00
Takes 2-5 minutes. Grab coffee. Come back to a running bot.
2025-11-21 12:13:48 -03:00
2025-11-23 17:02:22 -03:00
## Your First Chat
2025-11-21 12:13:48 -03:00
2025-11-23 17:02:22 -03:00
Once bootstrap finishes:
2025-11-21 12:13:48 -03:00
2025-11-23 17:02:22 -03:00
1. Open browser to `http://localhost:8080`
2. Write a simple tool (see below)
3. Bot responds using GPT-3.5 (or local model)
2025-11-21 12:13:48 -03:00
2025-11-23 17:02:22 -03:00
No configuration. No API keys (for local). It just works.
2025-11-21 12:13:48 -03:00
2025-11-23 17:02:22 -03:00
## What's Actually Happening
2025-11-23 17:02:22 -03:00
Behind that simple `./botserver` command:
2025-11-21 12:13:48 -03:00
2025-11-23 17:02:22 -03:00
```
Installing PostgreSQL 16.2... ✓
Installing Valkey cache... ✓
Installing SeaweedFS storage... ✓
Installing Qdrant vectors... ✓
Downloading embeddings... ✓
Creating database schema... ✓
Generating secure credentials... ✓
Loading bot templates... ✓
Starting web server on :8080 ✓
```
2025-11-23 13:46:55 -03:00
2025-11-23 17:02:22 -03:00
Everything lands in `botserver-stack/` directory. Fully self-contained.
2025-11-23 13:46:55 -03:00
2025-11-23 17:02:22 -03:00
## Make Your Own Bot in 2 Minutes
2025-11-23 13:46:55 -03:00
2025-11-23 17:02:22 -03:00
### Step 1: Create Package
2025-11-23 13:46:55 -03:00
```bash
2025-11-23 17:02:22 -03:00
mkdir templates/my-bot.gbai
mkdir templates/my-bot.gbai/my-bot.gbdialog
2025-11-23 13:46:55 -03:00
```
2025-11-23 17:02:22 -03:00
### Step 2: Write Start Script
```bash
cat > templates/my-bot.gbai/my-bot.gbdialog/start.bas << 'EOF'
TALK "Hi! I'm your personal assistant."
TALK "What can I help you with?"
answer = HEAR
TALK "I can help you with: " + answer
EOF
2025-11-21 12:13:48 -03:00
```
2025-11-23 17:02:22 -03:00
### Step 3: Restart & Test
```bash
./botserver restart
# Visit http://localhost:8080/my-bot
2025-11-23 13:46:55 -03:00
```
2025-11-23 17:02:22 -03:00
Your bot is live.
2025-11-21 12:13:48 -03:00
2025-11-23 17:02:22 -03:00
## Adding Intelligence
2025-11-21 12:13:48 -03:00
2025-11-23 17:02:22 -03:00
### Give It Knowledge
Drop PDFs into knowledge base:
```bash
mkdir templates/my-bot.gbai/my-bot.gbkb
cp ~/Documents/policies.pdf templates/my-bot.gbai/my-bot.gbkb/
```
2025-11-23 13:46:55 -03:00
2025-11-23 17:02:22 -03:00
Bot instantly answers questions from your documents.
2025-11-21 12:13:48 -03:00
2025-11-23 17:02:22 -03:00
### Give It Tools
Create a tool for booking meetings:
```bash
cat > templates/my-bot.gbai/my-bot.gbdialog/book-meeting.bas << 'EOF'
PARAM person, date, time
DESCRIPTION "Books a meeting"
2025-11-21 12:13:48 -03:00
2025-11-23 17:02:22 -03:00
SAVE "meetings.csv", person, date, time
TALK "Meeting booked with " + person + " on " + date
EOF
2025-11-21 12:13:48 -03:00
```
2025-11-23 17:02:22 -03:00
Now just say "Book a meeting with John tomorrow at 2pm" - AI handles the rest.
2025-11-21 12:13:48 -03:00
2025-11-23 17:02:22 -03:00
## Optional Components
2025-11-23 13:46:55 -03:00
2025-11-23 17:02:22 -03:00
Want email? Video calls? Better models?
2025-11-23 17:02:22 -03:00
```bash
./botserver install email # Full email server
./botserver install meeting # Video conferencing
./botserver install llm # Local AI models
2025-11-21 12:13:48 -03:00
```
2025-11-23 17:02:22 -03:00
Each adds specific functionality. None required to start.
## File Structure After Bootstrap
2025-11-21 12:13:48 -03:00
```
2025-11-23 17:02:22 -03:00
botserver-stack/
postgres/ # Database files
valkey/ # Cache data
seaweedfs/ # Object storage
qdrant/ # Vector database
models/ # Embeddings
templates/
default.gbai/ # Default bot
my-bot.gbai/ # Your bot
.env # Auto-generated config
2025-11-21 12:13:48 -03:00
```
2025-11-23 17:02:22 -03:00
## Troubleshooting Quick Fixes
2025-11-21 12:13:48 -03:00
2025-11-23 17:02:22 -03:00
**Port already in use?**
```bash
HTTP_PORT=3000 ./botserver
```
2025-11-21 12:13:48 -03:00
2025-11-23 17:02:22 -03:00
**Bootstrap fails?**
```bash
./botserver cleanup
./botserver # Try again
```
2025-11-21 12:13:48 -03:00
2025-11-23 17:02:22 -03:00
**Want fresh start?**
```bash
rm -rf botserver-stack .env
./botserver
```
**Check what's running:**
```bash
./botserver status
```
2025-11-21 12:13:48 -03:00
2025-11-23 17:02:22 -03:00
## Container Deployment
2025-11-21 12:13:48 -03:00
2025-11-23 17:02:22 -03:00
Prefer containers? Use LXC mode:
```bash
./botserver --container
```
2025-11-21 12:13:48 -03:00
2025-11-23 17:02:22 -03:00
Creates isolated LXC containers for each component. Same auto-bootstrap, better isolation.
2025-11-21 12:13:48 -03:00
2025-11-23 17:02:22 -03:00
## What You've Learned
2025-11-21 12:13:48 -03:00
2025-11-23 17:02:22 -03:00
✅ BotServer installs itself completely
✅ Default bot works immediately
✅ Create new bots in minutes
✅ Add documents for instant knowledge
✅ Write tools for custom actions
2025-11-21 12:13:48 -03:00
## Next Steps
2025-11-23 17:02:22 -03:00
- **[Quick Start](./quick-start.md)** - Build a real bot
- **[Installation Details](./installation.md)** - How bootstrap works
- **[First Conversation](./first-conversation.md)** - Chat interface tour
- **[Sessions](./sessions.md)** - How conversations persist
2025-11-21 12:13:48 -03:00
2025-11-23 17:02:22 -03:00
## The Philosophy
2025-11-21 12:13:48 -03:00
2025-11-23 17:02:22 -03:00
We believe setup should be invisible. You want a bot, not a DevOps degree. That's why everything auto-configures. Focus on your bot's personality and knowledge, not infrastructure.
2025-11-21 12:13:48 -03:00
2025-11-23 17:02:22 -03:00
Ready for more? Continue to [Quick Start](./quick-start.md) to build something real.