when you post code here, please format it properly so we can read it reasonably. here’s info o how:
for what you’re doing, i think you can do it all (or very close to all) via the ui. especially if you’ve not built automation before, you should use the ui if you can. i don’t see anything here that you couldn’t do in the ui. and it will save you from formatting issues.
given what you’ve posted, i’m guessing that you have your whole action block indented. it should line up right at the same level as trigger.