There are many books on Alexa but most focus on using the service rather than understanding how it works. The Dummy books are quite good.
There is no simple answer to your question on protocols, commands etc. as it varies according to what you are doing.
Essentially there is a potentially a long pipeline of events and actions.
1) Device (Dot, Echo ...) listens for wake word (Alexa). When this occurs device then sends the audio through to the Amazon Alexa service.
2) Amazon Alexa service analyses the audio, forms it into words and then tries to interpret what you are requesting.
3) The request could need a local response back to the device like an answer to a question, setting an alarm, or playing music. If so then the Amazon service just replies directly back to the device.
4) If the request needs an added skill (triggered by the command used) then Alexa forms a packet of data (containing the words recognised in the request) and sends them on to the skill service configured when that skill is created. This is typically another cloud service somewhere and can be on the Amazon lamda service which can be used to host skills (see Alexa skill development info for good guides).
5) The skill service decides what to do based on the request words it receives.
6) In some cases (like requesting train times) this might just be a reply back to Alexa with text which then gets vocalised and sent back to your device.
7) In other cases, like home automation control, the skill service has to action the request using whatever techniques / protocols that particular home automation device needs. This is why there is no simple answer to your question. For example, some skills (particularly those developed by individual users) might talk direct to your device using port forwards and sending either a web request or using tcp/udp messaging. In other cases (probably more common for commercial devices) the home automation already has its own cloud service to allow control via a phone App. So then the skill service sends the action command to the home automation service in a similar way to how that phone App would. The home automation service then performs the action using again any number of different methods. Some automation devices might poll their home automation service to see if there are any outstanding commands.
Most Sonoff modules use the ESP8266 wifi processor module. One can update the firmware in these to do all sorts of useful things. Check out www.esp8266.com