EDIT - after replying with an Example of how to do this with AppleScript and how to adapt that AppleScript to other situations I suddenly realised a much simpler solution. So, I am editing my original post with this non-AppleScript version:
Since it is the case that pasting the XML code of an Action recreates that Action in Keyboard Maestro we don't need AppleScript at all to create a single Action...
It can be done by just using Keyboard Maestro native Actions and replacing the parts of the XML code that we want with Keyboard Maestro Variables!
So, first create a Custom Action (with Placeholder text for the bits you want to Prompt the User for).
Select just this one Action in Keyboard Maestro and choose Edit>Copy As>Copy as XML
Paste this into a Text Editor (I just use Apple Notes). Edit this XML text to replace the Placeholder text with Keyboard Maestro Variables (shown in bold just to make it clearer)
is edited to become this:
To build the Macro to make use of this:
Put that edited XML code in a
Set Variable Action.
Filter that Variable to process the Variables.
Then paste that Variable's XML text by using an
Insert Text by Pasting Action.
Running the resultant Macro will create a new Customised Action just below whatever current Action is selected in the Macro you are editing.
Here is an Example Macro using the Action that @noisneil uploaded for me.
EXAMPLE Create Single Action with original XML.kmmacros (5.1 KB)
And here is that Example Macro in use:
As this particular custom Action references a Macro to Execute that is not on my computer it shows "none". But as the reference for the Macro it is looking for is in the XML code it should work fine on @noisneil's Mac. And of course even that could be changed to a Variable.
This approach should work with any Keyboard Maestro Action (not just the Execute Macro Action).
EDIT - I've just realised you can be even cheekier if instead of using Placeholder text you just enter the Variable names you want to use in you initial Custom Action, quoted like this:
When this Action is copied as XML those Variables will be quoted correctly in the XML. No need to edit them in the XML.
One last thing to bear in mind is that when you are building your Macro, if you try and paste this XML text into a
Set Variable Action it won't paste in. It will create a new Action. So you do have to temporarily add something to the XML text to "break" it so that it will just paste in as text. A simple way is to first paste it into a Text Editor, add a random letter at the front of the code, copy and paste this edited version into the
Set Variable Action and then remove that random letter.