This workflow is the code that orchestrates the tasks through the Zenaton workflow engine and are then executed on your servers.
const { workflow, duration } = require("zenaton");
module.exports = workflow("ShippingWorkflow", {
*handle(shipment) {
this.shipment = shipment;
yield this.run.task("Fulfill", this.shipment)
const fulfilled = yield this.wait.event("Fulfilled").for(duration.weeks(1));
if (fulfilled) {
yield this.run.task("ProceedToTracking", this.shipment)
} else {
yield this.run.task("AlertNotFulfilled", this.shipment)
}
},
*onEvent(eventName) {
if (eventName === "ChargeBack") {
yield this.run.task("CancelOrderFromShipment", this.shipment)
}
if (eventName === "OutOfStock") {
yield this.run.task("ProcessOutOfStockQuantity", this.shipment)
}
},
});
Real-world Examples
Start building workflows
Sign-up and run a sample project Learn more