Project

General

Profile

Actions

Task #931

closed

PE-1816: Add async persona generation with status webhook

Added by Fredrick Amnehagen about 2 hours ago. Updated 41 minutes ago.

Status:
Done
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
2026-05-16
Due date:
% Done:

100%

Estimated time:

Description

Problem

Persona generation is synchronous. User must poll for completion. No automatic notification when generation finishes.

Current Flow

  1. POST /api/v1/personas (sync request)
  2. If generation takes time, user must poll GET /api/v1/personas/{id}/status
  3. No automatic callback

Proposed Solution

  1. POST /api/v1/personas/generate-async - Returns job ID immediately
  2. GET /api/v1/personas/jobs/{id} - Check status
  3. Webhook sent when generation completes (PersonaReady event)

Async Job Flow

  1. User submits: POST /api/v1/personas/generate-async with {name, archetype, traits}
  2. Returns: {job_id: 'uuid', status: 'queued', poll_url: '/api/v1/personas/jobs/uuid'}
  3. Backend dispatches GeneratePersonaJob
  4. On complete: webhook sent to user's configured URL
  5. User can poll for status anytime

Benefits

  • Non-blocking API
  • Webhook notification on completion
  • Better UX for long-running generations
  • Support for bulk generation

Implementation

  • Use Laravel Queue (already configured)
  • Create GeneratePersonaJob
  • Add personas_jobs table (id, user_id, status, progress, result, error)
  • Modify WebhookService to dispatch on persona events

Files to Create/Modify

  • app/Jobs/GeneratePersonaJob.php
  • app/Http/Controllers/Api/PersonaJobController.php
  • database/migrations/ (personas_jobs table)
  • app/Services/PersonaService.php (event dispatch)
  • routes/api_v1.php
Actions #1

Updated by Fredrick Amnehagen 41 minutes ago

  • Status changed from To do to Done
  • % Done changed from 0 to 100

Added persona_jobs table, PersonaJob model, AsyncPersonaGenerationJob, PersonaJobController. Added POST /personas/generate-async (returns job_id immediately), GET /personas/jobs/{id} (status), POST /personas/jobs/{id}/retry, POST /personas/jobs/{id}/cancel. Webhook dispatched on completion.

Actions

Also available in: Atom PDF