How do Shelly products detect button presses?
All they need is a pullup resistor to one of the internal power rails- +12 or +3.3V (and some protection/filter passives most likely).
No isolation is provided in the circuit, so the signal can go more-or-less directly into the MCU.
From here:

Do not connect AC power and the serial connection at the same time The GND connection of the Shelly is connected to the live AC wire. Connecting serial with your PC will fry your PC.

For this reason, the external switch should  use wiring standards adequate for any other mains wiring.
Edit: Textbook circuit to the left (even R1 might be unnecessary if an internal MCU pullup is enabled). More robust circuit to the right. More protection is possible, such as TVS diodes and so on, there is no way to tell how solid their design is without taking it apart, but being an inexpensive consumer product probably not all that much.



simulate this circuit &ndash; Schematic created using CircuitLab
The N is one side of the 110/230V power source and the internally derived power supplies are relative to that N. Probably they are using half-wave rectified AC for the flyback supply to keep the N common with the input power. Guess:



simulate this circuit