Produce AI-written sample emails grounded in the session’s current skeleton. Async via Trigger.dev — returns a run id you poll elsewhere.
generate-email-examples Trigger.dev task, which reads the session’s current skeleton and produces one AI-written sample email per lead in the request body. Results are written back onto the session as generated_examples.
The call is async via Trigger.dev: the HTTP response returns a runId (and a publicAccessToken for the Trigger.dev realtime SDK) as soon as the task is enqueued. Observe progress by subscribing to the run via the realtime SDK, or by polling GET /api/campaigns/ai-chat-sessions/{id} until task_status returns to null and generated_examples is populated.
skeleton. Build one first by calling runAiChatTurn a few times until the framework LLM converges. Calling this endpoint before a skeleton exists returns 400 (Session has no framework yet. Chat first to create one.).
task_status: "generating_examples" before dispatching. If another generate-examples run (or a /turn call) is already in flight, the update finds task_status !== null, fails to claim, and the handler returns 409. Wait for task_status to clear, then retry.
leads small (3–10) unless you actually need every prospect’s sample.isFirstBatch controls append vs seed. Pass true on the first call for a session to overwrite generated_examples. Subsequent calls with false append — useful for top-up runs that regenerate samples for just the newly-added prospects.Rate limit: one active task per session. A 409 means either a /turn run or a prior /generate-examples run is still going. Poll GET .../{id} every 2–5 s until task_status === null.On 500 during dispatch. The server releases the claim before returning 500 — the session is immediately retryable. No manual task_status reset is needed.When 400 says no framework. Build one via POST .../turn. A typical warmup is 2–4 turns. The skeleton field on the session must be non-null before this endpoint will accept a call.Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
AI chat session UUID
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$leads is the only required field. The generator reads the session's current skeleton and produces one example email per lead.
Leads to generate sample emails for. Must contain at least one lead.
1Context about where this email sits in the campaign sequence — helps the LLM write follow-ups that acknowledge prior touches.
Signals whether this is the first batch of examples for the session. The generator may seed generated_examples on true and append on false.
Task dispatched. Poll the session or subscribe to the Trigger.dev run for results.
Trigger.dev run id. Use with the Trigger.dev realtime SDK (plus publicAccessToken) for progress events, or poll GET /api/campaigns/ai-chat-sessions/{id} until task_status returns to null and generated_examples is populated.
Short-lived Trigger.dev public access token scoped to this run.