How to Require Approval for Large MarketMan Vendor Orders
Build a Spojit workflow that receives a draft MarketMan purchase order over a webhook, totals its value, and pauses for human approval before creating the order whenever the spend exceeds your threshold.
What This Integration Does
Restaurant and retail teams often let buyers raise purchase orders directly from a back-of-house system or a spreadsheet macro. Most orders are routine, but the occasional large vendor order (a bulk protein buy, a full liquor restock) deserves a second set of eyes before it is sent. This workflow puts a spend gate in front of MarketMan: a draft order arrives, Spojit adds up the line totals, and any order above your limit waits for a manager to approve or reject it in the Spojit Approvals inbox. Orders under the limit flow straight through and are created automatically.
The run starts when an external system sends an HTTP POST to the workflow's Webhook trigger with the draft order (vendor and line items). A Connector node totals the lines using the math connector, a Condition node compares the total to your threshold, and on the over-threshold branch a Human node pauses the workflow. Only after approval does the MarketMan create-order tool run and the order get sent to the vendor. A slack message confirms the outcome. Each webhook call is one independent run: a rejected or timed-out approval halts that run with no order created, and re-sending the same draft starts a fresh run.
Prerequisites
- A MarketMan connection added under Connections, with permission to create orders, plus the buyer and vendor GUIDs you order against. See the MarketMan connector article.
- A Slack connection and the channel ID where approval notices should post. See the Slack connector article.
- A webhook signing connection (scheme Spojit or Custom) so the trigger can verify the incoming POST. See Setting Up a Webhook Connection.
- A user, role, or team to act as the approver, and a spend threshold (for example
500) in the order's currency. - The sending system must include each line item's catalog item code, quantity, and unit price in its POST body.
Step 1: Receive the draft order with a Webhook trigger
Add a Trigger node and set its type to Webhook. Choose your signing connection so Spojit verifies the request with HMAC, then copy the generated URL and point your sending system at it. The trigger output is the parsed JSON body, available as {{ input }}. Design the sender to POST a shape like this:
{
"vendorGuid": "5b2a-...-vendor",
"comment": "Weekly protein restock",
"lines": [
{ "code": "BEEF-CHUCK-10", "quantity": 12, "unitPrice": 38.50 },
{ "code": "CHICKEN-THIGH-5", "quantity": 20, "unitPrice": 14.20 }
]
}
The webhook responds with 202 and an executionId immediately, so the sender is not held open while the approval waits.
Step 2: Compute each line total with the math connector
Add a Loop node in ForEach mode over {{ input.lines }} so you can turn each line into a value. Inside the loop body, add a Connector node in Direct mode on the math connector and pick the calculate tool. Set its expression to multiply quantity by price, for example {{ line.quantity }} * {{ line.unitPrice }}, and store the result. Collect the per-line results into a list (for example lineTotals) so the next step can add them. If your sender can already supply a flat array of numbers, you can skip the loop and feed that array straight into Step 3.
Step 3: Sum the order total
Add another Connector node in Direct mode on the math connector and select the sum tool. Map its values input to the list of line totals from Step 2 (for example {{ lineTotals }}). Store the result as orderTotal. If you want a tidy display value for notifications, add one more math Direct node using the currency tool to format {{ orderTotal }} for the message text. Keep the raw numeric orderTotal for the comparison in the next step, since the formatted string is for humans only.
Step 4: Branch on the spend threshold with a Condition node
Add a Condition node that checks whether {{ orderTotal }} is greater than your limit, for example greater than 500. Connect the False output (orders at or under the limit) directly to the MarketMan create step in Step 6, so small orders are created without delay. Connect the True output (large orders) to the Human approval node in Step 5. This keeps the approval cost and waiting time only where it matters.
Step 5: Pause for human approval on large orders
On the True branch, add a Human node. Set a clear Label (for example Large vendor order approval) and a Message that summarizes the order using variables, such as Approve order to vendor {{ input.vendorGuid }} totalling {{ orderTotal }}?. Fill in the Notification title and Notification body (both accept {{ variables }}), set Urgency to High, and optionally turn on Email approvers. Add an Approval slot and place your manager user, role, or team as an atom in it; the slot is the only required field. Optionally set a Timeout (minutes). Approvers respond in the Approvals inbox at /approvals. On approval the node outputs { approved: true, approvalId, outcome: "APPROVED" } and the run continues; a rejection or timeout halts the run with no order created. Note that "on reject do something else" branching is not supported, so a rejected large order simply stops here.
Step 6: Create the order in MarketMan
Add a Connector node in Direct mode on the MarketMan connector and select the create-order tool. Both the approved branch and the under-threshold branch lead here. Map the inputs:
vendorGuid: {{ input.vendorGuid }}
orderStatus: Sent
comment: {{ input.comment }}
catalogItems: [ { "CatalogItemCode": "BEEF-CHUCK-10", "Quantity": 12 }, ... ]
Build catalogItems from {{ input.lines }}, mapping each line's code to CatalogItemCode and its quantity to Quantity; a Transform node is handy for reshaping the lines into this array. Setting orderStatus to Sent dispatches the purchase order to the vendor. Store the response as createdOrder for the confirmation step.
Step 7: Confirm the outcome in Slack
Add a Connector node in Direct mode on the slack connector and select the send-message tool. Set channel to your channel ID and write a text that reports what happened, for example Order to {{ input.vendorGuid }} for {{ orderTotal }} created and sent. For audit clarity you can post a different message on the approved-large path versus the auto-created path. If you prefer email instead of chat, swap this for a Send Email node, which uses Spojit's built-in mail service and needs no connection.
Tips
- Use the math connector's
calculatetool for the line math so quantity-by-price stays exact; avoid stringing numbers together in templates, which can concatenate instead of add. - Keep a single
orderTotalnumeric value for the Condition comparison and a separatecurrency-formatted string for messages, so a thousands separator never breaks the threshold test. - Set a realistic Timeout (minutes) on the Human node so a forgotten approval does not leave a draft order pending indefinitely; a timeout is treated as a rejection and halts the run.
- Ask Miraxa, the intelligent layer across your automation, to scaffold the canvas: "Add a Condition node that checks if
{{ orderTotal }}is over 500 and connect the true branch to a Human approval node," then fine-tune fields in the properties panel.
Common Pitfalls
- Forgetting to wire the False branch of the Condition node to the
create-orderstep means small orders never get created. Both branches must reach Step 6. - Sending unit prices the workflow never sees: if the POST body omits
unitPrice, the total computes as zero and every order looks small. Validate the incoming shape before going live. - Mismatched catalog item codes cause
create-orderto fail at the vendor. Confirm eachCatalogItemCodematches MarketMan's vendor catalog, which you can list with theget-catalog-itemstool. - Expecting a "rejected" branch: a rejected or timed-out approval halts the run, so put any "notify on rejection" message inside the approval notification rather than downstream of the Human node.
Testing
Before pointing your real ordering system at the webhook, send a small test POST with a single low-value line so orderTotal falls under your threshold, and confirm the Condition node routes it down the auto-create path and a Slack confirmation posts. Then send a test with quantities high enough to exceed the limit and confirm the run pauses at the Human node, the request appears in the Approvals inbox, and approving it creates the order while rejecting it halts the run with no order. Watch the execution history to see exactly which branch each run took and what create-order returned before enabling the workflow for production traffic.