1Write the workflow
A workflow is a YAML file: the request it accepts, the steps it runs and what it returns. This one asks the model to read a ticket and return a fixed shape, so whatever starts it can rely on the answer.
Workflow: TriageTicket
Description: Reads a support ticket and says what it is about and how urgent it is.
Triggers:
- New: Ticket
Schema:
type: object
required: [Prompt]
properties:
Prompt: { type: string }
Output:
Structured:
type: object
required: [Topic, Urgency]
properties:
Topic: { type: string, enum: [Billing, Refund, Bug, Account, Other] }
Urgency: { type: string, enum: [Low, Normal, High] }
Steps:
- ModelCall: Triage
Instructions: Read the ticket. Say what it is about and how urgent it is.
Output:
Structured:
type: object
required: [Topic, Urgency]
properties:
Topic: { type: string, enum: [Billing, Refund, Bug, Account, Other] }
Urgency: { type: string, enum: [Low, Normal, High] }- Step kind
- ModelCall
- Name
- Triage
- Model
- Auto
- Output
- Structured
2Upload it
Send the YAML as the request body with an API key of your Workflow organization, created in Settings › API keys and shown once. Momor compiles it before storing anything: a workflow that fails is refused with 422 and one line per problem, giving the line, column and field. A workflow that passes comes back with its id and the content hash of this version; keep the id to start runs on it.
curl -X POST "https://api.momor.ai/workflow/workflows" \
-H "Authorization: Bearer $MOMOR_API_KEY" \
-H "Content-Type: application/yaml" \
--data-binary @triage.yaml{
"id": "4f6d2c1e-8a3b-4f0e-9d2a-7c5b1e0f3a21",
"name": "TriageTicket",
"contentHash": "9b1c…"
}You can also save it in Workflows: choose Start from nothing, switch the editor to YAML, paste the file and choose Save version. No Workflow organization yet? Create one.
3Start a run
Start a run on the workflow with the same key and send the ticket in the same request. The body is checked against the Ticket schema; when it passes, the run opens its first turn and Momor answers 202 with that turn while the steps run.
curl -X POST "https://api.momor.ai/workflow/workflows/$WORKFLOW_ID/runs" \
-H "Authorization: Bearer $MOMOR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "Prompt": "I was charged twice for my October invoice." }'4Follow the run
Ask for the same request as an event stream and the response follows the turn to its end instead: an opened frame, every event the turn records, then closed. The answer is in the result.committed event.
curl -N -X POST "https://api.momor.ai/workflow/workflows/$WORKFLOW_ID/runs" \
-H "Authorization: Bearer $MOMOR_API_KEY" \
-H "Accept: text/event-stream" \
-H "Content-Type: application/json" \
-d '{ "Prompt": "I was charged twice for my October invoice." }'event: opened
data: {"runId":"…","turnId":"…","queueItemId":null}
event: turn.started
id: …
data: {"event":"turn.started","path":"…","turnId":"…","payload":{…}}
event: model.replied
id: …
data: {"event":"model.replied","path":"triage","turnId":"…","payload":{…}}
event: result.committed
id: …
data: {"event":"result.committed","path":"…","turnId":"…","payload":{…}}
event: closed
data: {"state":"Completed"}GET /workflow/runs/{runId} returns the run and its turns, and the same address as an event stream replays every event from the start. See Run history.