Creating Flows
Define a flow in YAML and create it in ServiceNow.
Basic Example
yaml
schema: nebula
name: Auto-close Resolved Incidents
type: flow
status: draft
trigger:
type: record_updated
table: incident
steps:
- if: "$trigger.current.state = 6"
then:
- action: update_record
name: Close the Incident
inputs:
table: incident
values:
state: "7"
close_code: Solved (Permanently)
close_notes: Auto-closed after resolution.Creating from the Web UI
- Go to the Editor page
- Write your YAML (or load a sample from the toolbar)
- Fix any validation errors shown in the editor
- Click Create to push the flow to ServiceNow
Flow Structure
Every flow YAML file has these sections:
yaml
schema: nebula # Schema version
name: "My Flow" # Required
type: flow # flow or subflow (default: flow)
status: draft # draft or published (default: draft)
run_as: system # system or user (default: system)
access: public # public or package_private (default: public)
trigger: # Required for flows, not allowed for subflows
type: record_created
table: incident
inputs: [] # Subflow input parameters
outputs: [] # Subflow output parameters
variables: [] # Scratch variables
steps: # Required — the flow logic
- action: lookup_record
inputs:
table: incidentSee the YAML Spec for complete field documentation.
Action Steps
Action steps call built-in ServiceNow actions:
yaml
- action: lookup_record
name: Find the Caller
inputs:
table: sys_user
conditions: "sys_id=$trigger.current.caller_id"Common actions: lookup_record, create_record, update_record, delete_record, send_email, send_notification, log, run_script.
Subflow Steps
Call another subflow by its sys_id:
yaml
- subflow: abc123def456abc123def456abc123de
name: Notify Team
inputs:
incident_number: $trigger.current.numberLogic Steps
Control flow with conditions, loops, and error handling:
yaml
- if: "$trigger.current.priority = 1"
then:
- action: send_email
inputs:
to: oncall@example.com
subject: "P1 Incident: $trigger.current.number"
body: "A P1 incident has been created."
else:
- action: log
inputs:
message: "Non-P1 incident, skipping notification."See Step Types for all available logic steps.
Publishing
To create a flow and publish it in one step:
yaml
status: publishedThe tool handles the compilation process required to make the flow active.