Orishare
Concepts

AI drafting

Describe a campaign in plain language; get validated rule documents to review, simulate and publish.

AI drafting turns a sentence into rule documents. It is a drafting tool, not a decision maker: the model never runs on the event path, a draft is never published by itself, and every draft is validated against your environment before you see it (ADR 0008).

How a draft is made

  1. Context. The API compiles a bounded description of the environment: the business description and vocabulary from GET /context, observed event names with their property types and a couple of samples, declared attributes (those flagged as personal data are left out), currencies, active rewards, tier programs, segments, counters, campaigns and existing rules. Sample values under personal-looking keys are redacted, and samples are framed as data so text inside an event cannot instruct the model.
  2. Draft. POST /ai/rule_drafts with { "request": "…" }. The model answers with rules, an explanation per rule, the assumptions it made and, when it could not draft safely, questions.
  3. Gate. Each rule goes through the same validator as POST /rules plus checks the request makes possible: the trigger event must have been observed, event.properties.* paths must exist on that event, segments must exist, a cap mentioned in the request must appear as a limit, and literal amounts must come from the request or the assumptions.
  4. Result. 201 with the generation (rules, assumptions, questions, model, token usage), or 422 ai_draft_rejected whose details carry the errors, questions and assumptions so the dashboard can ask you for the missing piece. Model failures are 503 ai_unavailable.
orishare ai draft "When a customer buys an audiobook give them 100 points, 50 more halfway through, and 200 when they finish. Each only once per title."

Reviewing and publishing

In the dashboard, Rules › Draft with AI shows each drafted rule with its explanation and a one-line summary. Open in builder creates the rule as a draft with the generation linked (ai_generation_id on POST /rules); simulate it against a sample event, then publish. The generation records the rule and the version it became, so every published rule can be traced to the request that produced it.

Limits and switches

  • Every attempt counts against the plan's monthly ai_drafts quota (429 quota_exceeded past it).
  • Owners and admins can switch drafting off for the whole organization under Settings › Context; the API then answers 403 ai_drafting_disabled.
  • Requests are capped at 4,000 characters and drafts at 10 rules; ask for fewer with max_rules.

What the model sees

GET /ai/rule_drafts/{id} returns the stored generation including a snapshot of the context (names only, never values) and how much was truncated to fit. Personal data attributes never enter the prompt; delete a customer and their events leave the samples as well.

On this page