I'm not quite sure what you're after, here.
Closest available within Mail and Smart Mailboxes on macOS Monterey are akin to the following:

Here's an intro to Smart Mailboxes (which are best considered to be saved searches):
... Use Smart Mailboxes in Mail on Mac - Apple Support
There's no means to process text within the mail messages akin to what you might be seeking here, and the macOS Shortcuts app lacks meaningful support for Mail, and I also don't know of a way to do this with Automator.
Past what's available, send your feedback to the folks at Apple:
... Product Feedback - Apple
Pending any changes from Apple, you're probably going to want a different mail client with capabilities better suited for your needs, either a full app, or an app intended to directly connect to and script the contents of the account on the mail server.