Skip to main content

Collect Messages

The Collect Messages Action aggregates messages from branched processing flows in your Flux app. When actions are branched using the Output > Advanced S...

Copy/Save

Collect Messages Action

The Collect Messages Action aggregates messages from branched processing flows in your Flux app. When actions are branched using the Output > Advanced Settings > Send event for each option, this action collects the results back into a single message.

For example, you can execute the RTSP Camera Image Action and AI actions targeting multiple cameras, then use the Collect Messages Action to aggregate the results before sending a single consolidated notification.

Configuration

Collect Target Channel

Aggregates messages sent to the specified message aggregation target channel.

Destination Channel

Specify the destination channel for aggregated messages. Once all messages from the branched processing have been received, they are aggregated and sent to the destination channel.

Advanced Settings: Anchor

When a Flux app has multiple branches, you specify the channel or action that determines the starting point for aggregation. The resource serving as this starting point is called an anchor. This action executes once all processing after the anchor has completed.

In a Flux app, you can configure one or more actions on a channel or send the execution result (output data) of an action to another channel. As a result, the paths included in the aggregation depend on which channel/action is set as the anchor.

Anchor Behavior

You can select either an action or a channel as the anchor. The aggregation behavior differs depending on which type of resource is selected.

When an action is set as the anchor:

  • Only channels or actions that follow the anchor action become aggregation targets if the action executes.
  • Even if the anchor action or subsequent processing fails and messages do not reach the aggregation target channel, the aggregation process itself may still run and may return an empty array.

When a channel is set as the anchor:

  • Only channels or actions that follow the anchor channel become aggregation targets if a message reaches that channel.
  • If a message does not reach the anchor channel due to a condition mismatch or an error, the aggregation process does not start.

Usage Guidelines:

  • To aggregate only cases where a specific action was executed, set that action—or the channel or action following it—as the anchor.
  • To aggregate in all cases, including when an action is skipped due to a condition mismatch, set the channel or action preceding that action as the anchor.

Output

Configure how to handle the output data of the action. Refer to Enable Republishing of Action Output for more details.

Output Data of the Action

The Collect Messages Action outputs an array containing all collected messages in the messages field.

The following example shows the output when multiple Soracom Cloud Camera image acquisition actions are executed and collected:

{
  "messages": [
    {
      "deviceId": "7CDDE90XXXXX",
      "imageUrl": "https://flux-core-temporary-object-storage-jp-prod.s3.ap-northeast-1.amazonaws.com/01KCTRENXXXXXXX",
      "exportId": "5d06a3a4-XXXX",
      "harvestFilesPath": "/flux/XXXX.jpg",
      "datetime": "2025-12-19T07:28:35.035Z"
    },
    {
      "deviceId": "7CDDE90YYYYY",
      "imageUrl": "https://flux-core-temporary-object-storage-jp-prod.s3.ap-northeast-1.amazonaws.com/01KCTRENYYYYYYY",
      "exportId": "5d06a3a4-YYYY",
      "harvestFilesPath": "/flux/YYYY.jpg",
      "datetime": "2025-12-19T07:28:36.017Z"
    }
  ]
}

The following example shows the output when multiple AI actions are executed and collected:

{
  "messages": [
    {
      "output": {
        "text": "<AI response>"
      },
      "usage": {
        "completion_tokens": 246,
        "prompt_tokens": 3949,
        "total_tokens": 4195,
        "prompt_tokens_details": {
          "cached_tokens": 0,
          "audio_tokens": 0
        },
        "completion_tokens_details": {
          "reasoning_tokens": 0,
          "audio_tokens": 0,
          "accepted_prediction_tokens": 0,
          "rejected_prediction_tokens": 0
        },
        "model": "gpt-4.1-nano",
        "byol": false,
        "service": "openai",
        "credit": 2
      }
    },
    {
      "output": {
        "text": "<AI response>"
      },
      "usage": {
        "completion_tokens": 244,
        "prompt_tokens": 3949,
        "total_tokens": 4193,
        "prompt_tokens_details": {
          "cached_tokens": 0,
          "audio_tokens": 0
        },
        "completion_tokens_details": {
          "reasoning_tokens": 0,
          "audio_tokens": 0,
          "accepted_prediction_tokens": 0,
          "rejected_prediction_tokens": 0
        },
        "model": "gpt-4.1-mini",
        "byol": false,
        "service": "openai",
        "credit": 6
      }
    }
  ]
}

The attributes are as follows:

AttributeDescription
messagesAn array containing all collected messages. Each element in the array is a message that was sent to the target channel after the anchor point. The structure of each message depends on the actions that generated them.

The messages array will be empty ([]) if the anchor is set to an action and that action fails, or if no messages are sent to the target channel.

Search Esc to close / Enter to view results