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 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.

Available on the Standard and Enterprise plans. For more information about plans, refer to Soracom Flux Plans.

Configuration

Config

Configure the Collect Messages action settings:

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. Therefore, the paths included in the aggregation depend on which channel/action is set 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.

Example: Collecting Soracom Cloud Camera Images

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"
    }
  ]
}

Example: Collecting AI Action Results

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:

Attribute Description
messages An 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.