Problems with macro to create markdown link to edit or trigger KM macro in Bear

Hello, I created the macro below to create a link in Bear markdown to edit a macro.
Everything works except for I don't' know how to replace Macro Name by the appropriate variable at the end

Could I further simplify the macro by simply inserting the UUID as a variable instead of "copy UUID" etc ?

The syntax for the final expression is
[Macro Name](Macro URL)

I will have 2 versions at the end, one to edit the macro and the other to trigger the macro, one with keyboardmaestro://m=UUID to edit and one with kmtrigger://macro=UUID to edit the macro.

thank you very much

Create Bear Link to Edit Macro.kmmacros (29.8 KB)

After you've copied the UUID and saved it to a variable, try a normal "Copy" action -- that will put the macro's name (amongst other things) on the clipboard, except suffixed with a :leftwards_arrow_with_hook: (which is easy enough to remove).

Of course there's always AppleScript. Pop this in an "Execute an AppleScript" action and you'll have a link as you've described, ready to paste:

tell application "Keyboard Maestro"
	set theMacro to item 1 of (get selectedMacros)
	set the clipboard to "[" & name of macro id theMacro & "](keyboardmaestro://m=" & theMacro & ")"
end tell