This tutorial explains how to create a custom keyboard shortcut to close all macOS notifications using Automator and System Settings.
- Open Automator (use Spotlight Search or find it in Applications).
- In the window that appears, select Quick Action as the document type.