Approvals
asked = m.propose("send_quote", title="Email the quote to Ava", detail={"quote": 41})The owner sees it on Approvals, and a push on their phone. When they say yes, your Ownbox runs what m.on_approve(kind, fn) registered, once, with detail. The same kind and detail while one waits is the same proposal. Never raises.
- Needs in machine.yaml
- Nothing
- Returns
{"status": "waiting" | "repeat" | "refused", "id", "code", "reason", "href"}. Decide oncode: "no_such_kind" (register it withm.on_approvefirst), "bad_kind", "too_large" (detail over 16,000 characters as JSON), "bad_title".
def send_quote(detail):
pid = m.person("email", "ava@example.com")
return m.send_email(pid, {"subject": "Your quote", "text": "Here it is."}, key=f"quote:{detail['quote']}")
m.on_approve("send_quote", send_quote)fn(detail) runs once, after they said yes. kind is lowercase letters, digits and underscores; register it before the machine proposes one.
- Needs in machine.yaml
- Nothing