Skip to main content
The streaming zone state pattern monitors what’s happening in a zone as a whole β€” how many objects are in it, how long they’ve been there β€” rather than tracking individual objects. You get updates whenever zone occupancy changes, making it ideal for crowd-level and aggregate scenarios. This guide uses congestion detection as the running example (vehicles blocking factory aisles), but the same pattern applies to any zone-level use case β€” congregation, occupancy limits, loading dock queues, and more.

What you’ll build

The workflow follows this structure:
  • Trigger receives zone state updates for vehicle zones across the site
  • Zone Activity Check evaluates how many qualifying vehicles are in the zone
  • Event Orchestrator routes based on check results β€” scoped by zone to prevent duplicate events per zone
  • Create path finds the closest frame, captures a still, runs a VLM confirmation, and creates the event
  • Close path closes the event when conditions are no longer met
  • Replay Trigger (disabled) is available for testing

Prerequisites

  • A Worlds site with aisle zones configured
  • GraphQL Subscription API credentials in the Workflow Builder
  • The state machine running and connected to your Workflow Builder instance
  • Azure OpenAI or similar LLM credentials (optional, for VLM confirmation)
  • SendGrid API credentials (optional, for email alerts)

Step 1: Detection Webhook Trigger

Configure the trigger to receive zone state updates for vehicles.

Why zone state?

For congestion, the question isn’t β€œwhat is this specific forklift doing?” β€” it’s β€œare there too many vehicles in this aisle?” Zone state gives you exactly that: updates whenever the occupancy of a zone changes. Each execution tells you how many tracks are in the zone, what types they are, and how long each has been there. You’ll receive three signal types:

Step 2: Zone Activity Check

The check node evaluates whether there are enough qualifying vehicles in the zone to constitute congestion. What happens: For every zone state update, the node counts how many active tracks in the zone meet the dwell time and intersection thresholds. If 4+ vehicles each have at least 5 seconds dwell time and 10% intersection, the check passes. Output: Adds checks.zoneActivity.passed (boolean) and checks.zoneActivity.qualified_track_ids (array of track IDs that met thresholds) to the data. The qualified track IDs are used downstream for image capture and event metadata.

Adapting for similar use cases

Step 3: Event Orchestrator

The orchestrator reads the Zone Activity Check results and manages the event lifecycle. Routing:

Why the close path matters here

Unlike the batch track state workflow which uses batch mode (where each track arrives once, already expired), this streaming workflow sees continuous zone updates. When vehicles leave the zone and the track count drops below the threshold, the checks fail β€” and the orchestrator routes to Close Event so you can close the event in Worlds with the end time.

Step 4: Closest Frame

Before capturing an image, find the optimal timestamp where the qualifying vehicles are closest together in the frame. Node: Worlds Actions β†’ Closest Frame Why this node: With multiple vehicles involved in congestion, you want an image that shows them all clearly. The Closest Frame node analyzes the bounding box positions across recent detections and finds the timestamp where the tracks are closest together β€” giving you the best possible single image of the congestion. Output: Adds closest_frame.optimal_timestamp to the data, which you pass to the image processor.
Closest Frame is particularly useful in zone state workflows where you’re dealing with multiple tracks. In single-track workflows (like obstruction), you can skip this and use a timestamp directly.

Step 5: Create still image

Capture the congestion scene at the optimal timestamp. Node: Worlds Actions β†’ Process Detection Image β†’ Create Still The image will show all qualifying vehicles with bounding boxes and the zone overlay drawn on the frame.

Step 6: VLM confirmation (optional)

Pass the captured image through a Vision Language Model to add context or confirm congestion. This step uses the built-in Basic LLM Chain node with an image input. The model analyzes the still image and returns structured data:
Two ways to use the VLM output:
  1. As context metadata (this workflow) β€” the VLM output is merged back with the detection data and attached as event metadata. The event is always created regardless of VLM output.
  2. As a check gate (advanced pattern) β€” feed the congestion_boolean into an IF node to gate whether the event is created. This adds AI confirmation to reduce false positives.
After the VLM check, a Merge node combines the VLM output with the original image data, and a Code node prepares event metadata (computing centroid position from all qualified tracks, formatting track info strings).

Step 7: Create event in Worlds

Write the congestion event to the Worlds platform. Node: Event Manager β†’ Create Event Metadata:
Unlike the batch obstruction workflow, we don’t set an end time here because the congestion may still be ongoing. The close path handles setting the end time when conditions clear.

Step 8: Close event path

When vehicles leave the zone and the track count drops below the threshold, the orchestrator routes to Close Event. Node: Event Manager β†’ Close Event Metadata: This calculates the congestion duration in seconds from the event start time (stored by the orchestrator) to the current zone update time.

Step 9: Optional β€” GIF and email

After creating the event, you can optionally generate a GIF and send an email alert, following the same pattern as the batch track state workflow.

How it works end-to-end

  1. Cameras monitor factory aisles, detecting vehicles in predefined zones
  2. The state machine tracks zone occupancy and emits zone_updated signals as vehicles enter and leave
  3. Two vehicles enter an aisle zone β†’ zone_updated β†’ Zone Activity Check: 2 tracks, threshold is 4 β†’ fails β†’ No Action
  4. A third vehicle enters β†’ zone_updated β†’ 3 tracks β†’ fails β†’ No Action
  5. A fourth vehicle enters β†’ zone_updated β†’ 4 tracks, all with 5s+ dwell and 10%+ intersection β†’ passes
  6. Orchestrator sees no existing event for this zone β†’ routes to Create Event
  7. Closest Frame finds the optimal timestamp with all 4 vehicles visible
  8. A still image is captured with bounding boxes and zone overlay
  9. The VLM analyzes the image and confirms congestion with a context description
  10. An event is created in Worlds with track data, VLM context, and the image
  11. More vehicles enter β†’ checks still pass β†’ orchestrator routes to Update Event (unwired)
  12. Vehicles leave, count drops to 3 β†’ checks fail β†’ orchestrator routes to Close Event with duration

Other use cases for this pattern

The streaming zone state pattern works for any use case where you care about aggregate zone activity rather than individual tracks: The core structure stays the same β€” Trigger (zone state) β†’ Zone Activity Check β†’ Orchestrator (zone scope) β†’ Actions β€” only the threshold configuration and event metadata change.

Comparing batch vs streaming workflows