It can’t be just a virtual switch because at the present time Alexa does not allow switches to be the triggers in routines.
You have to use special code for a virtual device which is BOTH A Switch and a Sensor. When you turn on the switch, the sensor will look like it opened. when you turn off the switch the sensor will look like it closed.
Since Alexa can use sensors as the trigger for routines, it will work.
This is all explained in the community FAQ, including links to get that particular code, so let’s not take this thread any further off-topic, because this method does NOT work with Google devices at this time.