Summary

Implement an event subscriber system that automatically injects entity context data into playground messages as they are saved. This ensures that EntityContext nodes in workflows receive the serialized entity data without requiring manual data passing, creating a seamless integration between entity sessions and workflow execution.

Business Value

  • Eliminates manual data handling between entity context and workflow nodes
  • Ensures consistent entity data availability across all workflow executions
  • Supports complex workflows with multiple EntityContext nodes
  • Maintains clean separation between session management and workflow execution

Features Implemented

  • Automatic Injection: Entity data injected on message save without manual intervention
  • EntityContext Node Detection: Automatically finds EntityContext nodes in workflow definition
  • Entity Serialization: Full entity data serialized via FlowDrop's EntitySerializer
  • Metadata Merging: Entity context merged with existing message inputs
  • New Message Filtering: Only processes new user messages, not system responses

Technical Implementation

  • EntityContextInjectorSubscriber service subscribed to entity lifecycle events
  • Hooks into hook_entity_presave() for FlowDropPlaygroundMessage entities
  • Validates session has entity context metadata before processing
  • Builds initial data structure matching EntityContext node requirements
  • Merges entity data into message metadata[inputs] array
  • Integration with PlaygroundService::buildInitialData() for proper data flow

Data Flow

  1. User sends message in entity-context playground session
  2. Message entity triggers presave hook
  3. EntityContextInjectorSubscriber checks for entity context in session
  4. Entity is loaded and serialized to full data structure
  5. Serialized entity injected into message metadata
  6. Workflow execution receives entity data via initialData
  7. EntityContext nodes access entity fields and values

Comments

joevagyok created an issue. See original summary.

d34dman’s picture

Version: » 1.x-dev
Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.