Workflows and events
Miridia raises an event each time an important change occurs. For example, a customer is created, a product price changes, or a shipment is delivered. Each event has a trigger. You attach workflows to a trigger. When the event occurs, Miridia sends the event data to each workflow that is attached to that trigger.
A workflow runs in an external workflow engine, or at a webhook address that you own. Thus you can add behaviour to Miridia without a change to Miridia itself. For example, you can send a message when an order is cancelled, or push a price change to your store.
Workflow engines
| Engine | Status |
|---|---|
| n8n | Native support |
| Elsa Workflows | Native support |
| Power Automate | Available |
| Zapier | Available |
| Custom webhooks | Available |
| RabbitMQ | Available |
Connect an engine in the same way as other integrations. Read Connect an integration.
The default engine
A business can connect more than one workflow engine. Miridia makes each new workflow in the default engine. The first engine that you activate becomes the default. Each engine that you add after it is not the default, until you make it the default.
For example, you connect n8n first and Zapier second. n8n stays the default, and Miridia makes each new workflow in n8n.
How a workflow runs
- A change occurs, for example a user saves a new product price.
- Miridia raises one or more events. A price change raises
OnProductUpdatedandOnProductPriceChange. - For each event, Miridia finds each active workflow that is attached to the trigger.
- Miridia runs the workflows in their position order. Each workflow gets a POST request with the event data.
You can change the position order of the workflows for an entity type. Use this when one workflow must run before another.
Automatic workflows and manual actions
A workflow can run automatically, or a user can start it:
- Automatic: the workflow runs each time its trigger occurs. This is the default.
- Single action: the workflow shows as an action on the details page of one record, for example "Sync this order" on the order page. It runs for that one record.
- Multi action: the workflow shows as a bulk action on the list page, for example "Sync orders" on the orders list. It runs for the selected records.
A workflow usually uses only one of these surfaces.
Workflows for one record
Usually a workflow runs for each record of its entity type. You can also bind a workflow to one record. For example:
- A high-value order that needs a special notification route.
- One product that needs its own restock workflow.
Switch a workflow off
A new workflow is active immediately, and it shows in the workflow list. To stop a workflow without a delete, switch it off. The workflow stays in the engine, but Miridia does not send events to it.
| Action | Request |
|---|---|
| List the triggers of an entity type | GET /api/Triggers/{entityType} |
| Create a workflow | POST /api/workflows/configure |
| List the workflows of an entity type | GET /api/workflows/{entityType}/configured |
| Switch a workflow on or off | PATCH /api/workflows/configured/{workflowId} |
| Update a workflow | PUT /api/workflows/configured/{workflowId} |
| Delete a workflow | DELETE /api/workflows/configured/{workflowId} |
| Set the position order | POST /api/workflows/{entityType}/configure-positions |
| List the manual actions of an entity type | GET /api/workflows/{entityType}/actions |
| Run a manual action | POST /api/workflows/{entityType}/actions/{actionId} |
To create a workflow, send the trigger, a title, a description, and the action flags:
{
"triggerId": 15,
"title": "Tell the team about cancelled orders",
"description": "Sends a message when an order status changes to Cancelled.",
"entityType": "Order",
"isSingleAction": false,
"isMultiAction": false
}
To switch the workflow off, send this body:
{
"isEnabled": false
}
Read the Workflow reference for all the fields.
The trigger catalogue
The tables give each trigger that you can attach a workflow to. The event name is the name that the event data and the API use.
Customers
| Id | Title | Event name |
|---|---|---|
| 2 | Customer Created | OnCustomerCreated |
| 3 | Customer Updated | OnCustomerUpdated |
| 45 | Customer Contact Created | OnCustomerContactCreated |
| 46 | Customer Contact Updated | OnCustomerContactUpdated |
| 74 | Customer Deleted | OnCustomerDeleted |
Products and inventory
| Id | Title | Event name |
|---|---|---|
| 7 | Product Created | OnProductCreated |
| 8 | Product Updated | OnProductUpdated |
| 9 | Product Price Changed | OnProductPriceChange |
| 10 | Product Stock Count Changed | OnProductStockCountChange |
| 27 | Product Deleted | OnProductDeleted |
| 67 | Inventory Low Stock | OnInventoryLowStock |
Orders
| Id | Title | Event name |
|---|---|---|
| 13 | Order Created | OnOrderCreated |
| 14 | Order Updated | OnOrderUpdated |
| 15 | Order Status Changed | OnOrderStatusChanged |
| 39 | Order Item Created | OnOrderItemCreated |
| 40 | Order Item Updated | OnOrderItemUpdated |
| 41 | Order Item Deleted | OnOrderItemDeleted |
| 98 | Order Deleted | OnOrderDeleted |
Shipments and delivery plans
| Id | Title | Event name |
|---|---|---|
| 20 | Shipment Created | OnShipmentCreated |
| 21 | Shipment Updated | OnShipmentUpdated |
| 22 | Shipment Cancelled | OnShipmentCancelled |
| 23 | Shipment Delivered | OnShipmentDelivered |
| 24 | Shipment Status Changed | OnShipmentStatusChanged |
| 25 | Shipment Quotation Generated | OnShipmentQuotationGenerated |
| 26 | Shipment Quotation Accepted | OnShipmentQuotationAccepted |
| 34 | Shipment Delivery Requested | OnShipmentDeliveryRequested |
| 97 | Shipment Deleted | OnShipmentDeleted |
| 47 | Dispatch Created | OnDispatchCreated |
| 48 | Dispatch Updated | OnDispatchUpdated |
| 95 | Dispatch Deleted | OnDispatchDeleted |
A "dispatch" is a delivery plan: a group of shipments that leave together.
Purchase orders
| Id | Title | Event name |
|---|---|---|
| 68 | Purchase Order Created | OnPurchaseOrderCreated |
| 69 | Purchase Order Received | OnPurchaseOrderReceived |
| 90 | Purchase Order Status Changed | OnPurchaseOrderStatusChanged |
| 91 | Purchase Order Updated | OnPurchaseOrderUpdated |
Transfer orders
| Id | Title | Event name |
|---|---|---|
| 65 | Transfer Order Created | OnTransferOrderCreated |
| 66 | Transfer Order Received | OnTransferOrderReceived |
| 92 | Transfer Order Status Changed | OnTransferOrderStatusChanged |
| 93 | Transfer Order Dispatched | OnTransferOrderDispatched |
Work orders
| Id | Title | Event name |
|---|---|---|
| 61 | Work Order Created | OnWorkOrderCreated |
| 62 | Work Order Started | OnWorkOrderStarted |
| 63 | Work Order Completed | OnWorkOrderCompleted |
| 64 | Work Order Cancelled | OnWorkOrderCancelled |
| 94 | Work Order Updated | OnWorkOrderUpdated |
Bills of material
| Id | Title | Event name |
|---|---|---|
| 70 | Bom Created | OnBomCreated |
| 71 | Bom Updated | OnBomUpdated |
| 72 | Bom Deleted | OnBomDeleted |
Suppliers
| Id | Title | Event name |
|---|---|---|
| 53 | Supplier Created | OnSupplierCreated |
| 54 | Supplier Updated | OnSupplierUpdated |
| 55 | Supplier Deleted | OnSupplierDeleted |
Businesses, users, vehicles, and integrations
| Entity | Id | Title | Event name |
|---|---|---|---|
| Vehicle | 73 | Vehicle Created | OnVehicleCreated |
| Business | 57 | Business Created | OnBusinessCreated |
| User | 50 | User Registered | OnUserRegistered |
| Integration | 31 | Integration Provider Configured | OnIntegrationProviderConfigured |
| Integration | 32 | Integration Provider Activated | OnIntegrationProviderActivated |
| Integration | 96 | Integration Provider Deactivated | OnIntegrationProviderDeactivated |
GET /api/Triggers/{entityType}, for example GET /api/Triggers/Order.