If you’re using DID, that is, you have several incoming line phone numbers to the Asterisk box, I’d dedicate one of the numbers to the fax machine, and have it directed to the fax line.
I’m generally opposed to putting fax lines on VOIP systems though. It’s usually a much better configuration to simply leave an analog line off the system, and by itself, to go directly to the fax machine.
Yes, you do end up with one fewer trunk lines on the Asterisk box, but you also gain a loss of power station. Should your Asterisk box lose power, you have a known location to go to that’s not affected by the situation. (Emergency phones should always be available in a central place, and fax machines are usually centrally located in an office.)
If you’re not using DID, and you’re just trying to do fax detect on an ‘S’ extension, it’s really kind of a timing thing. The CNG tones from the sending fax are sent every couple of seconds. Which means that the fax sender could hear a couple of seconds of your main menu greeting before the Asterisk box hears the CNG tones and starts whatever fax handling method you use.
You could try to put this at the begining of your main menu:
exten => s,1,Answer()
exten => s,2,Ringing()
exten => s,3,Wait(2)
exten => s,4,go on to other main menu stuff
This will give all callers a couple of seconds of extra ringing but, more importantly, it will also answer the incoming lines and give the Asterisk box a chance to listen for and hear the CNG tones before it begins to play the IVR greeting. It should switch over to fax receive mode immediately.
Hope that helps.