That one is super easy if you want it to happen every time. It’s an official feature which is part of echo routines (not smartthings routines) . And it recognizes the SmartThings contact and motion sensors as triggers.
If you’re a power user, even better is that it will trigger for a virtual sensor, which means any event at all that smartthings can recognize can now be used to trigger an echo routine. And you can set conditions on it like time of day or location mode or other filters. You put the logic on the SmartThings side and only trigger the virtual sensor when you want the echo routine to run.
See the community FAQ (the topic title is a clickable link).