diff --git a/src/SUMMARY.md b/src/SUMMARY.md
index 6b22d197..9d27084e 100644
--- a/src/SUMMARY.md
+++ b/src/SUMMARY.md
@@ -112,7 +112,7 @@
- [store.bas](./chapter-06-gbdialog/templates/store.md)
- [talk-to-data.bas](./chapter-06-gbdialog/templates/talk-to-data.md)
- [whatsapp.bas](./chapter-06-gbdialog/templates/whatsapp.md)
- - [Consolidated Examples](./chapter-06-gbdialog/examples-consolidated.md)
+ - [Webhook Integrations and Jobs](./chapter-06-gbdialog/examples-consolidated.md)
- [Data Sync Tools](./chapter-06-gbdialog/tools-data-sync.md)
- [Keywords Reference](./chapter-06-gbdialog/keywords.md)
- [TALK](./chapter-06-gbdialog/keyword-talk.md)
@@ -357,6 +357,7 @@
- [Storage Services](./appendix-external-services/storage.md)
- [Directory Services](./appendix-external-services/directory.md)
- [Attendance Queue](./appendix-external-services/attendance-queue.md)
+ - [Hosting, DNS, and MDA](./appendix-external-services/hosting-dns.md)
- [Time-Series Database](./appendix-external-services/timeseries.md)
- [NVIDIA GPU](./appendix-external-services/nvidia.md)
- [Multimodal](./appendix-external-services/multimodal.md)
@@ -365,6 +366,7 @@
- [Appendix C: Environment Variables](./appendix-env-vars/README.md)
- [Appendix D: Documentation Style](./appendix-docs-style/conversation-examples.md)
+ - [SVG and Conversation Standards](./appendix-docs-style/svg.md)
[Glossary](./glossary.md)
[Contact](./contact/README.md)
\ No newline at end of file
diff --git a/src/appendix-docs-style/svg.md b/src/appendix-docs-style/svg.md
new file mode 100644
index 00000000..dd4f9795
--- /dev/null
+++ b/src/appendix-docs-style/svg.md
@@ -0,0 +1,191 @@
+# Documentation Style Standards
+
+All interface layouts in this documentation use SVG-based wireframe representations for screenshots and diagrams. Conversation examples use the WhatsApp-style HTML format for consistent, visually appealing rendering.
+
+---
+
+## Interface Wireframes (SVG)
+
+All interface screenshots and layouts should use SVG wireframes located in `/assets/`.
+
+### Directory Structure
+
+```
+assets/
+├── suite/
+│ ├── chat-screen.svg
+│ ├── drive-screen.svg
+│ ├── calendar-screen.svg
+│ ├── mail-screen.svg
+│ ├── tasks-screen.svg
+│ ├── meet-screen.svg
+│ ├── live-monitoring-organism.svg
+│ └── ...
+├── chapter-01/
+│ ├── bootstrap-process.svg
+│ └── session-states.svg
+└── chapter-04/
+ └── analytics-interface.svg
+```
+
+### Referencing SVG Wireframes
+
+Use standard HTML image syntax with responsive styling:
+
+```html
+
+```
+
+---
+
+## Conversation Examples (WhatsApp Style)
+
+All conversation examples throughout the book use the WhatsApp-style HTML format. This provides a familiar, visually consistent representation of bot interactions.
+
+### Standard Format
+
+```html
+
` tags for each line
+5. **Emojis** — Use sparingly for status indicators (✅, ❌, 📧, 📅, 📁)
+6. **Bold text** — Use `` for emphasis
+7. **Attachments** — Indicate with 📎 emoji and filename
+
+### File Attachments Example
+
+```html
+
@@ -14,113 +14,109 @@ The dashboard displays BotServer at the center orchestrating all interactions, w
- **Top**: Real-time metrics panels for sessions, messages, and response time
- **Bottom**: Resource utilization bars and activity ticker
+---
+
## Accessing the Dashboard
-Access monitoring from the Suite interface:
+The monitoring dashboard is the **default homepage** when accessing Suite:
+
+```/dev/null/monitoring-url.txt#L1
+http://localhost:8080/monitoring
+```
+
+Or from within Suite:
1. Click the apps menu (⋮⋮⋮)
2. Select **Monitoring**
-3. Or navigate directly to `/monitoring`
-## Dashboard Features
+---
-### Animated System Architecture
+## Real-Time Metrics
-The SVG visualization shows real-time data flow:
+### Active Sessions Panel
-| Component | Color | Description |
-|-----------|-------|-------------|
-| **BotServer** | Blue/Purple | Central orchestrator with rotating ring |
-| **PostgreSQL** | Blue | Primary database with cylinder icon |
-| **Qdrant** | Purple | Vector database with triangle nodes |
-| **MinIO** | Amber | Object storage with disk icon |
-| **BotModels** | Pink | AI/ML service with neural network icon |
-| **Cache** | Cyan | In-memory cache with lightning icon |
-| **Vault** | Green | Secrets management with lock icon |
+Displays current conversation sessions:
+
+```/dev/null/sessions-example.txt#L1-4
+Active Sessions: 12
+Peak Today: 47
+Avg Duration: 8m 32s
+Trend: ↑ +3 in last hour
+```
+
+### Messages Panel
+
+Shows message throughput:
+
+```/dev/null/messages-example.txt#L1-4
+Today: 1,234 messages
+This Hour: 89
+Avg Response: 1.2s
+Rate: 14.8 msg/min
+```
+
+### Resource Utilization
+
+Real-time system resources:
+
+| Resource | Current | Threshold |
+|----------|---------|-----------|
+| **CPU** | 65% | Warning > 80% |
+| **Memory** | 72% | Warning > 85% |
+| **GPU** | 45% | Warning > 90% |
+| **Disk** | 28% | Warning > 90% |
+
+---
+
+## Service Health Status
+
+Each service has a status indicator:
+
+| Service | Status | Health Check |
+|---------|--------|--------------|
+| **PostgreSQL** | 🟢 Running | Connection pool, query latency |
+| **Qdrant** | 🟢 Running | Vector count, search time |
+| **MinIO** | 🟢 Running | Storage usage, object count |
+| **BotModels** | 🟢 Running | Token usage, response time |
+| **Cache** | 🟢 Running | Hit rate, memory usage |
+| **Vault** | 🟢 Running | Seal status, policy count |
### Status Indicators
-Each service has a status dot:
-
| Status | Color | Animation |
|--------|-------|-----------|
| **Running** | 🟢 Green | Gentle pulse |
| **Warning** | 🟡 Amber | Fast pulse |
| **Stopped** | 🔴 Red | No animation |
-### Real-Time Metrics
+---
-Three metric panels at the top update automatically:
+## Live Data Endpoints
-| Panel | Update Interval | Description |
-|-------|-----------------|-------------|
-| **Active Sessions** | 5 seconds | Current open conversations with trend |
-| **Messages Today** | 10 seconds | Total messages with hourly rate |
-| **Avg Response** | 10 seconds | Average response time in milliseconds |
-
-### Resource Utilization
-
-Resource bars show system health:
-
-| Resource | Gradient | Warning Threshold |
-|----------|----------|-------------------|
-| **CPU** | Blue/Purple | > 80% |
-| **Memory** | Green | > 85% |
-| **GPU** | Purple | > 90% |
-| **Disk** | Amber | > 90% |
-
-### Activity Ticker
-
-A live ticker at the bottom shows the latest system events with a pulsing green indicator.
-
-## View Modes
-
-Toggle between two views using the grid button or press `V`:
-
-### Live View (Default)
-The animated SVG visualization showing the complete system topology with flowing data packets.
-
-### Grid View
-Traditional panel-based layout with detailed tree views for each metric category:
-- Sessions panel with active, peak, and duration
-- Messages panel with counts and rates
-- Resources panel with progress bars
-- Services panel with health status
-- Bots panel with active bot list
-
-## Keyboard Shortcuts
-
-| Shortcut | Action |
-|----------|--------|
-| `V` | Toggle between Live and Grid view |
-| `R` | Refresh all metrics |
-
-## HTMX Integration
-
-The dashboard uses HTMX for real-time updates without full page reloads:
+The dashboard pulls real data from these HTMX endpoints:
| Endpoint | Interval | Data |
|----------|----------|------|
-| `/api/monitoring/metric/sessions` | 5s | Session count |
-| `/api/monitoring/metric/messages` | 10s | Message count |
-| `/api/monitoring/metric/response_time` | 10s | Avg response |
-| `/api/monitoring/resources/bars` | 15s | Resource SVG bars |
+| `/api/monitoring/metric/sessions` | 5s | Session count, trend |
+| `/api/monitoring/metric/messages` | 10s | Message count, rate |
+| `/api/monitoring/metric/response_time` | 10s | Avg response time |
+| `/api/monitoring/resources/bars` | 15s | CPU, memory, GPU, disk |
| `/api/monitoring/services/status` | 30s | Service health JSON |
-| `/api/monitoring/activity/latest` | 5s | Activity text |
-| `/api/monitoring/timestamp` | 5s | Last updated time |
+| `/api/monitoring/activity/latest` | 5s | Activity ticker text |
+| `/api/monitoring/bots/active` | 30s | Active bot list |
+
+---
## API Access
-Access monitoring data programmatically:
+### Full Status Endpoint
-### Get Full Status
-
-```/dev/null/monitoring-api.txt
+```/dev/null/api-call.txt#L1
GET /api/monitoring/status
```
-**Response:**
+Returns complete system status:
-```/dev/null/monitoring-response.json
+```/dev/null/monitoring-response.json#L1-25
{
"sessions": {
"active": 12,
@@ -149,31 +145,89 @@ GET /api/monitoring/status
}
```
-### Service-Specific Endpoints
+### Active Bots Endpoint
-| Endpoint | Returns |
-|----------|---------|
-| `/api/monitoring/services` | All service details |
-| `/api/monitoring/bots` | Active bot list |
-| `/api/monitoring/history?period=24h` | Historical metrics |
-| `/api/monitoring/prometheus` | Prometheus format export |
+```/dev/null/bots-api.txt#L1
+GET /api/monitoring/bots
+```
-## Component Health Details
+Returns list of deployed bots with metrics:
-| Component | Health Check | Warning Signs |
-|-----------|--------------|---------------|
-| **PostgreSQL** | Connection count, query rate | > 80 connections, slow queries |
-| **Qdrant** | Vector count, search latency | > 50ms search time |
-| **MinIO** | Storage usage, object count | > 80% storage used |
-| **BotModels** | Token usage, response latency | > 2s response time |
-| **Vault** | Seal status, policy count | Unsealed without auth |
-| **Cache** | Hit rate, memory usage | < 80% hit rate |
+```/dev/null/bots-response.json#L1-18
+{
+ "bots": [
+ {
+ "name": "default",
+ "status": "active",
+ "sessions_today": 34,
+ "messages_today": 567,
+ "avg_response_ms": 980
+ },
+ {
+ "name": "support",
+ "status": "active",
+ "sessions_today": 12,
+ "messages_today": 234,
+ "avg_response_ms": 1100
+ }
+ ]
+}
+```
-## Alerts Configuration
+### Historical Data
+
+```/dev/null/history-api.txt#L1
+GET /api/monitoring/history?period=24h
+```
+
+Returns time-series data for charting.
+
+### Prometheus Export
+
+```/dev/null/prometheus-api.txt#L1
+GET /api/monitoring/prometheus
+```
+
+Returns metrics in Prometheus format for external monitoring systems.
+
+---
+
+## View Modes
+
+Toggle between two views using the grid button or press `V`:
+
+### Live View (Default)
+
+The animated SVG visualization showing the complete system topology with flowing data packets. This is the recommended view for operations dashboards.
+
+### Grid View
+
+Traditional panel-based layout with detailed metrics:
+
+- **Sessions Panel**: Active, peak, average duration
+- **Messages Panel**: Counts, rates, response times
+- **Resources Panel**: Progress bars with thresholds
+- **Services Panel**: Health status for each component
+- **Bots Panel**: List of active bots with metrics
+
+---
+
+## Keyboard Shortcuts
+
+| Shortcut | Action |
+|----------|--------|
+| `V` | Toggle between Live and Grid view |
+| `R` | Refresh all metrics immediately |
+| `F` | Toggle fullscreen mode |
+| `?` | Show keyboard shortcuts |
+
+---
+
+## Alert Configuration
Configure alert thresholds in `config.csv`:
-```/dev/null/config-alerts.csv
+```/dev/null/config-alerts.csv#L1-6
name,value
alert-cpu-threshold,80
alert-memory-threshold,85
@@ -182,78 +236,93 @@ alert-response-time-ms,5000
alert-email,admin@example.com
```
-## Console Mode
+When thresholds are exceeded:
+1. Service status turns amber/red
+2. Alert notification sent to configured email
+3. Activity ticker shows alert message
-For terminal-based monitoring:
+---
-```/dev/null/console-command.bash
+## Console Mode Monitoring
+
+For terminal-based monitoring or headless servers:
+
+```/dev/null/console-command.sh#L1
./botserver --console --monitor
```
Output:
-```/dev/null/console-output.txt
+
+```/dev/null/console-output.txt#L1-6
[MONITOR] 2025-01-15 14:32:00
Sessions: 12 active (peak: 47)
Messages: 1,234 today (89/hour)
CPU: 65% | MEM: 72% | GPU: 45%
Services: 6/6 running
+Latest: User enrolled in Computer Science course
```
-## Tips & Best Practices
+---
-💡 **Watch the data packets** - Flowing animations indicate active communication between components
+## Component Health Details
-💡 **Monitor trends** - The session trend indicator (↑/↓) shows direction of change
+| Component | Metrics Monitored | Warning Signs |
+|-----------|-------------------|---------------|
+| **PostgreSQL** | Connection count, query rate, replication lag | > 80 connections, queries > 100ms |
+| **Qdrant** | Vector count, search latency, memory | > 50ms search, > 80% memory |
+| **MinIO** | Storage usage, object count, bandwidth | > 80% storage, high error rate |
+| **BotModels** | Token usage, response latency, queue depth | > 2s response, queue > 10 |
+| **Vault** | Seal status, policy count, auth failures | Sealed, repeated auth failures |
+| **Cache** | Hit rate, memory usage, evictions | < 80% hit rate, frequent evictions |
-💡 **Click services** - Click any service node in Live view to see detailed status
+---
-💡 **Set up alerts** - Configure thresholds before issues become critical
+## Best Practices
-💡 **Use keyboard shortcuts** - Press `R` for quick refresh, `V` to toggle views
+1. **Keep monitoring visible** — Use a dedicated screen or dashboard monitor for operations
+2. **Set appropriate thresholds** — Configure alerts before issues become critical
+3. **Watch data flow** — Animated packets indicate active communication between components
+4. **Monitor trends** — The session trend indicator (↑/↓) shows direction of change
+5. **Use historical data** — Query `/api/monitoring/history` for trend analysis
+6. **Enable Prometheus export** — Integrate with existing monitoring infrastructure
-💡 **Check historical data** - Query `/api/monitoring/history` for trend analysis
+---
## Troubleshooting
-### Dashboard not loading
+### Dashboard Not Loading
-**Possible causes:**
-1. WebSocket connection failed
-2. API endpoint unreachable
-3. Browser blocking HTMX
-
-**Solution:**
1. Check browser console for errors
2. Verify `/api/monitoring/status` returns data
-3. Refresh the page
+3. Ensure WebSocket connection is established
+4. Refresh the page
-### Metrics showing "--"
+### Metrics Showing "--"
-**Possible causes:**
-1. Initial load in progress
-2. API timeout
-3. Service unavailable
+1. Wait 5-10 seconds for initial data load
+2. Check network tab for failed API requests
+3. Verify all services are running
+4. Check BotServer logs for errors
-**Solution:**
-1. Wait 5-10 seconds for first update
-2. Check network tab for failed requests
-3. Verify services are running
+### Animations Stuttering
-### Animations stuttering
-
-**Possible causes:**
-1. High CPU usage
-2. Many browser tabs open
-3. Hardware acceleration disabled
-
-**Solution:**
-1. Close unused tabs
-2. Enable hardware acceleration in browser
+1. Close unused browser tabs
+2. Enable hardware acceleration in browser settings
3. Use Grid view for lower resource usage
+4. Check if system CPU is overloaded
+
+### Service Showing Red
+
+1. Check service-specific logs in `botserver-stack/logs/`
+2. Verify Vault is unsealed
+3. Check database connection limits
+4. Restart the affected service
+
+---
## See Also
-- [Monitoring API Reference](../chapter-10-api/monitoring-api.md)
-- [Console Mode](./console-mode.md)
-- [Configuration Options](../chapter-08-config/README.md)
-- [Analytics App](./apps/analytics.md)
\ No newline at end of file
+- [Console Mode](./console-mode.md) — Terminal-based interface
+- [HTMX Architecture](./htmx-architecture.md) — How real-time updates work
+- [Suite Manual](./suite-manual.md) — Complete user guide
+- [Analytics App](./apps/analytics.md) — Business metrics and reporting
\ No newline at end of file
diff --git a/src/chapter-06-gbdialog/examples-consolidated.md b/src/chapter-06-gbdialog/examples-consolidated.md
index 1d52f6e2..58976103 100644
--- a/src/chapter-06-gbdialog/examples-consolidated.md
+++ b/src/chapter-06-gbdialog/examples-consolidated.md
@@ -1,97 +1,16 @@
-# Consolidated Examples: Complete Tools & Workflows
+# Webhook Integrations and Jobs Examples
-This document provides complete, production-ready examples that demonstrate how multiple keywords work together to build real-world tools and automation workflows.
+This document provides complete, production-ready examples demonstrating webhook endpoints and scheduled jobs. All examples use event-driven patterns—no conversation loops.
-## 1. Customer Support Bot with AI
+---
-A complete customer support solution with knowledge base, ticket creation, and escalation.
+## 1. E-Commerce Order Management System
-```basic
-' customer-support.bas
-' Complete customer support tool with AI-powered responses
+Complete order processing with inventory, payments, and notifications via webhook.
-' Initialize knowledge bases
-USE KB "product-docs"
-USE KB "faq"
-USE KB "policies"
-
-' Set AI personality
-SET CONTEXT "You are a helpful customer support agent for TechCorp. Be friendly, professional, and concise. If you cannot answer a question, offer to create a support ticket."
-
-' Main conversation loop
-TALK "Hello! I'm your TechCorp support assistant. How can I help you today?"
-
-conversation_active = TRUE
-
-WHILE conversation_active
- HEAR user_message
-
- ' Check for exit commands
- IF INSTR(LCASE(user_message), "bye") > 0 OR INSTR(LCASE(user_message), "exit") > 0 THEN
- TALK "Thank you for contacting TechCorp support. Have a great day!"
- conversation_active = FALSE
- ELSE IF INSTR(LCASE(user_message), "ticket") > 0 OR INSTR(LCASE(user_message), "human") > 0 THEN
- ' User wants to create a ticket or talk to human
- TALK "I'll create a support ticket for you. Please describe your issue in detail."
- HEAR issue_description
-
- TALK "What's your email address?"
- HEAR customer_email
-
- ' Create ticket in database
- ticket_id = "TKT-" + FORMAT(NOW(), "YYYYMMDDHHmmss")
- description = issue_description
- ticket_status = "open"
- priority = "normal"
- created_at = NOW()
- conversation_history = user_message
-
- SAVE "support_tickets", ticket_id, customer_email, description, ticket_status, priority, created_at, conversation_history
-
- ticket_result = ticket_id
- ticket_id = ticket_result.id
-
- ' Send confirmation email
- email_body = "Your support ticket #" + ticket_id + " has been created. Our team will respond within 24 hours."
- SEND MAIL customer_email, "Support Ticket Created - #" + ticket_id, email_body
-
- ' Notify support team
- SEND MAIL "support@techcorp.com", "New Ticket #" + ticket_id, "Customer: " + customer_email + "\n\nIssue: " + issue_description
-
- TALK "I've created ticket #" + ticket_id + ". You'll receive a confirmation email shortly. Is there anything else I can help with?"
- ELSE
- ' Use AI to answer the question
- response = LLM user_message
- TALK response
-
- ' Log the conversation
- question = user_message
- answer = response
- log_timestamp = NOW()
- INSERT "conversation_logs", question, answer, log_timestamp
-
- TALK "Did that answer your question? (yes/no/create ticket)"
- HEAR feedback
-
- IF INSTR(LCASE(feedback), "no") > 0 THEN
- TALK "I'm sorry I couldn't help. Would you like me to create a support ticket? (yes/no)"
- HEAR create_ticket
- IF INSTR(LCASE(create_ticket), "yes") > 0 THEN
- ' Trigger ticket creation on next loop
- user_message = "create ticket"
- END IF
- END IF
- END IF
-WEND
-```
-
-## 2. E-Commerce Order Management System
-
-Complete order processing with inventory, payments, and notifications.
-
-```basic
+```botbook/src/chapter-06-gbdialog/examples-consolidated.bas#L1-80
' order-system.bas
-' E-commerce order management tool
+' E-commerce order management webhook
WEBHOOK "new-order"
@@ -106,10 +25,8 @@ payment_token = body.payment.token
' Validate order
IF order_id = "" OR customer_email = "" THEN
- WITH result = NEW OBJECT
- .status = 400
- .error = "Missing required fields"
- END WITH
+ result_status = 400
+ result_error = "Missing required fields"
EXIT
END IF
@@ -126,35 +43,20 @@ FOR EACH item IN items
NEXT item
IF NOT inventory_ok THEN
- ' Notify customer of stock issue
SEND MAIL customer_email, "Order Issue - Items Out of Stock", "Unfortunately, the following items are out of stock: " + out_of_stock_items
-
- WITH result = NEW OBJECT
- .status = 400
- .error = "Items out of stock"
- .items = out_of_stock_items
- END WITH
+ result_status = 400
+ result_error = "Items out of stock"
EXIT
END IF
' Process payment
-WITH payment_request = NEW OBJECT
- .amount = body.total
- .currency = "USD"
- .token = payment_token
- .description = "Order " + order_id
-END WITH
-
SET HEADER "Authorization", "Bearer " + GET BOT MEMORY "stripe_key"
-payment_result = POST "https://api.stripe.com/v1/charges", payment_request
+payment_result = POST "https://api.stripe.com/v1/charges", body.total, "USD", payment_token, "Order " + order_id
IF payment_result.status <> "succeeded" THEN
SEND MAIL customer_email, "Payment Failed", "Your payment could not be processed. Please try again."
-
- WITH result = NEW OBJECT
- .status = 402
- .error = "Payment failed"
- END WITH
+ result_status = 402
+ result_error = "Payment failed"
EXIT
END IF
@@ -162,74 +64,40 @@ END IF
FOR EACH item IN items
current_stock = FIND "products", "sku=" + item.sku
new_stock = current_stock.stock - item.quantity
+ UPDATE "products", "sku=" + item.sku, new_stock, NOW()
- WITH stock_update = NEW OBJECT
- .stock = new_stock
- .updated_at = NOW()
- END WITH
- UPDATE "products", "sku=" + item.sku, stock_update
-
- ' Alert if low stock
IF new_stock < 10 THEN
SEND MAIL "inventory@company.com", "Low Stock Alert: " + item.sku, "Stock level: " + new_stock
END IF
NEXT item
-' Create order record
-WITH order_record = NEW OBJECT
- .order_id = order_id
- .customer_email = customer_email
- .customer_name = customer_name
- .items = items
- .total = body.total
- .shipping_address = shipping_address
- .payment_id = payment_result.id
- .status = "confirmed"
- .created_at = NOW()
-END WITH
+' Save order record
+SAVE "orders", order_id, customer_email, customer_name, items, body.total, shipping_address, payment_result.id, "confirmed", NOW()
-SAVE "orders", order_id, order_record
-
-' Generate invoice PDF - pass variables directly
-invoice_customer = customer_name
-invoice_email = customer_email
-invoice_items = order_items
-subtotal = body.subtotal
-tax = body.tax
-shipping_cost = body.shipping_cost
-invoice_date = FORMAT(NOW(), "MMMM DD, YYYY")
-
-invoice_pdf = GENERATE PDF "templates/invoice.html", order_id, invoice_customer, invoice_email, invoice_items, subtotal, tax, shipping_cost, total, invoice_date, "invoices/" + order_id + ".pdf"
-
-' Send confirmation email with invoice
-email_body = "Thank you for your order, " + customer_name + "!\n\n"
-email_body = email_body + "Order #: " + order_id + "\n"
-email_body = email_body + "Total: $" + body.total + "\n\n"
-email_body = email_body + "Your invoice is attached. You'll receive shipping updates soon."
+' Generate invoice PDF
+invoice_pdf = GENERATE PDF "templates/invoice.html", order_id, customer_name, customer_email, items, body.subtotal, body.tax, body.shipping_cost, body.total, FORMAT(NOW(), "MMMM DD, YYYY"), "invoices/" + order_id + ".pdf"
+' Send confirmation email
+email_body = "Thank you for your order, " + customer_name + "!\n\nOrder #: " + order_id + "\nTotal: $" + body.total + "\n\nYour invoice is attached."
SEND MAIL customer_email, "Order Confirmed - #" + order_id, email_body, invoice_pdf.url
-' Notify warehouse - build simple notification
-warehouse_order_id = order_id
-warehouse_items = items
-warehouse_address = shipping_address
-warehouse_priority = "normal"
-POST "https://warehouse.internal/api/orders", warehouse_order_id, warehouse_items, warehouse_address, warehouse_priority
+' Notify warehouse
+POST "https://warehouse.internal/api/orders", order_id, items, shipping_address, "normal"
-' Return success
result_status = "confirmed"
result_order_id = order_id
result_payment_id = payment_result.id
-result_invoice_url = invoice_pdf.url
```
-## 3. HR Onboarding Automation
+---
-Complete employee onboarding workflow.
+## 2. HR Onboarding Automation
-```basic
+Complete employee onboarding workflow triggered by webhook.
+
+```botbook/src/chapter-06-gbdialog/examples-consolidated.bas#L82-150
' onboarding.bas
-' HR onboarding automation tool
+' HR onboarding automation webhook
WEBHOOK "new-employee"
@@ -242,25 +110,14 @@ role = body.role
' Validate input
IF employee_email = "" OR employee_name = "" THEN
- WITH result = NEW OBJECT
- .status = 400
- .error = "Missing employee name or email"
- END WITH
+ result_status = 400
+ result_error = "Missing employee name or email"
EXIT
END IF
' Create employee record
employee_id = "EMP-" + FORMAT(NOW(), "YYYYMMDD") + "-" + LEFT(GUID(), 4)
-emp_name = employee_name
-emp_email = employee_email
-emp_department = department
-emp_role = role
-emp_manager = manager_email
-emp_start_date = start_date
-emp_status = "onboarding"
-created_at = NOW()
-
-SAVE "employees", employee_id, emp_name, emp_email, emp_department, emp_role, emp_manager, emp_start_date, emp_status, created_at
+SAVE "employees", employee_id, employee_name, employee_email, department, role, manager_email, start_date, "onboarding", NOW()
' Create tasks for IT setup
CREATE TASK "Create email account for " + employee_name, "it@company.com", start_date
@@ -275,25 +132,16 @@ CREATE TASK "Add " + employee_name + " to benefits enrollment", "hr@company.com"
' Send welcome email to new employee
USE KB "employee-handbook"
SET CONTEXT "You are a friendly HR assistant. Create a warm, professional welcome message."
-
welcome_content = LLM "Write a welcome email for " + employee_name + " joining as " + role + " in " + department + " department, starting on " + start_date
-
SEND MAIL employee_email, "Welcome to the Team, " + employee_name + "!", welcome_content
' Notify manager
-manager_message = "New team member alert!\n\n"
-manager_message = manager_message + employee_name + " will be joining your team as " + role + " on " + start_date + ".\n\n"
-manager_message = manager_message + "Please prepare:\n"
-manager_message = manager_message + "- First week schedule\n"
-manager_message = manager_message + "- Team introduction meeting\n"
-manager_message = manager_message + "- Project assignments\n"
-
+manager_message = "New team member alert!\n\n" + employee_name + " will be joining your team as " + role + " on " + start_date + ".\n\nPlease prepare:\n- First week schedule\n- Team introduction meeting\n- Project assignments"
SEND MAIL manager_email, "New Team Member: " + employee_name, manager_message
-' Add to department Slack channel
+' Post to Slack
slack_channel = "#" + LCASE(department)
-slack_text = "🎉 Please welcome " + employee_name + " who will be joining us as " + role + " on " + start_date + "!"
-POST "https://hooks.slack.com/services/xxx", slack_channel, slack_text
+POST "https://hooks.slack.com/services/xxx", slack_channel, "🎉 Please welcome " + employee_name + " who will be joining us as " + role + " on " + start_date + "!"
' Schedule 30-60-90 day check-ins
check_in_dates = [30, 60, 90]
@@ -302,18 +150,18 @@ FOR EACH days IN check_in_dates
CREATE TASK days + "-day check-in with " + employee_name, manager_email, check_in_date
NEXT days
-' Return success
result_status = "success"
result_employee_id = employee_id
result_tasks_created = 9
-result_message = "Onboarding initiated for " + employee_name
```
-## 4. Daily Business Intelligence Report
+---
-Automated daily report with AI-generated insights.
+## 3. Daily Business Intelligence Report
-```basic
+Automated daily report job with AI-generated insights.
+
+```botbook/src/chapter-06-gbdialog/examples-consolidated.bas#L152-230
' daily-report.bas
' Automated daily business intelligence report
@@ -341,198 +189,51 @@ avg_resolution_time = AGGREGATE "AVG", tickets_resolved, "resolution_time_hours"
low_stock = FIND "products", "stock < 10"
out_of_stock = FIND "products", "stock = 0"
-' Gather website analytics
-SET HEADER "Authorization", "Bearer " + GET BOT MEMORY "analytics_api_key"
-analytics = GET "https://api.analytics.com/v1/summary?date=" + today
-
' Compile data for AI analysis
-report_date = today
-sales_revenue = total_revenue_today
-sales_orders = order_count_today
-sales_change = revenue_change
-tickets_opened = UBOUND(tickets_today)
-tickets_resolved_count = UBOUND(tickets_resolved)
-avg_resolution = avg_resolution_time
-low_stock_count = UBOUND(low_stock)
-out_of_stock_count = UBOUND(out_of_stock)
-visitors = analytics.visitors
-page_views = analytics.page_views
-bounce_rate = analytics.bounce_rate
-
-report_data = "Date: " + report_date + ", Revenue: $" + sales_revenue + ", Orders: " + sales_orders + ", Change: " + sales_change + "%, Tickets: " + tickets_opened + " opened, " + tickets_resolved_count + " resolved, Low stock: " + low_stock_count
+report_data = "Date: " + today + ", Revenue: $" + total_revenue_today + ", Orders: " + order_count_today + ", Change: " + revenue_change + "%, Tickets: " + UBOUND(tickets_today) + " opened, " + UBOUND(tickets_resolved) + " resolved, Low stock: " + UBOUND(low_stock)
' Generate AI insights
SET CONTEXT "You are a business analyst. Analyze this data and provide actionable insights. Be concise and focus on key trends and recommendations."
+ai_insights = LLM "Analyze this business data and provide 3-5 key insights:\n\n" + report_data
-analysis_prompt = "Analyze this business data and provide 3-5 key insights:\n\n" + report_data
-ai_insights = LLM analysis_prompt
-
-' Build HTML report
-report_title = "Daily Business Report - " + today
-generated_at = NOW()
-
-report_pdf = GENERATE PDF "templates/daily-report.html", report_title, report_data, ai_insights, generated_at, "reports/daily-" + today + ".pdf"
+' Build report PDF
+report_pdf = GENERATE PDF "templates/daily-report.html", "Daily Business Report - " + today, report_data, ai_insights, NOW(), "reports/daily-" + today + ".pdf"
' Send to executives
executives = ["ceo@company.com", "cfo@company.com", "coo@company.com"]
-
FOR EACH exec IN executives
SEND MAIL exec, "Daily Business Report - " + today, "Please find attached today's business intelligence report.\n\n" + ai_insights, report_pdf.url
NEXT exec
' Post summary to Slack
-slack_channel = "#executive-updates"
-slack_text = "📊 *Daily Report - " + today + "*\n\n"
-slack_text = slack_text + "💰 Revenue: $" + FORMAT(total_revenue_today, "#,##0.00") + " (" + FORMAT(revenue_change, "+0.0") + "%)\n"
-slack_text = slack_text + "📦 Orders: " + order_count_today + "\n"
-slack_text = slack_text + "🎫 Support Tickets: " + UBOUND(tickets_today) + " opened, " + UBOUND(tickets_resolved) + " resolved\n"
-slack_text = slack_text + "⚠️ Low Stock Items: " + UBOUND(low_stock) + "\n\n"
-slack_text = slack_text + "*AI Insights:*\n" + ai_insights
-POST "https://hooks.slack.com/services/xxx", slack_channel, slack_text
+slack_summary = "📊 *Daily Report - " + today + "*\n\n💰 Revenue: $" + FORMAT(total_revenue_today, "#,##0.00") + " (" + FORMAT(revenue_change, "+0.0") + "%)\n📦 Orders: " + order_count_today + "\n🎫 Support Tickets: " + UBOUND(tickets_today) + " opened, " + UBOUND(tickets_resolved) + " resolved\n⚠️ Low Stock Items: " + UBOUND(low_stock)
+POST "https://hooks.slack.com/services/xxx", "#executive-updates", slack_summary
' Store report in database
-report_date = today
-pdf_url = report_pdf.url
-SAVE "daily_reports", report_date, report_data, ai_insights, pdf_url
+SAVE "daily_reports", today, report_data, ai_insights, report_pdf.url
PRINT "Daily report generated and distributed for " + today
```
-## 5. Multi-Language Customer Survey Tool
+---
-Interactive survey with real-time translation and sentiment analysis.
+## 4. Document Processing Pipeline
-```basic
-' survey-tool.bas
-' Multi-language customer survey with AI analysis
+Automated document intake, processing, and classification via webhook.
-TALK "Welcome! What language would you prefer? / ¡Bienvenido! ¿Qué idioma prefiere? / Bienvenue! Quelle langue préférez-vous?"
-
-HEAR language_choice
-
-' Detect language
-SET CONTEXT "Identify the language of this text. Respond with only the language code: en, es, fr, de, pt, or other."
-detected_lang = LLM language_choice
-detected_lang = TRIM(LCASE(detected_lang))
-
-' Set translations
-IF detected_lang = "es" THEN
- q1 = "¿Cómo calificaría su experiencia general? (1-10)"
- q2 = "¿Qué es lo que más le gustó de nuestro servicio?"
- q3 = "¿Qué podríamos mejorar?"
- q4 = "¿Nos recomendaría a un amigo? (sí/no)"
- thank_you = "¡Gracias por sus comentarios!"
-ELSE IF detected_lang = "fr" THEN
- q1 = "Comment évalueriez-vous votre expérience globale ? (1-10)"
- q2 = "Qu'avez-vous le plus apprécié dans notre service ?"
- q3 = "Que pourrions-nous améliorer ?"
- q4 = "Nous recommanderiez-vous à un ami ? (oui/non)"
- thank_you = "Merci pour vos commentaires !"
-ELSE
- q1 = "How would you rate your overall experience? (1-10)"
- q2 = "What did you like most about our service?"
- q3 = "What could we improve?"
- q4 = "Would you recommend us to a friend? (yes/no)"
- thank_you = "Thank you for your feedback!"
- detected_lang = "en"
-END IF
-
-' Collect responses
-TALK q1
-HEAR rating
-IF NOT IS NUMERIC(rating) THEN
- rating = 5
-END IF
-
-TALK q2
-HEAR liked_most
-
-TALK q3
-HEAR improvements
-
-TALK q4
-HEAR recommend
-
-' Translate responses to English for analysis if needed
-IF detected_lang <> "en" THEN
- SET CONTEXT "Translate the following text to English. Only provide the translation, nothing else."
- liked_most_en = LLM liked_most
- improvements_en = LLM improvements
-ELSE
- liked_most_en = liked_most
- improvements_en = improvements
-END IF
-
-' Sentiment analysis
-SET CONTEXT "Analyze the sentiment of this feedback. Respond with: positive, neutral, or negative."
-sentiment = LLM "Liked: " + liked_most_en + ". Improvements: " + improvements_en
-sentiment = TRIM(LCASE(sentiment))
-
-' NPS calculation
-IF INSTR(LCASE(recommend), "yes") > 0 OR INSTR(LCASE(recommend), "sí") > 0 OR INSTR(LCASE(recommend), "oui") > 0 THEN
- would_recommend = TRUE
- nps_category = "promoter"
-ELSE
- would_recommend = FALSE
- nps_category = "detractor"
-END IF
-
-IF rating >= 9 THEN
- nps_category = "promoter"
-ELSE IF rating >= 7 THEN
- nps_category = "passive"
-ELSE
- nps_category = "detractor"
-END IF
-
-' Save survey response
-survey_language = detected_lang
-survey_rating = rating
-submitted_at = NOW()
-
-SAVE "survey_responses", survey_language, survey_rating, liked_most, liked_most_en, improvements, improvements_en, would_recommend, sentiment, nps_category, submitted_at
-
-' Generate AI summary for low scores
-IF rating < 6 THEN
- SET CONTEXT "You are a customer experience manager. Summarize this negative feedback and suggest immediate actions."
-
- alert_summary = LLM "Customer rated us " + rating + "/10. They liked: " + liked_most_en + ". They want us to improve: " + improvements_en
-
- SEND MAIL "cx-team@company.com", "⚠️ Low Survey Score Alert", "Rating: " + rating + "/10\n\nSummary: " + alert_summary + "\n\nOriginal feedback:\n- Liked: " + liked_most + "\n- Improve: " + improvements
-END IF
-
-TALK thank_you
-
-' Show aggregated stats
-total_responses = AGGREGATE "COUNT", "survey_responses", "id"
-avg_rating = AGGREGATE "AVG", "survey_responses", "rating"
-promoters = FILTER "survey_responses", "nps_category=promoter"
-detractors = FILTER "survey_responses", "nps_category=detractor"
-nps_score = ((UBOUND(promoters) - UBOUND(detractors)) / total_responses) * 100
-
-PRINT "Survey completed. Total responses: " + total_responses + ", Avg rating: " + FORMAT(avg_rating, "0.0") + ", NPS: " + FORMAT(nps_score, "0")
-```
-
-## 6. Document Processing Pipeline
-
-Automated document intake, processing, and classification.
-
-```basic
+```botbook/src/chapter-06-gbdialog/examples-consolidated.bas#L232-330
' document-pipeline.bas
' Automated document processing and classification
WEBHOOK "document-upload"
-' Get uploaded document
document_url = body.document_url
document_name = body.filename
uploader_email = body.uploader_email
IF document_url = "" THEN
- WITH result = NEW OBJECT
- .status = 400
- .error = "No document URL provided"
- END WITH
+ result_status = 400
+ result_error = "No document URL provided"
EXIT
END IF
@@ -541,111 +242,62 @@ local_path = DOWNLOAD document_url, "incoming/" + document_name
' Extract text based on file type
file_extension = LCASE(RIGHT(document_name, 4))
-
-IF file_extension = ".pdf" THEN
- content = GET local_path
-ELSE IF file_extension = "docx" OR file_extension = ".doc" THEN
- content = GET local_path
-ELSE IF file_extension = ".txt" THEN
- content = READ local_path
-ELSE
- ' Try OCR for images
- content = GET local_path
-END IF
+content = GET local_path
' Classify document using AI
-SET CONTEXT "You are a document classifier. Classify this document into one of these categories: invoice, contract, report, correspondence, legal, hr, other. Also extract key metadata. Respond in JSON format with fields: category, confidence, key_dates, key_parties, summary."
-
+SET CONTEXT "You are a document classifier. Classify this document into one of these categories: invoice, contract, report, correspondence, legal, hr, other. Respond with just the category name."
classification_prompt = "Classify this document:\n\n" + LEFT(content, 5000)
-classification_result = LLM classification_prompt
-
-' Parse AI response (simplified - in production use proper JSON parsing)
-category = "other"
-IF INSTR(classification_result, "invoice") > 0 THEN
- category = "invoice"
-ELSE IF INSTR(classification_result, "contract") > 0 THEN
- category = "contract"
-ELSE IF INSTR(classification_result, "report") > 0 THEN
- category = "report"
-ELSE IF INSTR(classification_result, "legal") > 0 THEN
- category = "legal"
-ELSE IF INSTR(classification_result, "hr") > 0 THEN
- category = "hr"
-END IF
+category = TRIM(LCASE(LLM classification_prompt))
' Move to appropriate folder
destination = category + "/" + document_name
MOVE local_path, destination
' Create searchable index entry
-filename = document_name
-original_url = document_url
-stored_path = destination
-content_preview = LEFT(content, 1000)
-full_text = content
-classification_details = classification_result
-uploaded_by = uploader_email
-processed_at = NOW()
-
-doc_id = INSERT "documents", filename, original_url, stored_path, category, content_preview, full_text, classification_details, uploaded_by, processed_at
+doc_id = INSERT "documents", document_name, document_url, destination, category, LEFT(content, 1000), content, uploader_email, NOW()
' Add to knowledge base for future queries
USE KB category + "-docs"
' Category-specific processing
-SELECT CASE category
- CASE "invoice"
- ' Extract invoice details
- SET CONTEXT "Extract from this invoice: vendor name, invoice number, date, due date, total amount, line items. Respond in JSON."
- invoice_data = LLM content
-
- ' Create payable record
- payable_doc_id = doc_id
- extracted_data = invoice_data
- payable_status = "pending_review"
- payable_created_at = NOW()
- INSERT "accounts_payable", payable_doc_id, extracted_data, payable_status, payable_created_at
-
- SEND MAIL "accounting@company.com", "New Invoice for Review", "A new invoice has been uploaded and classified.\n\nDocument: " + document_name + "\nCategory: Invoice\n\nPlease review in the accounting portal."
-
- CASE "contract"
- ' Extract contract details
- SET CONTEXT "Extract from this contract: parties involved, effective date, expiration date, key terms, renewal clauses. Respond in JSON."
- contract_data = LLM content
-
- contract_doc_id = doc_id
- contract_extracted = contract_data
- contract_status = "active"
- contract_created_at = NOW()
- INSERT "contracts", contract_doc_id, contract_extracted, contract_status, contract_created_at
-
- SEND MAIL "legal@company.com", "New Contract Uploaded", "A new contract has been processed.\n\nDocument: " + document_name + "\n\nDetails: " + contract_data
-
- CASE "hr"
- SEND MAIL "hr@company.com", "New HR Document", "A new HR document has been uploaded: " + document_name
-END SELECT
+IF category = "invoice" THEN
+ SET CONTEXT "Extract from this invoice: vendor name, invoice number, date, due date, total amount. Respond in JSON."
+ invoice_data = LLM content
+ INSERT "accounts_payable", doc_id, invoice_data, "pending_review", NOW()
+ SEND MAIL "accounting@company.com", "New Invoice for Review", "A new invoice has been uploaded.\n\nDocument: " + document_name
+END IF
+
+IF category = "contract" THEN
+ SET CONTEXT "Extract from this contract: parties involved, effective date, expiration date, key terms. Respond in JSON."
+ contract_data = LLM content
+ INSERT "contracts", doc_id, contract_data, "active", NOW()
+ SEND MAIL "legal@company.com", "New Contract Uploaded", "A new contract has been processed.\n\nDocument: " + document_name
+END IF
+
+IF category = "hr" THEN
+ SEND MAIL "hr@company.com", "New HR Document", "A new HR document has been uploaded: " + document_name
+END IF
' Notify uploader
-SEND MAIL uploader_email, "Document Processed: " + document_name, "Your document has been successfully processed.\n\nCategory: " + category + "\nDocument ID: " + doc_id + "\n\nYou can now search for this document in the document portal."
+SEND MAIL uploader_email, "Document Processed: " + document_name, "Your document has been successfully processed.\n\nCategory: " + category + "\nDocument ID: " + doc_id
-' Return result
result_status = "processed"
result_doc_id = doc_id
result_category = category
-result_path = destination
```
-## 7. Real-time Data Sync Tool
+---
-Bidirectional sync between systems.
+## 5. Real-time Data Sync (CRM to ERP)
-```basic
+Bidirectional sync between systems via webhook.
+
+```botbook/src/chapter-06-gbdialog/examples-consolidated.bas#L332-420
' data-sync.bas
' Real-time data synchronization between CRM and ERP
WEBHOOK "crm-update"
-' Handle CRM webhook
event_type = body.event
record_type = body.record_type
record_id = body.record_id
@@ -653,82 +305,42 @@ data = body.data
timestamp = body.timestamp
' Log sync event
-sync_source = "crm"
-sync_event = event_type
-sync_record_type = record_type
-sync_record_id = record_id
-sync_timestamp = source_timestamp
-received_at = NOW()
-INSERT "sync_logs", sync_source, sync_event, sync_record_type, sync_record_id, sync_timestamp, received_at
+INSERT "sync_logs", "crm", event_type, record_type, record_id, timestamp, NOW()
' Check for sync conflicts
last_erp_update = FIND "erp_sync_status", "record_id=" + record_id
IF last_erp_update.updated_at > timestamp THEN
- ' ERP has newer data - conflict
- WITH conflict = NEW OBJECT
- .record_id = record_id
- .crm_timestamp = timestamp
- .erp_timestamp = last_erp_update.updated_at
- .crm_data = data
- .erp_data = last_erp_update.data
- .status = "pending_resolution"
- END WITH
- INSERT "sync_conflicts", conflict
-
+ INSERT "sync_conflicts", record_id, timestamp, last_erp_update.updated_at, data, last_erp_update.data, "pending_resolution"
SEND MAIL "data-admin@company.com", "Sync Conflict Detected", "Record " + record_id + " has conflicting updates. Please resolve in the admin portal."
-
- WITH result = NEW OBJECT
- .status = "conflict"
- .message = "Newer data exists in ERP"
- END WITH
+ result_status = "conflict"
+ result_message = "Newer data exists in ERP"
EXIT
END IF
-' Transform data for ERP format
-SELECT CASE record_type
- CASE "customer"
- WITH erp_data = NEW OBJECT
- .customer_code = record_id
- .company_name = data.company
- .contact_name = data.contact_first_name + " " + data.contact_last_name
- .email = data.email
- .phone = data.phone
- .billing_address = data.address.street + ", " + data.address.city + ", " + data.address.state + " " + data.address.zip
- .credit_limit = data.credit_limit
- .payment_terms = data.payment_terms
- .updated_at = NOW()
- END WITH
-
- erp_endpoint = "/api/customers/" + record_id
-
- CASE "order"
- WITH erp_data = NEW OBJECT
- .order_number = record_id
- .customer_code = data.customer_id
- .order_date = data.created_at
- .ship_date = data.expected_ship_date
- .line_items = data.products
- .subtotal = data.subtotal
- .tax = data.tax
- .total = data.total
- .status = data.status
- END WITH
-
- erp_endpoint = "/api/orders/" + record_id
-
- CASE "product"
- WITH erp_data = NEW OBJECT
- .sku = record_id
- .description = data.name
- .category = data.category
- .unit_price = data.price
- .cost = data.cost
- .weight = data.weight
- .dimensions = data.dimensions
- END WITH
-
- erp_endpoint = "/api/products/" + record_id
-END SELECT
+' Transform data for ERP format based on record type
+IF record_type = "customer" THEN
+ erp_endpoint = "/api/customers/" + record_id
+ erp_customer_code = record_id
+ erp_company_name = data.company
+ erp_contact_name = data.contact_first_name + " " + data.contact_last_name
+ erp_email = data.email
+ erp_phone = data.phone
+END IF
+
+IF record_type = "order" THEN
+ erp_endpoint = "/api/orders/" + record_id
+ erp_order_number = record_id
+ erp_customer_code = data.customer_id
+ erp_order_date = data.created_at
+ erp_total = data.total
+END IF
+
+IF record_type = "product" THEN
+ erp_endpoint = "/api/products/" + record_id
+ erp_sku = record_id
+ erp_description = data.name
+ erp_unit_price = data.price
+END IF
' Send to ERP
erp_api_key = GET BOT MEMORY "erp_api_key"
@@ -736,42 +348,206 @@ SET HEADER "Authorization", "Bearer " + erp_api_key
SET HEADER "Content-Type", "application/json"
IF event_type = "create" THEN
- erp_result = POST "https://erp.company.com" + erp_endpoint, erp_data
+ erp_result = POST "https://erp.company.com" + erp_endpoint, data
ELSE IF event_type = "update" THEN
- erp_result = PUT "https://erp.company.com" + erp_endpoint, erp_data
+ erp_result = PUT "https://erp.company.com" + erp_endpoint, data
ELSE IF event_type = "delete" THEN
erp_result = DELETE "https://erp.company.com" + erp_endpoint
END IF
' Update sync status
-WITH sync_status = NEW OBJECT
- .record_id = record_id
- .record_type = record_type
- .last_crm_update = timestamp
- .last_erp_sync = NOW()
- .sync_result = erp_result.status
- .data = erp_data
-END WITH
-SAVE "erp_sync_status", record_id, sync_status
+SAVE "erp_sync_status", record_id, record_type, timestamp, NOW(), erp_result.status, data
-' Update sync log with result
-WITH log_update = NEW OBJECT
- .sync_completed_at = NOW()
- .erp_response = erp_result.status
-END WITH
-UPDATE "sync_logs", "record_id=" + record_id + " AND source='crm'", log_update
-
-WITH result = NEW OBJECT
- .status = "synced"
- .record_id = record_id
- .erp_status = erp_result.status
-END WITH
+result_status = "synced"
+result_record_id = record_id
+result_erp_status = erp_result.status
```
+---
+
+## 6. Scheduled Lead Nurturing Job
+
+Automated lead follow-up and nurturing campaign.
+
+```botbook/src/chapter-06-gbdialog/examples-consolidated.bas#L422-490
+' lead-nurturing.bas
+' Scheduled lead nurturing campaign
+
+SET SCHEDULE "lead-nurture", "0 9 * * *"
+
+' Find leads needing follow-up
+cold_leads_3_days = FIND "leads", "status='cold' AND DATEDIFF(NOW(), last_contact) >= 3"
+cold_leads_7_days = FIND "leads", "status='cold' AND DATEDIFF(NOW(), last_contact) >= 7"
+cold_leads_14_days = FIND "leads", "status='cold' AND DATEDIFF(NOW(), last_contact) >= 14"
+cold_leads_30_days = FIND "leads", "status='cold' AND DATEDIFF(NOW(), last_contact) >= 30"
+
+' 3-day follow-up: Tips email
+FOR EACH lead IN cold_leads_3_days
+ IF lead.nurture_stage = 0 THEN
+ SEND MAIL lead.email, "5 Tips to Improve Your Business", "templates/nurture-tips.html"
+ UPDATE "leads", "id=" + lead.id, 1, NOW()
+ END IF
+NEXT lead
+
+' 7-day follow-up: Case study
+FOR EACH lead IN cold_leads_7_days
+ IF lead.nurture_stage = 1 THEN
+ SEND MAIL lead.email, "Case Study: How We Helped Similar Companies", "templates/nurture-case-study.html"
+ UPDATE "leads", "id=" + lead.id, 2, NOW()
+ END IF
+NEXT lead
+
+' 14-day follow-up: Free consultation
+FOR EACH lead IN cold_leads_14_days
+ IF lead.nurture_stage = 2 THEN
+ SEND MAIL lead.email, "Free Consultation Offer", "templates/nurture-consultation.html"
+ UPDATE "leads", "id=" + lead.id, 3, NOW()
+ END IF
+NEXT lead
+
+' 30-day follow-up: Special offer
+FOR EACH lead IN cold_leads_30_days
+ IF lead.nurture_stage = 3 THEN
+ SEND MAIL lead.email, "Special Limited Time Offer", "templates/nurture-special-offer.html"
+ UPDATE "leads", "id=" + lead.id, 4, NOW()
+ END IF
+NEXT lead
+
+' Log nurturing stats
+PRINT "Lead nurturing completed: " + UBOUND(cold_leads_3_days) + " at stage 1, " + UBOUND(cold_leads_7_days) + " at stage 2"
+```
+
+---
+
+## 7. Payment Collection Reminder Job
+
+Automated payment reminders and collection workflow.
+
+```botbook/src/chapter-06-gbdialog/examples-consolidated.bas#L492-560
+' payment-collection.bas
+' Scheduled payment collection reminders
+
+SET SCHEDULE "payment-reminders", "0 8 * * 1-5"
+
+' Find overdue invoices
+due_today = FIND "invoices", "status='pending' AND due_date = CURDATE()"
+overdue_3_days = FIND "invoices", "status='pending' AND DATEDIFF(NOW(), due_date) = 3"
+overdue_7_days = FIND "invoices", "status='pending' AND DATEDIFF(NOW(), due_date) = 7"
+overdue_14_days = FIND "invoices", "status='pending' AND DATEDIFF(NOW(), due_date) = 14"
+overdue_30_days = FIND "invoices", "status='pending' AND DATEDIFF(NOW(), due_date) >= 30"
+
+' Due today reminder
+FOR EACH invoice IN due_today
+ customer = FIND "customers", "id=" + invoice.customer_id
+ SEND MAIL customer.email, "Payment Due Today - Invoice #" + invoice.id, "Your invoice #" + invoice.id + " for $" + invoice.amount + " is due today. Please make payment to avoid late fees."
+NEXT invoice
+
+' 3-day overdue: First reminder
+FOR EACH invoice IN overdue_3_days
+ customer = FIND "customers", "id=" + invoice.customer_id
+ SEND MAIL customer.email, "Payment Overdue - Invoice #" + invoice.id, "Your invoice #" + invoice.id + " for $" + invoice.amount + " is now 3 days overdue. Please remit payment as soon as possible."
+ UPDATE "invoices", "id=" + invoice.id, "first_reminder_sent", NOW()
+NEXT invoice
+
+' 7-day overdue: Second reminder with late fee warning
+FOR EACH invoice IN overdue_7_days
+ customer = FIND "customers", "id=" + invoice.customer_id
+ SEND MAIL customer.email, "URGENT: Payment Overdue - Invoice #" + invoice.id, "Your invoice #" + invoice.id + " is now 7 days overdue. A late fee may be applied if not paid within 7 days."
+ UPDATE "invoices", "id=" + invoice.id, "second_reminder_sent", NOW()
+NEXT invoice
+
+' 14-day overdue: Final notice
+FOR EACH invoice IN overdue_14_days
+ customer = FIND "customers", "id=" + invoice.customer_id
+ late_fee = invoice.amount * 0.05
+ new_total = invoice.amount + late_fee
+ SEND MAIL customer.email, "FINAL NOTICE: Invoice #" + invoice.id, "Your invoice is now 14 days overdue. A 5% late fee ($" + late_fee + ") has been applied. New total: $" + new_total
+ UPDATE "invoices", "id=" + invoice.id, late_fee, new_total, "final_notice_sent", NOW()
+
+ ' Notify accounts receivable
+ SEND MAIL "ar@company.com", "Invoice Escalation: #" + invoice.id, "Invoice #" + invoice.id + " for " + customer.name + " is 14 days overdue. Amount: $" + new_total
+NEXT invoice
+
+' 30+ day overdue: Send to collections
+FOR EACH invoice IN overdue_30_days
+ IF invoice.status <> "collections" THEN
+ customer = FIND "customers", "id=" + invoice.customer_id
+ UPDATE "invoices", "id=" + invoice.id, "collections", NOW()
+
+ ' Notify collections team
+ SEND MAIL "collections@company.com", "New Collections Account: " + customer.name, "Invoice #" + invoice.id + " - $" + invoice.total_with_fees + "\nCustomer: " + customer.name + "\nDays overdue: " + DATEDIFF(NOW(), invoice.due_date)
+ END IF
+NEXT invoice
+
+PRINT "Payment reminders sent: " + UBOUND(due_today) + " due today, " + UBOUND(overdue_3_days) + " 3-day, " + UBOUND(overdue_7_days) + " 7-day"
+```
+
+---
+
+## 8. Appointment Scheduling Webhook
+
+Handle appointment bookings from external calendar systems.
+
+```botbook/src/chapter-06-gbdialog/examples-consolidated.bas#L562-620
+' appointment-webhook.bas
+' Handle appointment scheduling from external systems
+
+WEBHOOK "appointment-booked"
+
+appointment_id = body.appointment_id
+customer_email = body.customer.email
+customer_name = body.customer.name
+customer_phone = body.customer.phone
+service_type = body.service
+appointment_date = body.date
+appointment_time = body.time
+staff_id = body.staff_id
+
+' Validate
+IF appointment_id = "" OR customer_email = "" THEN
+ result_status = 400
+ result_error = "Missing required fields"
+ EXIT
+END IF
+
+' Check staff availability
+existing = FIND "appointments", "staff_id='" + staff_id + "' AND date='" + appointment_date + "' AND time='" + appointment_time + "'"
+IF UBOUND(existing) > 0 THEN
+ result_status = 409
+ result_error = "Time slot not available"
+ EXIT
+END IF
+
+' Save appointment
+SAVE "appointments", appointment_id, customer_email, customer_name, customer_phone, service_type, appointment_date, appointment_time, staff_id, "confirmed", NOW()
+
+' Get staff info
+staff = FIND "staff", "id=" + staff_id
+
+' Send confirmation to customer
+confirmation_msg = "Your appointment has been confirmed!\n\n📅 " + appointment_date + " at " + appointment_time + "\n🏢 Service: " + service_type + "\n👤 With: " + staff.name + "\n\nPlease arrive 10 minutes early."
+SEND MAIL customer_email, "Appointment Confirmed - " + service_type, confirmation_msg
+
+' Send SMS reminder setup
+SET SCHEDULE "reminder-" + appointment_id, DATEADD(appointment_date + " " + appointment_time, -24, "hour")
+
+' Notify staff
+SEND MAIL staff.email, "New Appointment: " + customer_name, "You have a new appointment:\n\n📅 " + appointment_date + " at " + appointment_time + "\n👤 Customer: " + customer_name + "\n📞 Phone: " + customer_phone + "\n🏢 Service: " + service_type
+
+' Add to calendar
+BOOK staff.email, "Appointment: " + customer_name + " - " + service_type, appointment_date, appointment_time, 60
+
+result_status = "confirmed"
+result_appointment_id = appointment_id
+```
+
+---
+
## See Also
-- [Keywords Reference](./keywords.md) - Complete keyword documentation
-- [WEBHOOK](./keyword-webhook.md) - Creating API endpoints
-- [SET SCHEDULE](./keyword-set-schedule.md) - Scheduled automation
-- [Data Operations](./keywords.md#database--data-operations) - Database keywords
-- [File Operations](./keywords.md#file--document-operations) - File handling
\ No newline at end of file
+- [Keywords Reference](./keywords.md) — Complete keyword documentation
+- [WEBHOOK](./keyword-webhook.md) — Creating API endpoints
+- [SET SCHEDULE](./keyword-set-schedule.md) — Scheduled automation
+- [Data Operations](./keywords-data.md) — Database keywords
+- [File Operations](./keywords-file.md) — File handling
+- [HTTP Operations](./keywords-http.md) — REST API calls
\ No newline at end of file
diff --git a/src/executive-vision.md b/src/executive-vision.md
index 84ba6e46..12a9b252 100644
--- a/src/executive-vision.md
+++ b/src/executive-vision.md
@@ -189,8 +189,40 @@ Pragmatismo develops General Bots as an open-source platform for enterprise AI a
---
+## QUICK START
+
+Ready to see it in action? Skip to the hands-on guide:
+
+**[⚡ Quick Start: Run Your First Bot in 5 Minutes →](./chapter-01/quick-start.md)**
+
+Or continue reading for the full journey:
+
+| Path | Time | Best For |
+|------|------|----------|
+| [Quick Start](./chapter-01/quick-start.md) | 5 min | Developers who want to dive in immediately |
+| [Introduction](./introduction.md) | 10 min | Understanding the "No Forms" philosophy |
+| [Chapter 01](./chapter-01/README.md) | 15 min | Complete installation and first conversation |
+
+---
+
## NEXT STEPS
-[Chapter 01: Run and Talk →](./chapter-01/README.md)
+
@@ -47,17 +56,57 @@ General Bots was born from this vision: **replace forms with conversations**.
### After: The Conversation Experience
-```
-User: I need help with my order
-Bot: I'd be happy to help! What's your order number?
-User: It's 12345
-Bot: Found it - your laptop order from last week. What's the issue?
-User: It arrived damaged
-Bot: I'm sorry to hear that. I'll create a return label for you.
- Should I send it to your email on file?
-User: Yes please
-Bot: Done! Check your inbox. Is there anything else?
-```
+