I agree with the others that Rule Machine will probably be your best choice, but if you want an overview of the various options, this should help:
Also, since you mentioned that you have an iPhone, there is a third party app (iPhone only) that costs about $8 (+ $2 if you also want IBeacon support) that works very well if you want an if A while B then C. Not as powerful as Rule Machine (which is free), but very easy to use and a nice graphical interface. I like it a lot.