<!-- AANCER Developer Guide (English), step by step, part 2 of 3. All parts: https://aancer.ai/dev/llms.txt -->

## Build a workflow template

### The quick way: make it from a workflow

> need: the right `templates.author_own`.

1. Build and test the workflow in **Automations**.
2. Make a template from it under **Templates**.
3. Give every fixed value, such as connection or approver, a parameter.
4. Submit it for review. Another person approves it.
5. To take it to another installation, open the template and choose **Export as signed pack**.

For the other installation to accept the file, it needs the key of yours: choose **Extensions** > **Trust keys** > **Show key for another installation** and enter that key there.

### Write it by hand

1. Put this item into the manifest of chapter 3:

```
{ "kind": "template", "schemaVersion": 1, "id": "invoice-summary", "scope": "install",
  "spec": {
    "id": "tpl-acme-invoice-summary", "version": 1,
    "workspace": "{{param.target_workspace}}",
    "record": {
      "name": "Invoice summary with approval",
      "description": "Summarises an invoice, asks a person, then posts it.",
      "icon": "receipt", "industry": "financial", "complexity": "intermediate", "locale": "en",
      "aiAct": { "riskClass": "limited", "annexIiiCategory": "none",
        "intendedPurpose": "Summarise supplier invoices for a person who approves them.",
        "humanOversight": "A person approves every summary before it is posted.",
        "transparencyNote": "The summary is written by an AI model." },
      "compliance": { "dataCategories": ["invoice data"], "dataSubjects": [],
        "lawfulBasis": "contract", "retentionDays": 90 },
      "parameters": [
        { "id": "approvers_1", "type": "approvers", "label": "Who approves",
          "required": true },
        { "id": "conn_1", "type": "connection", "label": "Chat connection",
          "required": true, "connector": "connector-chat" } ],
      "bindings": [
        { "parameterId": "approvers_1", "stepId": "approve", "path": "approvers" },
        { "parameterId": "conn_1", "stepId": "post", "path": "connectorAuth" } ],
      "translations": {},
      "flow": { "name": "Invoice summary with approval", "rootStepId": "t", "steps": [
        { "id": "t", "type": "trigger", "name": "Invoice received",
          "position": { "x": 0, "y": 0 }, "triggerType": "webhook", "nextStepId": "sum" },
        { "id": "sum", "type": "aancer-ai", "name": "Summarise",
          "position": { "x": 0, "y": 120 }, "modelTier": "local-standard",
          "dataClassification": "internal",
          "systemPrompt": "Summarise the invoice: supplier, amount, due date.",
          "userPromptTemplate": "{{trigger.body.text}}", "nextStepId": "approve" },
        { "id": "approve", "type": "approval", "name": "Approve summary",
          "position": { "x": 0, "y": 240 },
          "approvalMessage": "Approve this invoice summary?",
          "approvalReasoning": "{{sum}}", "nextStepId": "post" },
        { "id": "post", "type": "connector", "name": "Post to channel",
          "position": { "x": 0, "y": 360 }, "connectorPiece": "connector-chat",
          "connectorAction": "send",
          "connectorInputs": { "channel": "finance", "text": "{{sum}}" } } ] },
      "createdAt": "2026-11-20T00:00:00.000Z" } } }
```

2. Replace `connector-chat` and `send` by a connector and an action of the target installation.
3. Add the parameter `target_workspace` (type `workspace`, not required) to the manifest. If it stays empty, the template is for everybody.
4. Sign, import, activate.
5. Try it: choose the template in the gallery, fill in the fields, run it.

### Rules you must follow

- Exactly one step is the trigger. `rootStepId` is its id
- `nextStepId` names the next step
- Earlier results: `{{trigger.body.text}}` or `{{stepId}}`
- No ids of connections, knowledge sets, agents or approvers in the steps. Bind a parameter
- No passwords or keys, not even in texts
- Templates with AI steps need a risk class and a purpose
- Words such as "employ", "exam" or "screen" make a template high risk, also inside other words. Then it needs an oversight text too

> warn: In release 1.0.0-rc2.3 scheduled workflows run in UTC even if you set a time zone. Approver lists and time limits of approval steps are not enforced. Plan for both.

## Build an agent blueprint

A blueprint is the plan of an agent. People make their own agent from it.

### The quick way: export an agent

> need: the right `agents.publish_own`.

1. Build, test and publish the agent.
2. Export it with the API call `POST /api/agents/{id}/export-for-submission` (see the reference).

Connections, forms, limits, memory and persona are not exported.

### Write it by hand

1. Put this item into the manifest:

```
{ "kind": "agent-blueprint", "schemaVersion": 1, "id": "invoice-triage", "scope": "install",
  "spec": {
    "name": "Invoice triage",
    "description": "Sorts incoming invoices and drafts the booking proposal.",
    "instructions": "You sort incoming invoices. Name supplier, amount and cost centre. Never book.",
    "starters": ["Sort today's invoices"],
    "model": { "tier": "local-standard" },
    "tools": [ { "kind": "knowledge", "ref": "{{param.policies}}" } ],
    "skills": [], "riskHint": null } }
```

2. Add a parameter `policies` (type `string`, not required). The administrator enters the id of a knowledge set there.
3. Sign, import, activate.
4. Choose **Agents** > **Create agent** and pick the blueprint.
5. Read what was left out, for example because a parameter is empty.
6. Test and publish the agent.

### Rules you must follow

- Name a tier (`local-standard`, `local-advanced`, `cloud-reasoning`), never a model
- Knowledge is always a parameter
- Workflows and other agents must be in the same pack, or be a parameter
- Web search must be declared under `declarations.dataFlows` with `web-search`
- Code and MCP tools are not possible

> tip: Workflows that start by web call, schedule or event only work with certified agents. Use a manual or form start if you can.

## Build a dashboard

### The quick way: on the screen

1. Choose **Dashboards** > **New dashboard**.
2. Choose **Add widget**, or **Help me build** and describe what you want.
3. Choose **Save draft**, then **Publish**.
4. Choose **Export as pack** to take it to another installation.

### Write it by hand

A dashboard has four layers: **dataset** (the table), **model** (what is counted), **widget** (one chart) and **dashboard** (the page).

1. Write four files. The lines with `//` only show the file name; leave them out:

```
// content/dataset.json
{ "id": "sales_orders", "title": "Sales orders",
  "columns": [
    { "id": "date", "type": "date", "required": true },
    { "id": "region", "type": "string", "required": true },
    { "id": "amount", "type": "number", "min": 0 } ],
  "retention": { "maxAgeDays": 730 } }

// content/model.json
{ "id": "sales",
  "entities": { "orders": { "dataset": "sales_orders" } },
  "dimensions": { "region": { "entity": "orders", "column": "region", "label": "Region" } },
  "measures": { "revenue": { "entity": "orders", "agg": "sum", "column": "amount",
                             "label": "Revenue", "format": "currency" } } }

// content/widget.json
{ "id": "revenue_by_region", "type": "chart", "title": "Revenue by region",
  "source": { "model": "sales",
              "query": { "measures": ["revenue"], "dimensions": ["region"] } },
  "chart": { "mark": "bar", "encoding": {
    "x": { "field": "region", "type": "nominal" },
    "y": { "field": "revenue", "type": "quantitative" } } } }

// content/dashboard.json
{ "id": "sales-overview", "title": "Sales overview", "icon": "BarChart3",
  "layout": [ { "widget": "revenue_by_region", "x": 0, "y": 0, "w": 12, "h": 8 } ] }
```

2. Put them into the manifest:

```
"parameters": [
  { "id": "target_workspace", "type": "workspace", "label": "Workspace",
    "required": true } ],
"items": [
  { "kind": "dataset", "schemaVersion": 1, "id": "sales_orders", "scope": "workspace",
    "workspace": "{{param.target_workspace}}", "spec": { "$ref": "content/dataset.json" } },
  { "kind": "model", "schemaVersion": 1, "id": "sales", "scope": "workspace",
    "workspace": "{{param.target_workspace}}", "spec": { "$ref": "content/model.json" } },
  { "kind": "widget", "schemaVersion": 1, "id": "revenue_by_region", "scope": "workspace",
    "workspace": "{{param.target_workspace}}", "spec": { "$ref": "content/widget.json" } },
  { "kind": "dashboard", "schemaVersion": 1, "id": "sales-overview", "scope": "workspace",
    "workspace": "{{param.target_workspace}}", "spec": { "$ref": "content/dashboard.json" } } ]
```

3. Sign, import, activate and choose the workspace.
4. Fill the dataset: with a publish step in a workflow, with an agent, or with an app.

### Rules you must follow

- A page is 12 columns wide. Widgets must not overlap
- A chart contains no data, no web address and no `$schema`
- Every dataset needs a limit: `maxAgeDays` or `maxRows`
- A dataset with rows is never deleted when the pack is removed

## Build a hook

A hook starts a workflow or an agent when something happens in AANCER.

### The events

| Event | Happens when |
|-|-|
| `run.completed`, `run.failed` | a workflow ended well or badly |
| `approval.requested`, `approval.decided` | an approval is asked for or decided |
| `dataset.rows.published` | a dataset got new rows |
| `dashboard.published` | a dashboard was published |
| `document.ingested` | a document was read into a knowledge set |
| `user.provisioned`, `workspace.member.changed` | people were added or changed |
| `schedule.run.completed` | a scheduled chat task ran |

`GET /api/events/catalog` shows the list of your installation with sample data.

### The quick way: on the screen

> need: the right `hooks.manage_own`.

1. Build a workflow that starts with the AANCER event trigger, and publish it.
2. Choose **Automations** > **Hooks** > **New hook**.
3. Choose the event and the workflow or agent.
4. Add conditions with **Add clause**.
5. Choose **Test filter**. Nothing is started by this.
6. Choose **Create hook**.

### Write it by hand

1. Put this item into the manifest:

```
{ "kind": "hook", "schemaVersion": 1, "id": "rejected_approvals", "scope": "workspace",
  "workspace": "{{param.target_workspace}}",
  "spec": {
    "id": "rejected_approvals", "title": "Rejected approvals",
    "event": { "name": "approval.decided", "version": 1 },
    "filter": [ { "path": "payload.outcome", "op": "eq", "value": "rejected" } ],
    "handler": { "type": "workflow", "ref": "flow_notify_requester" } } }
```

2. The workflow must already exist in the target workspace. Its id goes into `ref`.
3. Sign, import, activate.

### When it does not start

1. Open **Hooks** and choose **Deliveries**.
2. Read the error.
3. Repair the workflow and choose **Retry**.

> tip: A hook calls no web address. Let the workflow do that.

## Build a theme

### Write it

1. Put this item into the manifest:

```
{ "kind": "theme", "schemaVersion": 2, "id": "acme-ci", "scope": "install",
  "spec": {
    "id": "acme-ci", "platformName": "Acme Cloud", "tagline": "Your data. Your AI.",
    "defaultTheme": "light",
    "typography": { "ui": "system-ui, sans-serif" },
    "themes": {
      "light": { "--bg": "#FAFAF7", "--s1": "#FAFAF7", "--s2": "#FFFFFF",
                 "--t0": "#1B2430", "--ac": "#0F6E74", "--aci": "#FFFFFF", "--pr": "#0B1F3A" },
      "dark":  { "--bg": "#0E1420", "--s1": "#0E1420", "--s2": "#151C2A",
                 "--t0": "#E9EDF3", "--ac": "#5CC6C9", "--aci": "#0B1F22" } },
    "login": { "backgroundColor": "#0B1F3A", "tagline": "Welcome to Acme Cloud" } } }
```

2. For your own fonts (`.woff2`) and logos (`.png`, `.svg`), make the folders `content/fonts/` and `content/logos/` and name the files in `fonts` and `logos`.
3. Sign and import.
4. Read the contrast warnings and correct the colours.
5. Activate and reload the browser.

### Switch between looks

1. Choose **Platform Settings** > **Look & feel**.
2. Choose **Apply** at a look.

### Rules you must follow

- No web addresses, not even in the tagline or footer
- Colours as `#rrggbb` or `rgba(…)`
- Every file at most 2 MiB
- A theme for one workspace has no login page and no e-mail colours

### Rename words on the screen

1. Add an item of the kind `locale` with the scope `install`:

```json
{ "kind": "locale", "schemaVersion": 1, "id": "en-words", "scope": "install",
  "spec": { "locale": "en", "keys": { "nav.knowledge": "Handbooks" } } }
```

2. Sign, import, activate.

Next part: https://aancer.ai/dev/parts/guide/03-build-an-embedded-app.md
