Four example workflow packages proving the engine end-to-end: - Bug Report Triage: public entry, branch routing, SLA timer - Employee Onboarding: Starlark automated stages, signoff gate - Content Approval: multi-party signoff, revision cycle loop - Webhook Notifier: http.post, connections fallback, delivery logging Demo surface at /s/workflow-demo with cards, stage diagrams, Starlark viewer, API examples, active/published status, and copyable public links. Engine fixes: started_by in automated context, sla_seconds in package installer, parseSnapshotStages for wrapped/legacy formats. Platform fixes: extension SDK boot in base.html (Preact globals + boot()), admin teams paginated response extraction, workflow adoption endpoint (POST /teams/:teamId/workflows/:id/adopt), team-admin copyable link. Review pass remains on roadmap for remaining UI polish. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
42 lines
1.2 KiB
Plaintext
42 lines
1.2 KiB
Plaintext
def on_fire(ctx):
|
|
"""Fire outbound webhook with optional connection credentials."""
|
|
data = ctx["stage_data"]
|
|
url = data.get("webhook_url", "")
|
|
|
|
# Fallback to configured connection
|
|
if not url:
|
|
conn = connections.get("webhook")
|
|
if conn:
|
|
url = conn.get("url", "")
|
|
|
|
if not url:
|
|
return {"error": "No webhook URL configured"}
|
|
|
|
payload = json.encode({
|
|
"event": data.get("event_name", "workflow.notify"),
|
|
"instance_id": ctx["instance_id"],
|
|
"workflow_id": ctx["workflow_id"],
|
|
"data": data,
|
|
})
|
|
|
|
resp = http.post(url, body=payload, headers={
|
|
"Content-Type": "application/json",
|
|
"X-Switchboard-Event": data.get("event_name", "workflow.notify"),
|
|
})
|
|
|
|
# Log the delivery
|
|
db.insert("webhook_log", {
|
|
"url": url,
|
|
"status_code": str(resp["status"]),
|
|
"event": data.get("event_name", ""),
|
|
"instance_id": ctx["instance_id"],
|
|
})
|
|
|
|
status = "delivered" if int(resp["status"]) < 400 else "failed"
|
|
|
|
return {"advance": True, "data": {
|
|
"delivery_status": status,
|
|
"status_code": str(resp["status"]),
|
|
"response_body": resp["body"][:500],
|
|
}}
|