AI Workflow Generation

This guide covers Hyphen's advanced prompt-to-workflow drafting flow.

It is best used when you want to:

  • bootstrap a first draft quickly
  • work close to the runtime and workflow artifact layer
  • generate a spec, review it, and then provision it deliberately

If you want a more guided authoring experience, start with Process Studio.

What this path produces

A generation request can produce:

  • a workflow definition
  • actions to register
  • custom tables to create
  • external dependency notes, when the draft needs surrounding configuration

The output is powerful, but it still benefits from review before you provision it.

Step 1: Submit a generation request

Describe what you want the workflow to do in plain language:

bash
curl -X POST https://your-hyphen.example.com/ai/generate-workflow   -H "X-Org-Id: acme-corp"   -H "Content-Type: application/json"   -d '{
    "prompt": "Create a workflow that processes incoming invoices. For each invoice, match it against our payment records using PO number and vendor ID. If a match is found within a $50 tolerance, auto-reconcile it. If no match is found, have an AI agent investigate the exception by looking up the purchase order and checking payment history. For invoices over $10,000 that the agent cannot resolve, require manager approval before writing off. Log everything to an audit table.",
    "llmOptions": {
      "model": "gpt-4o",
      "temperature": 0.7
    }
  }'

Response:

json
{
  "generation_id": "llm_gen-123e4567-e89b-12d3-a456-426614174000",
  "status": "processing",
  "message": "Workflow generation initiated. Please use the status endpoint to track progress."
}

Step 2: Poll generation status

bash
curl https://your-hyphen.example.com/ai/generate-workflow/llm_gen-123e4567-e89b-12d3-a456-426614174000/status   -H "X-Org-Id: acme-corp"

Step 3: Retrieve the generated draft

bash
curl https://your-hyphen.example.com/ai/generate-workflow/llm_gen-123e4567-e89b-12d3-a456-426614174000   -H "X-Org-Id: acme-corp"

The response includes the generated workflow and any supporting artifacts the generator produced.

What to review before provisioning

Treat the output as a draft, not something you should publish blindly.

Review:

  • the step sequence
  • branching conditions
  • matcher configuration
  • agent objectives and tools
  • action references
  • context paths
  • custom table assumptions
  • external dependencies that still need real configuration

Step 4: Submit the provisioning request

Use create-from-ai to create the workflow, register actions, and provision tables in one call:

bash
curl -X POST https://your-hyphen.example.com/workflows/create-from-ai   -H "X-Org-Id: acme-corp"   -H "Content-Type: application/json"   -d '{
    "hyphen_workflow_definition": { ... },
    "actions_to_register": [ ... ],
    "custom_tables_to_create": [ ... ],
    "workflow_description": "Invoice matching with exception handling",
    "has_exception": false
  }'

Response:

json
{
  "process_id": "wf_cre-123e4567-e89b-12d3-a456-426614174000",
  "status": "processing_creation",
  "message": "Workflow creation initiated. Please use the status endpoint to track progress."
}

Step 5: Poll provisioning status

bash
curl https://your-hyphen.example.com/workflows/create-from-ai/wf_cre-123e4567-e89b-12d3-a456-426614174000   -H "X-Org-Id: acme-corp"

Important caveat

Generated actions may still need configuration before they are ready for production use.

For example:

  • URLs may need to be filled in
  • headers may need secrets
  • database queries may need refinement
  • descriptions may need cleanup

The generator gets you to a draft faster. It does not remove the need for review.

Prompting tips

Better prompts usually include:

  • the business record or object being processed
  • the fields to match or compare
  • thresholds and confidence rules
  • what the agent should investigate
  • when a human should step in
  • whether the workflow is scheduled

Example: weak prompt

Create a workflow to process invoices

Example: stronger prompt

Create a workflow that matches incoming invoices to payment records on PO number and vendor ID with a $50 amount tolerance and a 5-day date window. Use fuzzy matching on vendor names at 85% threshold. For unmatched invoices, have an AI agent investigate by looking up the PO in our ERP, checking payment history, and searching for duplicates. If the agent's confidence is below 0.8, pause for human review. Log the results to a reconciliation_audit table. Run daily at 6 AM Eastern.

For most teams, a good pattern is:

  1. generate a draft from a business description
  2. review and refine the output
  3. provision deliberately
  4. iterate once the workflow shape is clearer

If you want a product surface that structures that process more tightly, use Process Studio.