elsa-workflows / elsa-core

A .NET workflows library
https://v3.elsaworkflows.io/
MIT License
5.98k stars 1.09k forks source link

[ENH] Enable External Interaction with Publish Event and Event Activities #5583

Open sfmskywalker opened 5 days ago

sfmskywalker commented 5 days ago

Currently, the PublishEvent and Event activities only operate internally within the workflow engine. Enabling external applications to leverage these primitives would significantly enhance the system's flexibility and integration capabilities.

Proposed Enhancements

  1. PublishEvent Activity Enhancement

    • Current Behavior: The PublishEvent activity handles events internally.
    • Proposed Change: Allow the PublishEvent activity to publish events that external applications can subscribe to. For example, an EventPublished event can be picked up by the Webhooks module, enabling external applications to handle these events and perform corresponding actions.
  2. Event Activity Enhancement

    • Current Behavior: The Event activity is triggered by internal mechanisms.
    • Proposed Change: Enable external applications to trigger Event activities by sending HTTP requests or AMQP messages to the workflow engine. This will allow external systems to initiate events within the workflow, facilitating better integration and interaction.

Implementation Guidance

Benefits

Implementing these enhancements will significantly improve the capabilities of the workflow engine, making it more robust and versatile in handling complex integrations with external systems.

glime-ai[bot] commented 5 days ago

To implement the proposed enhancements for the PublishEvent and Event activities to allow for external application integration, you would need to extend the current functionality of Elsa Workflows. Here's how you could approach this based on the existing documentation and features:

  1. PublishEvent Activity Enhancement:

    • You could extend the PublishEvent activity to publish events to external systems by integrating with the Elsa.Webhooks package. This package can listen for domain events and fire HTTP requests to registered webhooks. By publishing an event that the Elsa.Webhooks package can recognize, you can notify external applications of internal workflow events.
  2. Event Activity Enhancement:

    • To allow external applications to trigger Event activities, you could expose an HTTP or AMQP API endpoint that external systems can call. When the endpoint receives a request, it would publish an internal event that the Event activity subscribes to, thus triggering the workflow.

Reference RunTask Activity:

Implementation Guidance:

Benefits:

Documentation and Resources:

Please note that these enhancements would require changes to the Elsa Workflows codebase and might involve creating custom activities or extending existing ones. If you are not familiar with the internal workings of Elsa Workflows, you may need to consult with the Elsa community or contributors for assistance.

This comment was generated by Glime.