Getting frustrated with triggered emails

Ok, so I think the problem is with using async and await commands. I also heard somewhere that you have to move the code to the back end. I keep on getting this error:
contactId does not match current session contact (401)