📜 ⬆️ ⬇️

Faxes in Freeswitch without fax

After the first half of the zero years, when the Internet and e-mail were widely distributed even in small cities, and the button “send to e-mail” appeared on scanners, I thought that faxes were from the category of fossils as analog modems.
But, to my misfortune, the love of fax machines was most of all fed by the employees of the accounting departments, who, in turn, were loved by the “executives” and “generals”. Considering the state of the analog lines in general, at that time the calls for “bad faxes” were spoiled by the overall picture of the service desk tickets, and my love for this document transfer technology was not at all.
Since 2006, in my projects, I began to use Asterisk or Avaya from business processes using Brainwashing at “decision makers”, thoughts about faxes were removed, in rare cases for the above-mentioned bookkeeping they left one analog line.
In 2012, when designing, the customer needed to be able to call from the site. About WebRTC read, but did not like it, stopped at Skype. Decisions on the Freeswitch, as a stable gate, have already been worked out by many, and on Asterisk it was no longer interesting.
After implementation, with the filing of local accounting, there was a question about faxes. Analog lines of the project did not provide. Consulted and agreed on the decision "at least at the reception."
Especially for the passage of faxes in the "computer telephony" protocol was developed
T.38 . In my case, there was no provision for additional equipment with its budget support, but I did not get an answer from the local Rostelecom. I stopped at the decision to use the G.711 codec and receive the document directly to the file.

In dialplan added:

<extension name="fax"> <condition field="destination_number" expression="^fax$"> <action application="answer"/> <action application="playback" data="silence_stream://2000"/> <action application="rxfax" data="/opt/freeswitch/fax/${strftime(%Y-%m-%d-%H-%M-%S)}-${caller_id_number}.tiff"/> <action application="hangup"/> </condition> </extension> 

')
Freeswitch has a fax tones analysis function for the entire voice session tone detect , and used it by writing:

  <action application="tone_detect" data="fax 1100 r +5000 transfer fax XML default"/> 


immediately after the voice greeting is answered. File folder distributed to the network via Samba . The customer, in the person of the chief accountant, was dissatisfied with the implementation without the usual apparatus, but in the debate against the advantage in saving money on paper, she could not argue the opposite. There is nothing left for accounting, how to study "new technologies".

A logical continuation of the story was the urgent need to send faxes. Working in Hylafax with the web interface, I thought it would be an impossible task for the customer. The idea of ​​printing a document on a virtual printer was beautiful, but it required additional actions of the recipient sending the number. Considering that business processes in an organization involved the scanning of documents in a specific repository, there were several workstations equipped with tablets and a dock. scanners, as well as the format used tiff, I decided that with the least resistance you can implement the following scheme; The document to be sent is scanned into a tiff file on a samba resource for sending faxes, with the assignment of the name of the form 8923XXXXXXX.tiff, where the file name before the extension is the recipient's number.

The script to send had the following form:

 send_fax.sh #/bin/bash #    # Send FAX script # Aleksey Ovchinnikov 2012 +7 913   find /home/fax/*.tif -printf "%f\n" | while read fname do mydate=$(date +%Y-%m-%d_%H-%M-%S) /usr/bin/convert -page Letter -density 204x98 -resize 1728!x1186 -units pixelsperinch -monochrome -compress Fax /home/fax/${fname%} /op t/freeswitch/fax/./$mydate"_"${fname%} rm /home/fax/${fname%} /opt/freeswitch/bin/fs_cli -x "originate sofia/gateway/rt/${fname%.*} &txfax(/opt/freeswitch/fax/./$mydate"_"${fname%})" done 


Scanning documents in the required parameters sometimes led to an error, I had to rewrite the script and forcefully convert files using ImageMagick.

To exclude questions, “fax went?” Added the following extension to the dialplan:

 <extension name="send_fax"> <condition field="destination_number" expression="^205$"> <action application="export" data="api_hangup_hook=system /opt/freeswitch/scripts/send_fax.sh"/> <action application="answer"/> <action application="playback" data="/opt/freeswitch/sounds/ru/RU/elena/___.wav"/> <action application="hangup"/> </condition> </extension> 

Source: https://habr.com/ru/post/159393/


All Articles