16 โ AI Features (Phase 9 stub)
Status: ๐ก Adapter ready (Phase 7) ยท Features wiring deferred to Phase 9 Last updated: 2026-05-14
Architecture (Already Built)
All LLM access via format-based adapters per global no-hardcoded-providers rule. See:
app/Adapters/Llm/LlmAdapterContract.phpโ interfaceapp/Adapters/Llm/OpenAICompatibleAdapter.phpโ covers OpenAI/DeepSeek/Groq/Mistral/Together/OpenRouter/xAI/Ollama/LM Studio/vLLMapp/Adapters/Llm/AnthropicFormatAdapter.phpโ for native Anthropic API formatapp/Adapters/Llm/LlmAdapterFactory.phpโLlmAdapterFactory::active()returns adapter for the active provider
Owner inputs everything via admin UI: base_url, api_key, default_model. Pricing per 1M tokens (optional, for cost tracking).
$llm = LlmAdapterFactory::active();
if (! $llm) {
// Feature disabled โ owner hasn't configured an LLM provider
return ['error' => 'No LLM provider configured. Set up in Settings โ Providers.'];
}
$response = $llm->chat([
['role' => 'system', 'content' => 'You are a helpful sales assistant.'],
['role' => 'user', 'content' => "Draft a proposal for {$client->company_name} about web design."],
], ['model' => $userPickedModel, 'temperature' => 0.7]);
echo $response->content;
Features to Build (Phase 9)
9.A AI Proposal Drafting
Trigger: Proposal create form โ "Draft with AI" button Input:
- Lead/Client context (industry, size, prior projects)
- Selected service template (web design, app dev, consulting)
- Tone (formal, friendly, casual)
Process:
- Build prompt from template (
config/ai-prompts/proposal-drafting.php) - Call
LlmAdapterFactory::active()->chat(...) - Stream response into TipTap editor
- User reviews, edits, finalizes
Per-feature model picker: Owner sets which provider for proposal drafting in Settings โ AI. Empty โ feature disabled.
9.B Email Thread Summarization
Trigger: Long ticket thread โ "Summarize for me" button on ticket detail Output: Bullet-point summary of issue + actions taken so far
9.C Smart Lead Scoring
Trigger: Lead create / activity log update Process: LLM scores 1-10 based on company size, industry, expressed urgency, source quality Display: Lead list shows AI score badge
9.D KB Article Suggestion (Ticket Form)
Trigger: Customer types ticket subject + body Process: Semantic search against published KB articles using embeddings (if embedding endpoint configured) or LLM-based relevance Display: "Maybe this helps?" โ suggest top 3 articles before submit
9.E Auto-Tag Ticket
Trigger: Ticket created Process: LLM classifies into: bug, feature-request, billing, how-to, complaint Display: Auto-set tag, agent can override
9.F Customer Communication Drafting
Trigger: Ticket reply, follow-up email Process: LLM drafts response based on conversation history + tone preference Display: Editable draft in reply box
Cost Control
- Per-feature toggle on/off (Settings โ AI Features)
- Per-feature provider assignment (different model for different task โ owner choice)
- Usage tracking:
llm_usagetable logs prompt_tokens + completion_tokens per call - Owner inputs
cost_per_1m_inputandcost_per_1m_outputper provider for spend dashboard - Monthly budget cap with auto-disable when exceeded (optional)
Privacy
- Sensitive data (full SSN, bank numbers, credit cards) stripped from prompts via regex pre-processor
- Owner can opt-in/opt-out per data type
- LLM calls logged with redacted prompt (for debugging only, retention 30 days)
- Documentation explicitly states what data goes to LLM provider
Local-First Option
Configure OpenAICompatibleAdapter with:
base_url:http://localhost:11434(Ollama)api_key: (empty)default_model:llama3.1:8b(or whatever you pulled)
Everything works the same โ no data leaves your network.
Implementation Order (Phase 9)
- Settings UI for per-feature provider assignment + toggle
- Usage tracking (
llm_usagetable + observer) - Proposal drafting (simplest, highest visible value)
- Ticket auto-tag (background, low risk)
- KB suggestion (requires embedding endpoint OR LLM relevance)
- Email summarization
- Lead scoring
- Communication drafting
Each feature is opt-in โ admin sets provider in Settings โ AI; if no provider, feature shows "Configure LLM provider to enable" message.