# Keyful — workflow authoring for an external AI / créer un scénario avec une IA

Return one JSON object matching `workflow.schema.json`. Use `daily-operations.json` as a structural example. Importing never executes or activates a workflow. The user reviews it, connects accounts, completes fields and explicitly saves/activates it in Keyful.

Répondez avec un seul objet JSON respectant `workflow.schema.json`. L’import se fait toujours en pause, dans un brouillon. L’exemple Google Agenda est volontairement incomplet : l’utilisateur doit sélectionner un compte et compléter les champs retournés par le fournisseur.

## Format

- `format`: exactly `keyful.workflow`; `version`: exactly `1`.
- `name`: 1–160 characters.
- `trigger.event`: one of the supported events in the schema.
- `schedule`: required for `schedule.due`; otherwise `null`. Local timezone is an IANA name. Interval is 15–1440 minutes. Weekly days: Monday=1, Sunday=7.
- `actions`: ordered execution tree; at most 60 nodes, nesting at most 5 levels.
- `canvas.positions`: optional visual coordinates keyed by node ID. `__trigger` is reserved for the trigger; do not use it as an action ID.
- Node IDs must be unique, 1–80 ASCII letters/digits/underscores/hyphens. Outputs may be referenced by node ID: preserve IDs when editing existing workflows.

## Native actions

- `create_task`: config `title`, `description`, `priority` (`low`, `normal`, `high`, `urgent`), optional contextual property/reservation fields.
- `notify_team`: config `role`, `title`, `message`, `href`. Ask the user to choose a real team role in the editor; never invent a role and claim it exists.
- `send_message_draft`: prepares a draft; it is not an automatic send.
- `http_request`: configure a destination and method in the editor. Network destinations and credentials are validated at execution. Never embed keys in an export.
- Other recognized native kinds are listed in the schema. Use the editor for their authoritative configuration.

## External actions

`composio_action`: config `{ "toolkit": "googlecalendar", "tool": "GOOGLECALENDAR_CREATE_EVENT", "toolName": "Créer un événement", "arguments": {} }`.

`zernio_action`: same shape, with a real operation slug from Keyful's Zernio catalog. Do not invent slugs or parameters. Browse the action in Keyful, export a draft, and use the provider's actual field schema. Tool versions may be exported as `version` in config; server-side provider metadata remains authoritative.

Do not include `connectionId`, tenant/user IDs, approvals, HMACs, OAuth tokens, passwords, cookies or API keys. The target account is chosen after import. An export intentionally removes execution approvals and known credential keys. Review recipients and free-text content before sharing any export.

For an external trigger use `integration.received` with `trigger.toolkit`, `trigger.slug`, `trigger.config`. Reconnect its account and review its subscription in the editor. For an incoming webhook use `webhook.received`; the saved workflow receives its own webhook in Keyful, not a copied secret URL.

## Logic

- Filter: `{ "id":"only-open", "kind":"filter", "condition": { "combinator":"and", "rules":[{"field":"statut","operator":"equals","value":"open"}] } }`.
- Branch: same condition, plus `then: []` and `else: []`.
- Loop: `kind:"loop"`, `source` from the schema, `maxIterations` 1–25, `body: []`.
- Conditions support equals, not_equals, contains, not_contains, is_empty, is_not_empty, greater_than, less_than.
- Variables use `{{reservationId}}`, `{{propertyId}}`, `{{voyageur}}`, `{{statut}}`, or verified upstream module outputs. Never invent runtime variables. A scheduled workflow has no implicit reservation context.

## Review before activation / vérification

1. Validate JSON, node IDs, the trigger and schedule.
2. Import as a draft; never add an `enabled` field.
3. Select the accounts and complete required action fields from the provider schema.
4. Simulate the scenario. Simulation makes no external calls and does not verify a provider's live result.
5. Only use actual execution when the user intends its effects. Review logs afterward.
