Got errors on my rule

Don’t paste complete example rules meant for xxx.rules file format into the UI rules editor.
See -

Only the part between, but not including, “then” and “end” belongs in a UI script section.