Failover WAN 2 sites

We have a main office and a branch office connected together with EFM line. Each of the offices has its own ISP. I would like to setup the routers in such a way that when internet is down at office A traffic to be redirected via EFM and computers at office A to use ISP provider of office B. And the other way around Office B to use the internet of office A when its own ISP is down. I’ve setup the routing so all networks can see each other at the moment and computers can communicate. Please find attached network diagram.
Image 2.png

If you set the gateways for each ISP to be checked (e.g. by PING) then that gives you a mechanism for marking the corresponding routes down if an ISP connection goes down.

You can then add default routes pointing to the EFM link but with suitable distance settings such that those secondary routes are ignored when the local ISP connection is available.