# Telegram Safe Campaign Launchpad Implementation Plan

> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.

**Goal:** Add a safe admin-only Telegram launchpad for previewing a small audience and queueing template-based campaign notifications without automation complexity.

**Architecture:** A Livewire admin page delegates to focused Telegram actions for audience resolution, preview shaping, and queue execution. The page only previews and queues; delivery stays in the existing Telegram queue/job pipeline.

**Tech Stack:** Laravel 12, Livewire, Spatie permissions, Telegram notification queue, audit logging.

---

### Task 1: Add failing admin UI tests for launchpad access and preview

**Files:**
- Modify: `C:/Users/a-djoudi/apps/ecoinv3/tests/Feature/Telegram/TelegramAdminUiTest.php`
- Test: `C:/Users/a-djoudi/apps/ecoinv3/tests/Feature/Telegram/TelegramAdminUiTest.php`

- [ ] Write failing tests for launchpad page access and masked preview rows.
- [ ] Run the targeted tests and confirm they fail for missing route/page behavior.
- [ ] Commit after the tests are in place and failing.

### Task 2: Add failing admin UI tests for queueing, dedupe, and audience filters

**Files:**
- Modify: `C:/Users/a-djoudi/apps/ecoinv3/tests/Feature/Telegram/TelegramAdminUiTest.php`
- Modify: `C:/Users/a-djoudi/apps/ecoinv3/tests/Concerns/UsesMinimalTelegramSchema.php`

- [ ] Add failing tests for queueing pending notifications, duplicate prevention, and campaign-matched audience filtering.
- [ ] Add minimal audit table support in the Telegram test harness if required by the queue action.
- [ ] Run the new targeted tests and confirm they fail for missing implementation.

### Task 3: Implement Telegram campaign audience resolution and preview actions

**Files:**
- Create: `C:/Users/a-djoudi/apps/ecoinv3/app/Domain/Telegram/Actions/ResolveTelegramCampaignAudienceAction.php`
- Create: `C:/Users/a-djoudi/apps/ecoinv3/app/Domain/Telegram/Actions/PreviewTelegramCampaignAudienceAction.php`

- [ ] Implement verified-only audience resolution for the three supported audience types.
- [ ] Implement masked preview shaping with a small preview limit.
- [ ] Re-run the preview-focused tests and confirm they pass.

### Task 4: Implement queue action and admin launchpad page

**Files:**
- Create: `C:/Users/a-djoudi/apps/ecoinv3/app/Domain/Telegram/Actions/QueueTelegramCampaignLaunchAction.php`
- Create: `C:/Users/a-djoudi/apps/ecoinv3/app/Livewire/Admin/Telegram/CampaignsPage.php`
- Create: `C:/Users/a-djoudi/apps/ecoinv3/resources/views/livewire/admin/telegram/campaigns-page.blade.php`

- [ ] Implement queue action with hard cap, idempotent fingerprint checks, and audit logging.
- [ ] Implement Livewire page state, preview action, and queue action wiring.
- [ ] Re-run the queue-focused tests and confirm they pass.

### Task 5: Wire permissions, routes, navigation, and translations

**Files:**
- Modify: `C:/Users/a-djoudi/apps/ecoinv3/app/Support/Rbac/PermissionCatalog.php`
- Modify: `C:/Users/a-djoudi/apps/ecoinv3/routes/web.php`
- Modify: `C:/Users/a-djoudi/apps/ecoinv3/resources/views/components/portal/sidebar.blade.php`
- Modify: `C:/Users/a-djoudi/apps/ecoinv3/lang/ar/telegram.php`
- Modify: `C:/Users/a-djoudi/apps/ecoinv3/lang/fr/telegram.php`
- Modify: `C:/Users/a-djoudi/apps/ecoinv3/lang/ar/admin_nav.php`
- Modify: `C:/Users/a-djoudi/apps/ecoinv3/lang/fr/admin_nav.php`

- [ ] Add `telegram.campaigns.manage` to the permission catalog and the appropriate roles.
- [ ] Add the admin route and Telegram workspace navigation link.
- [ ] Add the launchpad copy and labels in AR/FR.

### Task 6: Update documentation and verify

**Files:**
- Modify: `C:/Users/a-djoudi/apps/ecoinv3/docs/telegram_platform_architecture.md`

- [ ] Document the manual launchpad and its safety boundaries.
- [ ] Run `php artisan test tests/Feature/Telegram/TelegramAdminUiTest.php`.
- [ ] Run `php artisan app:architecture-check`.
- [ ] Confirm the Telegram launchpad adds no new architecture findings.
