← Workflow Academy

Workflow Academy · 5 / 5

Give both paths a receipt

Finish a bounded routing definition and understand the release decision.

YOUR TASK

Make this happen

3 steps
  1. Add a separate review_receipt node, its Lua file and review → review_receipt edge. Read envelope.review. Bound both receipt nodes to five seconds, zero retries and continueOnError false.

  2. Keep the working capabilities from the previous lesson and connect the new pieces to the same solution.

  3. Check the complete solution, then inspect any unmet requirements.

This step starts with the earlier solution and one new challenge. Each lesson keeps its own draft.

Read the starter files

main.cococo

workflow_document "main" {
  nodes = [workflow_node.prepare, workflow_node.route, workflow_node.review, workflow_node.ready, workflow_node.receipt]
  edges = [workflow_edge.prepare_route, workflow_edge.review, workflow_edge.ready, workflow_edge.receipt]
  inputSchema = {
    type = "object"
    properties = {
      jobId = {
        type = "string"
      }
      copies = {
        type = "integer"
        minimum = 1
      }
    }
    required = ["jobId", "copies"]
  }
}

prepare.cococo

workflow_node "prepare" {
  id = "prepare"
  type = "transform"
  config = {
    mapping = {
      copies = "{{ input.copies }}"
      jobId = "{{ input.jobId }}"
    }
  }
}

route.cococo

workflow_node "route" {
  id = "route"
  type = "condition"
  config = {
    expression = "nodes.prepare.output.copies > 100"
  }
}

review.cococo

workflow_node "review" {
  id = "review"
  type = "transform"
  config = {
    mapping = {
      status = "review"
      jobId = "{{ nodes.prepare.output.jobId }}"
    }
  }
}

ready.cococo

workflow_node "ready" {
  id = "ready"
  type = "transform"
  config = {
    mapping = {
      status = "ready"
      jobId = "{{ nodes.prepare.output.jobId }}"
    }
  }
}

links.cococo

workflow_edge "prepare_route" {
  from = "prepare"
  to = "route"
}
workflow_edge "review" {
  from = "route"
  to = "review"
  when = "true"
}
workflow_edge "ready" {
  from = "route"
  to = "ready"
  when = "false"
}
workflow_edge "receipt" {
  from = "ready"
  to = "receipt"
}

receipt.cococo

workflow_node "receipt" {
  id = "receipt"
  type = "script"
  config = {
    inline = file("scripts/receipt.lua")
  }
}

scripts/receipt.lua

local envelope = ...
return { jobId = envelope.ready.jobId, status = envelope.ready.status }

review-receipt.cococo

workflow_node "review_receipt" {
  id = "review_receipt"
  type = "script"
  config = {
    # TODO: add the mapping/expression or script input described above.
  }
  # TODO: add timeoutSeconds — see the task above.
  # TODO: add maxRetries — see the task above.
  # TODO: add continueOnError — see the task above.
}

scripts/review-receipt.lua

local envelope = ...
-- TODO: build a receipt from the predecessor output described in the task.
return {}
Supplied supporting files

Reference: workflows · introductionworkflows · getting-startedworkflows · valuesworkflows · branchesworkflows · scriptsworkflows · node-formsworkflows · publicationworkflows · diagnosticsworkflows · referenceworkflows · node-reference