Skip to main content
Core ships four review workflows in packages/core/src/workflows/review/. Import them from @mercurjs/core/workflows and run them with the Medusa container. None of them exposes a workflow hook, and none emits an event of its own: the events come from the module service, as listed in the Events reference.

createReviewWorkflow

Validates a submission, creates a pending review, and writes its customer, order, and target links. Workflow id create-review. Input type CreateReviewDTO, returns the created review. The workflow runs three steps:
  1. validate-review: fails with INVALID_DATA “Order not found!” when no order matches order_id and customer_id, and with “Review already exists” when the order has a review with the same reference and target id
  2. create-review: creates the review and links it to the customer and the order; on rollback, deletes the review
  3. create-remote-links: Medusa’s createRemoteLinkStep, which links the review to the product or the seller

updateReviewWorkflow

Updates any of a review’s editable fields, including status. Workflow id update-review. Input type UpdateReviewDTO, returns the updated review. Its single step, update-review, reads the review before writing. On rollback it restores the previous rating, customer_note, seller_note, and status.

respondReviewWorkflow

Writes a store’s answer to seller_note, once. Workflow id respond-review. Input type RespondReviewDTO, returns the updated review. Its single step, respond-review, fails with NOT_FOUND “Review not found” for an unknown id and with NOT_ALLOWED “This review already has a response” when seller_note is set. On rollback it sets seller_note back to null. The workflow doesn’t check which store owns the review: the Vendor API checks the seller link before running it.

deleteReviewWorkflow

Soft deletes a review. Workflow id delete-review. The input is the review id as a plain string, and the workflow returns that id.
Its single step, delete-review, calls softDeleteReviews and leaves the review’s links in place. On rollback it calls restoreReviews.

Steps

@mercurjs/core/workflows also exports each step, so you can compose them into your own workflows: