# Campaigns App Improvement Specification ## Current State Analysis The Campaigns app (`botui/ui/suite/campaigns/campaigns.html`) provides multi-channel marketing with: - Campaign grid view with status badges - Channel filters (Email, WhatsApp, Social) - Lists and Templates tabs - Basic campaign creation modal - Metrics display (sent, opened, clicked) ## Critical Issues to Fix ### 1. Missing Backend Integration **Problem:** All data loading endpoints return empty or placeholder data **Fix Required:** ``` GET /api/crm/campaigns - Returns campaign list GET /api/crm/lists - Returns contact lists GET /api/crm/templates - Returns message templates POST /api/crm/campaigns - Creates new campaign ``` **Expected Response Format:** ```json { "campaigns": [ { "id": "uuid", "name": "Welcome Series", "status": "running", "channels": ["email", "whatsapp"], "metrics": { "sent": 1250, "opened": 890, "clicked": 234 }, "budget": 500.00, "scheduled_at": "2026-03-20T10:00:00Z" } ] } ``` ### 2. Campaign Card Template Missing **Problem:** Backend returns JSON but frontend expects HTML **Fix:** Backend must return HTML fragments: ```html

{{name}}

{{status}}
{{#each channels}} {{icon}} {{name}} {{/each}}
{{metrics.sent}} Sent
{{metrics.opened}} Opened
{{metrics.clicked}} Clicked
``` ### 3. Form Submission Not Working **Problem:** Modal form uses HTMX but doesn't refresh list after creation **Fix:** ```javascript document.getElementById('campaign-form').addEventListener('htmx:afterRequest', function(e) { if (e.detail.successful) { hideCampaignModal(); // Refresh campaigns list htmx.ajax('GET', '/api/crm/campaigns', { target: '#campaignsList', swap: 'innerHTML' }); } else { // Show error message const error = e.detail.xhr.responseText; showError(error); } }); ``` ### 4. Channel Filter Not Working **Problem:** Filter function checks text content instead of data attributes **Fix:** ```html
``` ## Major Improvements Needed ### 5. Campaign Builder Wizard **What:** Multi-step campaign creation with preview **Implementation:** ```html

Campaign Details

Select Audience

Create Message

Schedule Campaign

Review & Launch

``` ### 6. Contact List Management **What:** Create and manage segmented contact lists **Implementation:** ```html ``` ### 7. Message Template Editor **What:** Rich template editor with variables and preview **Implementation:** ```html

Preview

``` ### 8. Campaign Analytics Dashboard **What:** Detailed metrics and performance tracking **Implementation:** ```html

Campaign Performance

Total Sent 0 +12%
Open Rate 0% +5%
Click Rate 0% -2%
Conversion Rate 0% +8%

Campaign Performance Over Time

Channel Breakdown

Top Performing Campaigns

Campaign Channel Sent Opened Clicked Converted
``` ### 9. A/B Testing **What:** Test different message variants **Implementation:** ```html

A/B Test Setup

Variant A (50%)

Variant B (50%)

hours
``` ### 10. WhatsApp Integration **What:** Send WhatsApp campaigns with media support **Implementation:** ```html

Quick Reply Buttons

``` ## Continued in CAMPAIGNS-PART2.md...