Skip to main content

AI System Configuration

This guide covers configuring the Gemini AI urgency analysis and the AI Knowledge Assistant from the admin panel.


Gemini AI Urgency Analysis

Enabling AI Processing

  1. Navigate to Admin → Settings → AI Assistant
  2. Set Enable AI Processing to Yes
  3. Configure the following settings:
SettingValueDescription
Gemini API KeyYour API keyShared key for all Gemini features (urgency + assistant + note optimization)
Generative Modelgemini-2.5-flashModel used for urgency analysis and chat
Enable AI ProcessingYes/NoMaster toggle for urgency analysis
Max Tickets Per Cron Run2 (default)Configurable throttle for queue processing
Direct Gemini Integration

The system calls the Google Gemini REST API directly (generativelanguage.googleapis.com). There is no proxy or intermediate service.

Model Fallback Chains

If the primary model fails (e.g. 503 overload), fallback models are tried automatically:

PrimaryFallback 1Fallback 2Fallback 3
gemini-2.5-flashgemini-2.5-flash-lite
gemini-2.5-progemini-2.5-flashgemini-3-flash-preview
gemini-3-pro-previewgemini-3-flash-previewgemini-2.5-progemini-2.5-flash

Response Cache

Gemini responses are cached in the database (ost_gemini_response_cache) with a configurable TTL. This avoids redundant API calls for identical ticket content.

  • Cache is bypassed during normal queue processing (bypass_cache=true)
  • Expired entries are cleaned up automatically during cron runs
  • Admin can configure TTL via Settings → AI Assistant

Urgency Criteria Editor

The urgency analysis prompt criteria can be customized:

  1. Navigate to Admin → Settings → AI Assistant
  2. Find the Urgency Criteria textarea
  3. Edit the criteria text to adjust how urgency is evaluated
  4. Click Reset to Default to restore the built-in criteria
  5. Save settings

How It Works

Once enabled:

  1. Every new thread entry (message, response, or note) triggers the motherload plugin
  2. The ticket is queued in ost_gemini_queue
  3. The cron-gemini.php cron job processes up to 2 tickets per run
  4. Results update the ticket's AI custom fields
  5. Critical urgency triggers email + SMS + browser notifications

Customer Type Classification

The AI uses "customer type" to calibrate urgency:

TypeDescriptionImpact
smallSmall client, lower hoursHigher urgency threshold
mediumMid-size clientStandard thresholds
largeEnterprise client, high hoursMore nuanced analysis

Customer type is determined automatically based on organization configuration.

Critical Alert Configuration

When AI sets urgency to CRITICAL:

  • Email sent to: assigned staff + PMs + department manager
  • SMS sent to: PMs (if phone configured and opted in)
  • Browser notification to: all subscribed staff
  • Alert is deduplicated (one per ticket, tracked in ost_ticket_ai_history)

AI Knowledge Assistant ("Burt")

Enabling the Assistant

  1. Navigate to Admin → Settings → AI Assistant
  2. Set Enable AI Assistant to Yes
  3. Configure Pinecone settings:
SettingValueDescription
Pinecone API KeyYour Pinecone keyVector database authentication
Pinecone HostIndex host URLPinecone serverless endpoint
Enabled SourcesJSON checkboxesWhich sources to include (tickets always active, plus sites/wiki/docs/GSM)
Max Context Results10Total results included as chat context
Max Conversation Messages20Conversation history depth
Chatbot NameBurtDisplay name used in chat UI and AI persona

Embedding Configuration

SettingValueDescription
Embedding Modelgemini-embedding-001768-dimension model for vector generation
Batch Size50Tickets processed per cron run
Embedding Cron IntervalEvery 10 minutesHow often new tickets are embedded
Conversation Retention30 daysAuto-delete old conversations

Verifying Embedding Status

Check how many tickets have been embedded:

-- Total embedded tickets
SELECT COUNT(*) FROM ost_ticket_embeddings;

-- Recently embedded
SELECT ticket_id, embedded_at
FROM ost_ticket_embeddings
ORDER BY embedded_at DESC
LIMIT 10;

-- Tickets without embeddings
SELECT t.ticket_id, t.number
FROM ost_ticket t
LEFT JOIN ost_ticket_embeddings e ON t.ticket_id = e.ticket_id
WHERE e.id IS NULL
ORDER BY t.created DESC
LIMIT 20;

AI Fields Management

Viewing AI Fields on Tickets

AI fields appear in the ticket detail view sidebar:

  • Urgency: Color-coded badge (green/yellow/orange/red)
  • Urgency %: Numeric score
  • Estimated Hours: AI effort estimate
  • Summary: Collapsible HTML summary
  • Timeline: Collapsible event timeline
  • Suggested Title: Click to apply as ticket subject

Custom Form Configuration

AI fields are attached via osTicket's custom form system:

  1. Navigate to Admin → Manage → Forms
  2. Find the ticket form with AI fields
  3. Fields should have these properties:
    • Visibility: Internal (not shown to clients)
    • Editable: Staff can override AI values
    • Required: No (filled by automation)

Cron Job Monitoring

Gemini Queue Status

-- Pending items in queue
SELECT COUNT(*) as pending FROM ost_gemini_queue WHERE processed = 0;

-- Recently processed
SELECT ticket_id, processed_at
FROM ost_gemini_queue
WHERE processed = 1
ORDER BY processed_at DESC
LIMIT 10;

-- Stuck items (queued more than 1 hour ago)
SELECT * FROM ost_gemini_queue
WHERE processed = 0 AND created < NOW() - INTERVAL 1 HOUR;

Embedding Queue Status

# Check cron is running
php cron-embeddings.php --status

API Logging

All AI API calls are logged for debugging:

Location: var/logs/api/gemini/ Format: gemini-YYYY-MM-DD.log

Viewing Logs

# Today's Gemini log
cat var/logs/api/gemini/gemini-2026-05-04.log

# Search for a specific ticket
grep "ticket_id.*8826" var/logs/api/gemini/*.log

Log Entry Format

Each entry includes:

  • Timestamp
  • Request URL
  • Request body (ticket data sent to Gemini)
  • Response status code
  • Response body (AI results)
  • Duration (milliseconds)

Sensitive headers (API keys) are automatically redacted in logs.


Troubleshooting

IssueSolution
AI fields not updatingCheck ost_gemini_queue for pending items; verify cron is running
"API Error" in logsVerify Gemini API key is valid; check model fallback chain in logs
Urgency always LOWReview customer type; check if enough thread content is sent
AI Assistant not respondingCheck Pinecone connectivity; verify embeddings exist
Embeddings not generatingCheck Gemini embedding API key; review cron error output
Critical alerts not sendingCheck dedup table; verify alert email template exists
AI fields blank on ticketVerify custom form is attached to ticket; check form_entry linkage

Disabling AI Features

To disable AI features without removing configuration:

ToggleEffect
Disable AI ProcessingStops urgency analysis; queue items will accumulate but not process
Disable AI AssistantHides chat widget; staff cannot use chatbot
Stop Gemini cronNo processing occurs; queue grows until cron resumes
Stop Embeddings cronNew tickets won't be searchable by AI; existing vectors remain
note

Disabling AI processing does not delete existing AI field values on tickets. Historical data is preserved.