Tasker is a nifty app for Android. (There's nothing like it for iPhone/iOS because of sandbox limitations.) It allows all sorts of "when this happens do that". e.g. When I'm connected to WiFi but it is not my home WiFi, start VPN.
It is complicated to learn, but wonderfully powerful.
I don't use it. When I was using it, about once or twice a week, my phone would spontaneously reboot. I wouldn't be using it at the time. It was just sitting in my pocket. Then it would vibrate and I'd pull it out and see that it was restarting.
The only tasks I had at the time were:
I don't have patience for spontaneous reboots right now. To really debug this, one would have to:
Certainly do-able. Not a priority right now.