Skip to content

Update Webhook Triggers: Add Async and Sync #736

@theroinaochieng

Description

@theroinaochieng

The code publishes a standardized webhook response message after a workflow run completes, but only for webhook-triggered work orders configured to reply after completion, and it currently treats all outcomes as HTTP 201 Created.

Purpose:
It conditionally sends (broadcasts) a webhook response after a workflow run finishes, using Phoenix PubSub.

When it runs:
maybe_broadcast_webhook_response/2 checks whether:
• The work order has a trigger
• The trigger is of type :webhook
• The webhook is configured to reply :after_completion
If any of these are not true, the function does nothing.

What it sends:
When the conditions are met, it:
1. Builds a PubSub topic scoped to the work order ("work_order::webhook_response")
2. Determines an HTTP-style status code based on the run state (currently always 201, regardless of outcome)
3. Constructs a response body containing:

•	data: the final workflow state from the payload

•	meta: run and work-order metadata (IDs, state, error type, timestamps)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions