Skip to main content

Scenario

Your content team creates brief tasks in Asana with structured descriptions: topic, target audience, content type, key messages, and SEO keywords. When a brief task moves to “Brief Complete” status, this job automatically generates a full content draft using Mavera’s Generate endpoint, then attaches the draft URL as a comment on the Asana task. Editors pick up drafts instead of blank pages. Flow: Asana GET /tasks (filter: “Brief Complete” section) → Extract brief fields → Mavera POST /api/v1/generationsPOST /tasks/{id}/stories (attach result as comment)

Code

Example Output

Error Handling

The code searches for sections containing “brief complete” (case-insensitive). If your workflow uses different names like “Ready for Writing” or “Approved Brief”, adjust the search string.
Asana story (comment) text is limited to 100,000 characters. Long drafts are truncated to 15,000 chars. For very long content, post a summary comment with a link to the full draft in a shared doc.
The addTask/removeTask section endpoints are separate calls. If the “Draft Ready” section doesn’t exist, the task stays in “Brief Complete” — no error is thrown, just no movement.
Running this job twice generates duplicate drafts. Add a check: before generating, fetch task stories and skip if a comment containing “Auto-generated draft” already exists.