applescript – Script that creates a mailbox (folder) based on the subject of the email

I adopt the zero inbox method, which means that I want to keep my inbox as empty as possible.

To achieve this, I need to archive emails quickly. The best method I found was to write a script that, when I right-click on an email, the script creates a new folder based on the subject of the email and then moves this message to this folder.

This worked perfectly in Microsoft Outlook on Windows.

Now I changed jobs and I'm using a Mac. Does anyone know how to achieve a similar result using Mail?

Thank you very much in advance.