How to Flag Negative Menu Profitability Items from MarketMan with AI
Build a Spojit workflow that pulls your MarketMan menu profitability report every week, uses an AI agent to rank loss-making and low-margin dishes, and posts a prioritized review list to a Slack channel.
What This Integration Does
Menu margins drift quietly. Ingredient costs creep up, recipes change, and a dish that used to earn money can slip into negative profitability without anyone noticing until the month-end numbers land. This workflow turns your MarketMan get-menu-profitability data into a short, ranked action list every week so your chef or operations lead always knows which menu items to re-cost, re-price, or pull first, without exporting spreadsheets by hand.
The workflow runs on a weekly Schedule trigger. On each run it asks MarketMan for the current menu profitability report, hands that report to an Agent-mode Connector node that ranks every item by margin and flags negative-margin dishes, formats the ranking into a readable summary, and sends one message to Slack. It stores no state between runs: each run produces a fresh snapshot of where margins stand right now, so re-running it (manually or on the next scheduled tick) simply posts an updated list. Nothing is written back to MarketMan, so it is safe to run as often as you like.
Prerequisites
- A MarketMan connection added in Spojit under Connections - Add connection - MarketMan, authorized for the buyer account whose menu you want to review. If you manage more than one buyer/account, note the buyer GUID you want to report on.
- A Slack connection added under Connections - Add connection - Slack, with access to the channel where the review list should be posted.
- The target Slack channel name or ID (for example
#menu-review), and the Spojit app invited to that channel. - The built-in math utility connector is available to every workspace with no setup, so there is nothing to connect for it.
- An idea of the margin threshold you consider "low" (for example anything under 60 percent gross margin) so the agent has a clear rule to apply.
Step 1: Add a Schedule trigger
Create a new workflow in the Spojit designer and set the Trigger node type to Schedule. A Schedule trigger uses a 5-field Unix cron expression plus an IANA timezone, and a single trigger can hold more than one schedule. For a Monday 8am weekly review in Sydney, use:
Cron: 0 8 * * 1
Timezone: Australia/Sydney
The trigger output is simply { scheduledAt }, which is the timestamp of the run. You will reference it later if you want to stamp the Slack message with the report date.
Step 2: Pull the menu profitability report from MarketMan
Add a Connector node in Direct mode, choose the MarketMan connector, and select the get-menu-profitability tool. This call returns the current menu profitability report data for your buyer account.
The only input is an optional buyerGuid. Leave it blank to use the default buyer on your connection, or paste a specific GUID if you report on a particular location:
buyerGuid: 7f3c2a10-... (optional - omit to use the connection default)
Set the output variable so later steps can reference it, for example menuReport. The report comes back as a list of menu items with their cost and revenue figures, which is exactly what the agent needs to rank margins.
Step 3: Rank and flag items with an AI agent
Add a second Connector node and switch it to Agent mode. Agent mode lets the agent reason over the data and produce a structured result, which is ideal for ranking and judgment work rather than a single fixed lookup. Point the prompt at the report variable from Step 2 and give it a clear rule for what counts as a problem item:
You are reviewing weekly restaurant menu profitability.
Here is the MarketMan menu profitability report:
{{ menuReport }}
For every menu item, compute the gross margin from its cost and revenue.
Rank all items from worst margin to best.
Flag two groups:
1. Loss-making items (negative margin).
2. Low-margin items (margin under 60 percent).
For each flagged item return its name, margin percent, and the main reason
it is underperforming if the data makes it clear.
Turn on a Response Schema so the agent returns predictable JSON you can build a message from. A schema like the following keeps the downstream Slack step simple:
{
"type": "object",
"properties": {
"lossMaking": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"margin": { "type": "number" },
"reason": { "type": "string" }
}
}
},
"lowMargin": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"margin": { "type": "number" }
}
}
},
"summary": { "type": "string" }
}
}
Set the output variable to review. You will reference fields such as {{ review.lossMaking }} and {{ review.summary }} in the next steps.
Step 4: Compute review totals with the math connector
Add a Connector node in Direct mode, choose the built-in math connector, and use the average tool to summarize the flagged margins into a single headline figure, for example the average margin of the loss-making and low-margin items. This gives the Slack message a concrete number so readers can see how serious the week looks at a glance.
Feed the margins from the agent result into the tool. If you want one combined average across both flagged groups, pass the margin values from {{ review.lossMaking }} and {{ review.lowMargin }}:
values: [ {{ review.lossMaking[*].margin }}, {{ review.lowMargin[*].margin }} ]
Set the output variable to flaggedAverage. If you prefer a different headline number, the math connector also offers min (the single worst margin), median, and round to clean up decimals before display.
Step 5: Build the message and post it to Slack
Add a Connector node in Direct mode, choose the Slack connector, and select the send-message tool. Set the channel to your review channel and compose the body from the agent summary and the flagged lists. A clear, scannable message reads well in Slack:
channel: #menu-review
text: |
Weekly menu profitability review - {{ scheduledAt }}
{{ review.summary }}
Average margin of flagged items: {{ flaggedAverage }}%
Loss-making (fix first):
{{ review.lossMaking }}
Low margin (watch):
{{ review.lowMargin }}
If you would rather have a clean bulleted list than the raw arrays, add a Transform node before this step to turn {{ review.lossMaking }} into one line per item (name plus margin), then reference the transformed text in the send-message body. Either way, one Slack message per run keeps the channel tidy.
Step 6: Save, schedule, and review
Save the workflow. The Schedule trigger you configured in Step 1 will fire on its cron expression and run the full chain automatically. You can ask Miraxa, the intelligent layer across your automation, to wire any of these nodes for you: for example, "Add a Slack send-message node that posts {{ review.summary }} to #menu-review and connect it after the math node." Miraxa knows the workflow you are editing and will ask first if an instruction is ambiguous.
Tips
- Keep the agent prompt's margin threshold explicit (for example "under 60 percent"). A named rule produces far more consistent flagging week to week than a vague "low margin" instruction.
- Run the review early in the week (a Monday cron) so the kitchen has time to act on re-costing or pricing before the busy period.
- Use the math connector's
roundtool on margin values before they reach the Slack message so percentages display cleanly without long decimals. - If you manage several locations, duplicate the workflow per buyer GUID, or add a Loop node over your list of buyer GUIDs and call
get-menu-profitabilityonce per account.
Common Pitfalls
- Leaving
buyerGuidblank when your connection covers multiple accounts means MarketMan returns the default buyer's menu, which may not be the one you intended. Pin the GUID when in doubt. - Forgetting to invite the Spojit app to the target Slack channel causes
send-messageto fail with a not-in-channel error. Invite it once before the first scheduled run. - Skipping the Response Schema in Agent mode lets the agent return free-form prose, which is hard to slice into
{{ review.lossMaking }}fields downstream. The schema is what makes Steps 4 and 5 reliable. - Cron and timezone mismatches catch people out:
0 8 * * 1is 8am in the IANA timezone you select, not in UTC. Double-check the timezone matches your venue.
Testing
Before turning the schedule loose, validate the chain on a small scope. Add a temporary Manual trigger (or switch the trigger type) and click Run so you can fire it on demand. Confirm the MarketMan get-menu-profitability step returns items in menuReport, that the Agent mode node fills review.lossMaking and review.lowMargin matching what you expect from a known week, and that the Slack message lands in the channel formatted the way you want. Once the message looks right, switch the trigger back to Schedule and let it run weekly.
Learn More
- MarketMan connector reference
- Slack connector reference
- Math utility connector reference
- Connector node: Direct mode and Agent mode
- Schedule and other trigger types
- How to Track Restaurant Waste with MarketMan and Slack Alerts
- How to Auto-Order Supplies When MarketMan Inventory Is Low
- How to Set Up Slack Alerts for Workflow Failures