Dispatch the Emergency Squad

Dinosaur Park Emergency Response - Challenge 5 of 5
Difficulty
2/10
Tags
EssentialsifEdit Fields (Set)convert-to-fileExecute Workflow Triggerconditional-logicJSON

You're the control room operator at Isla Dino. Your AI Operator can now detect emergencies and log them. But logging isn't enough - when dinosaurs escape, you need to dispatch the emergency response squad immediately!

In this final challenge, you'll add conditional logic to the sub-workflow: if there's a real emergency, format and send a dispatch order. If not, just log it and move on.

What you'll practice:

  • Using the If node for conditional branching
  • Comparing boolean values
  • Formatting emergency dispatch messages with Edit Fields
  • Converting data to file format for records

Your Task

  1. 1Copy the exercise below
  2. 2Paste into your n8n editor (Ctrl+V)
  3. 3Solve it — use hints if you get stuck
  4. 4Check the solution when done

Add emergency dispatch logic to the sub-workflow you created in Challenge 4.

  1. Open the sub-workflow you created in Challenge 4 (the separate workflow with the "When Executed by Another Workflow" trigger)
  2. Add an If node after the trigger to check if there's an emergency
  3. On the TRUE branch (emergency detected):
    • Add an Edit Fields node to format a dispatch message
    • The message should include the location, time, and dinosaur count
  4. Add a Convert to File node connected directly to the trigger (for logging all events). Set the operation to "Convert to CSV" to simulate appending a row to a spreadsheet

Important: Make sure the sub-workflow is both saved AND published after making changes - the tool node can only find workflows that are saved and published!

Hint: Use expressions to reference the input parameters from the trigger node.

Expected output:

  • If emergency: A formatted dispatch message ready to send
  • If no emergency: Just a log entry (no dispatch)

Hints

  1. Open your sub-workflow from Challenge 4 (the separate workflow with the "When Executed by Another Workflow" trigger)
  2. Add an If node after the trigger
  3. Set the condition: {{ $json.emergency_status }} equals true (boolean type, not string!)
  4. On the TRUE output, add an Edit Fields node with:
    • subject: "DINOSAUR BREAKOUT"
    • body: Use an expression to include the dinosaur count, location, and time from the trigger node
  5. Add a Convert to File node connected directly to the trigger (parallel to the If node)
  6. Save AND Publish the sub-workflow after making changes

Tip: To reference data from the trigger, use: {{ $('When Executed by Another Workflow').item.json.field_name }}

Sparkle Icons: In the main workflow's Tool node, look for the ✨ sparkle icons next to each parameter field. Clicking these lets the AI automatically decide which data to pass to the sub-workflow based on context. This is the easiest way to connect the right data once your sub-workflow is linked!

Explanation

Conditional Branching:

The If node splits your workflow into two paths:

  • TRUE: Execute when the condition is met (emergency detected)
  • FALSE: Execute when the condition is not met (all clear)

This is essential for workflows that need to respond differently to different situations.

Boolean Comparisons:

When checking emergency_status, you're comparing a boolean value:

{{ $json.emergency_status }} equals true

Make sure to select "Boolean" as the type, not "String".

The Complete Flow:

Trigger → If (emergency?)
            ├─ TRUE → Edit Fields (dispatch message)
            └─ FALSE → (nothing extra)
         → Convert to File (always log)

Congratulations!

You've built a complete emergency response system:

  1. Fetch park status from the API
  2. Analyze the map with AI vision
  3. Brief the AI Operator with context
  4. Give it a tool to log emergencies
  5. Dispatch the squad when needed

The dinosaurs don't stand a chance!

Solution Setup Instructions:

This solution has two separate workflows that must be set up in order:

Step 1: Create the Sub-Workflow first

  1. Click "Copy Sub-Workflow" below
  2. Create a new workflow in n8n and paste it
  3. Save AND Publish the workflow (both required!)

Step 2: Update your Main Workflow

  1. Go back to your exercise workflow
  2. In the Tool node, select your newly published sub-workflow
  3. Save and test the complete system

Why separate? n8n Tool nodes store a workflow ID reference. When you copy a workflow with a Tool node, that ID doesn't exist in your n8n instance yet.

Copy the Solution

This solution has multiple workflows. Copy them in order and paste into n8n.

Login to see the exercise

Create an account to access challenges and track your progress.

Log in to see exercise

Related Content

Continue your learning journey with these related challenges and guides: