[SOLVED] AppleScript error when running macro

This macro created by @noisneil is no longer working for some reason, even though I haven't made any changes to it.

I'm getting this error now:

Execute an AppleScript failed with script error: text-script:532:599: execution error: Notes got an error: AppleEvent handler failed. (-10000). Macro “Notes - New Note (available via Raycast)” cancelled (while executing Create new Note).

Notes - New Note (available via Raycast).kmmacros (43 KB)

Keyboard Maestro Export

One thing I noticed is that the error only pops up if I add both the title and the body. If I only add the title, it doesn't pop up, but it also doesn't add the new note at all

For some reason I was able to fix it by making some changes to the script, based on something I saw online (I just copied and pasted it, since I'm not an AppleScript expert). It's working now. So this is the new script:

set inst to system attribute "KMINSTANCE"
tell application "Keyboard Maestro Engine"
	set noteTitle to getvariable "Local__Title" instance inst
	set noteBody to getvariable "Local__Body" instance inst
end tell

set noteTitleHTML to "<h1>" & (noteTitle as Unicode text) & "</h1>"
set noteBodyHTML to "<pre style=\"font-family:SF Pro Text,sans-serif; font-size: 14px;\">" & (noteBody as Unicode text) & "</pre>"

set noteHTMLText to noteTitleHTML & noteBodyHTML

tell application "Notes" to tell account "iCloud"
	-- make new note
	set newNote to make new note at folder ¬
		"Notes" with properties {body:noteHTMLText}
	-- get its id
		id of newSPITENote
	on error errorMessage
		set ATID to AppleScript's text item delimiters
		set AppleScript's text item delimiters to "\""
		set theID to text item 2 of errorMessage
		set AppleScript's text item delimiters to ATID
	end try
end tell