What matters here
- Write the rules as a table, not as conditions inside the workflow. A table can be read, changed and checked.
- Give the table an owner. The person who answers for the outcome should be able to change the rule.
- Decide from facts the workflow gathered, not from what the requester typed.
- Use AI to sort free text into a category, then let the rules decide. Don't let a model make the decision itself.
- Send anything that matches no rule to a person. A default route hides the cases the rules missed.
- Record which rule decided each case, so every outcome can be explained.
Who this is for
You own a process in revenue operations, finance or support. The rules for who gets what, and when, live in a spreadsheet, a few workflow conditions and the heads of two senior people.
How it works in practice
What has to happen between the facts being gathered and the case going down the right route.
- 1
The facts are collected in one place
Amount, customer tier, contract terms, region, history: everything the rules need, read from the systems that hold it.
- 2
Free text is sorted into a category
An AI step reads the request and names the category and its confidence, so the rules have something to match.
- 3
The rules table is checked in order
The first rule that matches decides the route: approve automatically, send for approval, or hand to a team.
- 4
Cases no rule matches go to a person
With the facts and the reason no rule applied, so they can decide and suggest a new rule.
- 5
The decision is recorded with its rule
Which rule fired, on which facts, so the outcome can be explained later.
What a routing decision is made of
Four pieces, and the first is the one that keeps the others honest.
A rules table with an owner
Each row says when it applies and what happens. The process owner edits it, and every change is logged with who made it.
Facts, not claims
Rules run on values read from systems of record. A customer tier from the CRM beats a tier typed into a form.
AI that sorts, rules that decide
A model turns free text into a category with a confidence score. Below the threshold, the case goes to a person instead of guessing.
A fallback to a person
No match means a human decides, never a quiet default. Each fallback case is a candidate for a new rule.
The Tray Headless prompts
Paste these into Claude Code or Codex with the Tray Headless plugin installed. Each stage runs on its own. The systems named in them are the worked example rather than a requirement, and every prompt says so.
Once per project, run /tray-workflows:set-workspace to pick the workspace
these build in. Point it at a sandbox first.
Write the rules as a table
A rule nobody can read is a rule nobody can change.
- build-workflow
Use build-workflow. The systems in play are Zendesk, Salesforce, Stripe and Google Sheets, or whatever we run in those seats.
Build a rules table with one row per rule: the conditions (amount band, customer tier, request category, region), the route (approve automatically, send for approval, hand to a team) and a priority. Keep it in a sheet the process owner can edit, and log every change with who made it and when.
Rules are checked in priority order and the first match wins. Two rules that both match at the same priority is an error to report, not a tie to break at random.
Gather the facts before deciding
Rules are only as good as the values they run on.
- build-workflow
- tray-patterns
Use build-workflow. Before checking the rules, read every value they need from the system that holds it: the customer tier and contract from Salesforce, the payment from Stripe, the request from Zendesk.
If a value a rule needs is missing, don't treat it as zero or as false. Send the case to a person and say which value was missing.
Sort free text with AI, then let the rules decide
A model is good at reading and bad at being accountable.
Add an AI step that reads the request text and returns one category from a fixed list, with a confidence score and a one-line reason.
Above the threshold, pass the category to the rules table like any other fact. Below it, send the case to a person with the model's guess shown as a suggestion.
The model never picks the route itself. It answers "what is this about?", and the rules answer "what happens next?".
Send unmatched cases to a person
A default route hides the cases the rules missed.
- tray-gotchas
Use tray-gotchas. When no rule matches, post the case in the process owner's Slack channel with the facts, the category and why no rule applied. Let them pick the route in the message.
Record each of these cases. If the same kind keeps arriving, that is a rule the table is missing.
Record which rule decided
Every outcome should be explainable in one sentence.
Write the decision to the source record and to Snowflake: the rule that matched, the facts it matched on, the category and its confidence, and the route taken. Report each week on how often each rule fires, how many cases fell through to a person, and which rules never fire at all.
Validate it, then hand the table to the owner
Because the rules change more often than the workflow should.
Run the per-step checks and the whole-workflow audit before this goes live. Test a case for every rule, a case that matches two rules, one with a missing value, one with free text the model is unsure about, and one that matches nothing.
Then open the same workflow in Tray Build so the process owner can change the rules, the categories and the threshold in the visual canvas without a deployment.
What it connects to
Facts come from the systems that hold them, the rules live where the owner can edit them, and the decision goes back to the record.
-
Zendesk Supply the request and its text, and receive the route the case was given. Reads and writes -
Salesforce Supply the customer tier, contract terms and account owner the rules run on. Reads
-
Stripe Supply payment amounts and history for rules that depend on them. Reads
-
Google Sheets Hold the rules table the process owner edits. Reads
-
Slack Put unmatched cases in front of the process owner, with the facts and a way to choose the route. Reads and writes
-
Snowflake Hold every decision with the rule that made it, which is where missing rules show up. Writes
Named systems are the ones most teams run, not the only ones that work. Each is an authentication in your Tray workspace, referenced by name, so the workflow never holds a credential.
Same build, other stacks
The design does not change if you run something else in one of these seats. The same prompts build it against Microsoft Dynamics 365, Google BigQuery, Microsoft Teams, Jira, HubSpot or Databricks.
Connections in this build
Field mapping, templates and common problems for each pairing: Salesforce + Zendesk, Stripe + Salesforce, Google Sheets + Salesforce and Google Sheets + Stripe.
Running it in production
The rules are the control, so they have to be visible and owned.
- 1
It runs on the platform, not on your laptop
Decisions happen whenever a request arrives, and the rules table is read fresh on every run.
- 2
Every rule change is logged
Who changed which row and when, so the rules in force on any date can be shown.
- 3
Credentials are managed, never in code
Read access to the systems that supply facts, and write access only to the fields the decision updates.
- 4
AI never decides alone
It sorts text into a category. The rules decide, and anything uncertain goes to a person.
- 5
The owner changes the rules
In the table and in Tray Build, without a deployment or a ticket to engineering.