# AgentForms Template Library — Agent-Specific Form Patterns

Pre-built form templates designed for AI agent workflows. Each template defines the exact field structure for a common agent-to-human interaction pattern.

## Quick Reference

| Template | Purpose | Fields | Best For |
|----------|---------|--------|----------|
| `approval_gate` | Yes/No decision + feedback | 2 | Budget approval, content sign-off |
| `option_selector` | Choose from options | 2 | Multiple choice, preference selection |
| `data_validation` | Confirm/correct data | N+1 | Fact-checking, data correction |
| `feedback_loop` | Rating + open feedback | 2 | Quality assessment, iteration feedback |
| `data_collection` | Structured data gathering | N | Research, surveys, intake |
| `sign_off` | Formal approval with audit | 3 | Compliance, legal, financial |

## Usage with SDK

```python
from agentforms import AgentForms
import json

af = AgentForms(api_key="afk_live_...")

# Load a template
with open("templates/approval_gate.json") as f:
    template = json.load(f)

# Create form from template
form = af.forms.create(
    name=template["name"],
    fields=template["fields"],
    metadata=template.get("metadata"),
)
print(form.share_url)
```

```typescript
import { AgentForms } from "@agentforms/sdk";
import * as template from "./templates/approval_gate.json";

const af = new AgentForms("afk_live_...");

const form = await af.forms.create({
    name: template.name,
    fields: template.fields,
    metadata: template.metadata,
});
console.log(form.share_url);
```

## Template Schema

Each template is a JSON file with:

```json
{
  "id": "template_id",
  "name": "Display Name",
  "description": "What this template does",
  "pattern": "Pattern name (e.g., approval_gate)",
  "fields": [
    {
      "name": "snake_case_field",
      "label": "Display Label",
      "type": "text|email|tel|textarea|select|number|date|hidden",
      "required": false,
      "options": ["option1", "option2"],
      "placeholder": "..."
    }
  ],
  "metadata": {
    "agent_context": "What metadata to attach",
    "webhook_handler": "How to process the response"
  },
  "example_payload": {
    "field_name": "example_value"
  }
}
```

## Adding Custom Templates

1. Create a new JSON file in this directory
2. Follow the schema above
3. Define fields that match your agent's needs
4. Test with the SDK before deploying
