botserver/templates/TEMPLATE_PLAN.md
Rodrigo Rodriguez (Pragmatismo) 50eae38d36 Looking at this diff, I can see it's a comprehensive documentation
update and code refactoring focused on:

1. Adding new documentation pages to the table of contents
2. Restructuring the bot templates documentation
3. Changing keyword syntax from underscore format to space format (e.g.,
   `SET_BOT_MEMORY` → `SET BOT MEMORY`)
4. Updating compiler and keyword registration to support the new
   space-based syntax
5. Adding new keyword modules (social media, lead scoring, templates,
   etc.)

Refactor BASIC keywords to use spaces instead of underscores

Change keyword syntax from underscore format (SET_BOT_MEMORY) to more
natural space-separated format (SET BOT MEMORY) throughout the codebase.

Key changes:
- Update Rhai custom syntax registration to use space tokens
- Simplify compiler preprocessing (fewer replacements needed)
- Update all template .bas files to use new syntax
- Expand documentation with consolidated examples and new sections
- Add new keyword modules: social_media, lead_scoring, send_template,
  core_functions, qrcode, sms, procedures, import_export, llm_macros,
  on_form_submit
2025-11-30 10:53:59 -03:00

353 lines
No EOL
12 KiB
Markdown

# General Bots Template Plan
## 📋 50 Categorized Templates
### ✅ Completed Templates (4)
| # | Template | Category | Folder | Status |
|---|----------|----------|--------|--------|
| 1 | Employee Management | HR | `hr/employees.gbai` | ✅ Done |
| 2 | IT Helpdesk | IT | `it/helpdesk.gbai` | ✅ Done |
| 3 | Sales Pipeline | CRM | `crm/sales-pipeline.gbai` | ✅ Done |
| 4 | Contact Directory | CRM | `crm/contacts.gbai` | ✅ Done |
---
## 📁 Templates To Create (48)
### 💼 CRM & Sales (6 templates)
| # | Template | Folder | Key Files | Status |
|---|----------|--------|-----------|--------|
| 3 | Sales Pipeline | `crm/sales-pipeline.gbai` | `start.bas`, `create-deal.bas`, `update-stage.bas`, `pipeline-jobs.bas` | ✅ Done |
| 4 | Contact Directory | `crm/contacts.gbai` | `start.bas`, `add-contact.bas`, `search-contact.bas` | ✅ Done |
| 5 | Quote Generator | `crm/quotes.gbai` | `start.bas`, `create-quote.bas`, `send-quote.bas` |
| 6 | Customer Portal | `crm/customer-portal.gbai` | `start.bas`, `order-status.bas`, `support-request.bas` |
| 7 | Referral Tracking | `crm/referrals.gbai` | `start.bas`, `add-referral.bas`, `referral-jobs.bas` |
| 8 | Sales Reports | `crm/sales-reports.gbai` | `start.bas`, `generate-report.bas`, `report-jobs.bas` |
### 🏭 Operations & ERP (5 templates)
| # | Template | Folder | Key Files |
|---|----------|--------|-----------|
| 9 | Warehouse Management | `operations/warehouse.gbai` | `start.bas`, `receive-stock.bas`, `ship-order.bas` |
| 10 | Production Tracking | `operations/production.gbai` | `start.bas`, `work-order.bas`, `quality-check.bas` |
| 11 | Vendor Management | `operations/vendors.gbai` | `start.bas`, `add-vendor.bas`, `vendor-rating.bas` |
| 12 | Shipping & Logistics | `operations/logistics.gbai` | `start.bas`, `create-shipment.bas`, `track-shipment.bas` |
| 13 | Quality Control | `operations/quality.gbai` | `start.bas`, `inspection.bas`, `defect-report.bas` |
### 👥 Human Resources (5 templates)
| # | Template | Folder | Key Files |
|---|----------|--------|-----------|
| 14 | Leave Management | `hr/leave.gbai` | `start.bas`, `request-leave.bas`, `approve-leave.bas`, `leave-jobs.bas` |
| 15 | Time & Attendance | `hr/attendance.gbai` | `start.bas`, `clock-in.bas`, `timesheet.bas` |
| 16 | Recruitment | `hr/recruitment.gbai` | `start.bas`, `post-job.bas`, `add-applicant.bas`, `schedule-interview.bas` |
| 17 | Performance Reviews | `hr/reviews.gbai` | `start.bas`, `create-review.bas`, `submit-feedback.bas` |
| 18 | Training & LMS | `hr/training.gbai` | `start.bas`, `enroll-course.bas`, `complete-module.bas` |
### 💰 Finance & Accounting (6 templates)
| # | Template | Folder | Key Files |
|---|----------|--------|-----------|
| 19 | Invoice Management | `finance/invoicing.gbai` | `start.bas`, `create-invoice.bas`, `send-reminder.bas`, `invoice-jobs.bas` |
| 20 | Expense Tracker | `finance/expenses.gbai` | `start.bas`, `submit-expense.bas`, `approve-expense.bas` |
| 21 | Budget Planning | `finance/budgets.gbai` | `start.bas`, `create-budget.bas`, `budget-report.bas` |
| 22 | Time & Billing | `finance/billing.gbai` | `start.bas`, `log-time.bas`, `generate-invoice.bas` |
| 23 | Accounts Receivable | `finance/receivables.gbai` | `start.bas`, `record-payment.bas`, `aging-report.bas` |
| 24 | Payroll | `finance/payroll.gbai` | `start.bas`, `run-payroll.bas`, `payroll-jobs.bas` |
### 🏥 Healthcare & Medical (5 templates)
| # | Template | Folder | Key Files |
|---|----------|--------|-----------|
| 25 | Patient Records | `healthcare/patients.gbai` | `start.bas`, `register-patient.bas`, `medical-history.bas` |
| 26 | Appointment Scheduling | `healthcare/appointments.gbai` | `start.bas`, `book-appointment.bas`, `appointment-jobs.bas` |
| 27 | Pharmacy Inventory | `healthcare/pharmacy.gbai` | `start.bas`, `dispense-medication.bas`, `stock-alert.bas` |
| 28 | Medical Billing | `healthcare/medical-billing.gbai` | `start.bas`, `create-claim.bas`, `insurance-verify.bas` |
| 29 | Lab Results | `healthcare/lab.gbai` | `start.bas`, `enter-results.bas`, `notify-patient.bas` |
### 🎓 Education & Training (4 templates)
| # | Template | Folder | Key Files |
|---|----------|--------|-----------|
| 30 | Course Management | `education/courses.gbai` | `start.bas`, `create-course.bas`, `enroll-student.bas` |
| 31 | Faculty Management | `education/faculty.gbai` | `start.bas`, `add-faculty.bas`, `assign-class.bas` |
| 32 | Grade Book | `education/grades.gbai` | `start.bas`, `enter-grade.bas`, `grade-report.bas` |
| 33 | Student Portal | `education/student-portal.gbai` | `start.bas`, `view-schedule.bas`, `submit-assignment.bas` |
### 🏠 Real Estate & Property (4 templates)
| # | Template | Folder | Key Files |
|---|----------|--------|-----------|
| 34 | Property Listings | `realestate/properties.gbai` | `start.bas`, `add-property.bas`, `search-property.bas` |
| 35 | Lease Management | `realestate/leases.gbai` | `start.bas`, `create-lease.bas`, `rent-collection.bas`, `lease-jobs.bas` |
| 36 | Maintenance Requests | `realestate/maintenance.gbai` | `start.bas`, `submit-request.bas`, `assign-vendor.bas` |
| 37 | Tenant Portal | `realestate/tenant-portal.gbai` | `start.bas`, `pay-rent.bas`, `report-issue.bas` |
### 📅 Events & Scheduling (4 templates)
| # | Template | Folder | Key Files |
|---|----------|--------|-----------|
| 38 | Event Management | `events/events.gbai` | `start.bas`, `create-event.bas`, `register-attendee.bas`, `event-jobs.bas` |
| 39 | Room Booking | `events/room-booking.gbai` | `start.bas`, `check-availability.bas`, `book-room.bas` |
| 40 | Desk Booking | `events/desk-booking.gbai` | `start.bas`, `book-desk.bas`, `desk-map.bas` |
| 41 | Calendar Management | `events/calendar.gbai` | `start.bas`, `schedule-meeting.bas`, `send-invite.bas` |
### 🖥️ IT & Support (4 templates)
| # | Template | Folder | Key Files |
|---|----------|--------|-----------|
| 42 | Asset Tracking | `it/assets.gbai` | `start.bas`, `add-asset.bas`, `checkout-asset.bas`, `asset-jobs.bas` |
| 43 | Bug Tracking | `it/bugs.gbai` | `start.bas`, `report-bug.bas`, `update-bug.bas` |
| 44 | Change Management | `it/changes.gbai` | `start.bas`, `request-change.bas`, `approve-change.bas` |
| 45 | Knowledge Base | `it/knowledge.gbai` | `start.bas`, `add-article.bas`, `search-kb.bas` |
### 🤝 Nonprofit & Community (5 templates)
| # | Template | Folder | Key Files |
|---|----------|--------|-----------|
| 46 | Donor Management | `nonprofit/donors.gbai` | `start.bas`, `add-donor.bas`, `record-donation.bas`, `donor-jobs.bas` |
| 47 | Volunteer Management | `nonprofit/volunteers.gbai` | `start.bas`, `register-volunteer.bas`, `assign-shift.bas` |
| 48 | Membership | `nonprofit/membership.gbai` | `start.bas`, `register-member.bas`, `renew-membership.bas`, `member-jobs.bas` |
| 49 | Fundraising | `nonprofit/fundraising.gbai` | `start.bas`, `create-campaign.bas`, `track-pledges.bas` |
| 50 | Lending Library | `nonprofit/lending.gbai` | `start.bas`, `checkout-item.bas`, `return-item.bas`, `overdue-jobs.bas` |
---
## 📝 Template Structure Guide
### Required Files for Each Template
```
template-name.gbai/
├── template-name.gbdialog/
│ ├── start.bas # REQUIRED: Tools, KB, context, welcome
│ ├── <tool-name>.bas # Tool files (PARAM + DESCRIPTION)
│ └── <name>-jobs.bas # Scheduled jobs (SET SCHEDULE)
├── template-name.gbot/
│ └── config.csv # REQUIRED: Theme and settings
├── template-name.gbkb/
│ └── *.md # Knowledge base articles
└── template-name.gbdrive/
└── *.md # Document templates for FILL
```
### start.bas Template
```basic
' Template Name - Start Script
' Setup Tools
ADD TOOL "tool-name-1"
ADD TOOL "tool-name-2"
' Setup Knowledge Base
USE KB "template-name.gbkb"
' Set Context
SET CONTEXT "context name" AS "You are a [role]. You help with [tasks]."
' Setup Suggestions
CLEAR SUGGESTIONS
ADD SUGGESTION "action1" AS "Display text 1"
ADD SUGGESTION "action2" AS "Display text 2"
' Welcome Message
BEGIN TALK
**Template Title**
Welcome message here.
**What I can help with:**
Feature 1
Feature 2
END TALK
BEGIN SYSTEM PROMPT
Detailed instructions for the AI...
END SYSTEM PROMPT
```
### Tool File Template
```basic
PARAM paramname AS STRING LIKE "example" DESCRIPTION "What this parameter is"
PARAM optionalparam AS STRING LIKE "default" DESCRIPTION "Optional parameter"
DESCRIPTION "What this tool does. Called when user wants to [action]."
' Validate inputs
IF paramname = "" THEN
TALK "I need the parameter to continue."
paramname = HEAR
END IF
' Business logic
let result = "processed"
' Save data (field names = variable names)
SAVE "table.csv", paramname, optionalparam, result
' Store in memory
SET_BOT_MEMORY "last_item", result
' Notifications
SEND MAIL "recipient@example.com", "Subject", "Message body"
' Response
TALK "✅ Action completed successfully!"
TALK "Result: " + result
```
### Jobs File Template
```basic
PARAM jobname AS STRING DESCRIPTION "Name of the job to execute"
IF jobname = "daily task" THEN
SET SCHEDULE "0 8 * * *"
' Job logic here
let report = "Daily report content"
SEND MAIL "team@company.com", "Daily Report", report
TALK "Daily task completed"
END IF
IF jobname = "weekly task" THEN
SET SCHEDULE "0 9 * * 1"
' Job logic here
TALK "Weekly task completed"
END IF
IF jobname = "setup schedules" THEN
TALK "Configuring scheduled jobs..."
TALK "• Daily Task: 8:00 AM daily"
TALK "• Weekly Task: 9:00 AM Mondays"
TALK "✅ All schedules configured!"
END IF
```
### config.csv Template
```csv
name,value
prompt-history,2
prompt-compact,4
theme-color1,#1565C0
theme-color2,#E3F2FD
theme-logo,https://pragmatismo.com.br/icons/general-bots.svg
theme-title,Template Name - General Bots
```
### Knowledge Base (.gbkb) Template
Create `.md` files with relevant information:
- FAQs
- Policies and procedures
- How-to guides
- Reference information
---
## 🔑 Key Syntax Rules
### DO ✅
```basic
' Variable names (no spaces, no underscores in names)
let ticketnumber = "TKT001"
let useremail = "user@example.com"
' SAVE with field names = variable names
SAVE "table.csv", ticketnumber, useremail, status
' SET_BOT_MEMORY with underscores in key
SET_BOT_MEMORY "last_ticket", ticketnumber
' GET_BOT_MEMORY
let lastticket = GET_BOT_MEMORY("last_ticket")
' SET CONTEXT (with space)
SET CONTEXT "name" AS "description"
' ADD SUGGESTION (with space)
ADD SUGGESTION "key" AS "Display text"
' CLEAR SUGGESTIONS (with space)
CLEAR SUGGESTIONS
```
### DON'T ❌
```basic
' NO: Underscores in variable names
let ticket_number = "TKT001" ' WRONG
' NO: SET BOT MEMORY with spaces
SET BOT MEMORY "key", value ' WRONG
' NO: Complex object operations
SET object.field = value ' WRONG
SAVE "table", object.id, object ' WRONG
```
---
## 🚀 Instructions for Next Prompt
To continue creating templates, use this prompt:
```
Create template [NUMBER] from the TEMPLATE_PLAN.md:
Template: [Name]
Folder: [path]
Create these files:
1. start.bas - with tools, KB, context, suggestions, welcome
2. [tool-name].bas - main tool implementation
3. [name]-jobs.bas - scheduled jobs (if applicable)
4. config.csv - theme configuration
5. [topic].md in .gbkb folder - knowledge base content
Follow the syntax rules in TEMPLATE_PLAN.md exactly.
Use SAVE with variable names as field names.
Use SET_BOT_MEMORY (with underscores).
Create real .md content for the knowledge base.
```
---
## 📊 Progress Tracker
- [x] Template 1: Employee Management
- [x] Template 2: IT Helpdesk
- [x] Template 3: Sales Pipeline
- [x] Template 4: Contact Directory
- [ ] Templates 5-50: Pending
**Next template to create: #5 Quote Generator**
## 🔑 Syntax Updates (2025)
Keywords now use **spaces instead of underscores**:
| Old Syntax | New Syntax |
|------------|------------|
| `SET_BOT_MEMORY` | `SET BOT MEMORY` |
| `GET_BOT_MEMORY()` | `GET BOT MEMORY()` |
| `SET_CONTEXT` | `SET CONTEXT` |
| `ADD_SUGGESTION` | `ADD SUGGESTION` |
| `CLEAR_SUGGESTIONS` | `CLEAR SUGGESTIONS` |
| `USE_KB` | `USE KB` |
| `USE_TOOL` | `USE TOOL` |
| `CLEAR_KB` | `CLEAR KB` |
| `CLEAR_TOOLS` | `CLEAR TOOLS` |
| `SET_SCHEDULE` | `SET SCHEDULE` |
| `SET_HEADER` | `SET HEADER` |
| `CLEAR_HEADERS` | `CLEAR HEADERS` |
| `DELETE_HTTP` | `DELETE HTTP` |
| `DELETE_FILE` | `DELETE FILE` |