Asterisk Sending and receiving faxes
Hello. Today I want to write a note on how to set up sending / receiving faxes using Asterisk software PBX (no physical faxes are available). So.
Given:
1. There is an organization engaged in, say, sales (in fact, anything, because faxes are used a lot where). There are users in this organization who sometimes / often send / receive faxes.
2. There is also Asterisk with city lines connected (via SIP or through some VOIP gateway - it doesn’t matter. The main thing is that these peers are registered in sip.conf).
Task:
Configure Asterisk so that each user can receive / send a fax message by pressing a certain key combination on the phone.
Decision:
Everything described works on asterisk 1.8.27.0. Faxes sent by me are received without problems on fax machines such as multifunction devices and on ordinary machines located, for example, at customs. Our automatic telephone exchange should be collected / or the app_fax.so module is installed. This module includes two commands SendFAX and ReceiveFAX, and we will use them.
Sip.conf file
As you can see, this is a piece of my sip.conf file. Here is a feast that is registered on sipnet.ru. I and I will be called from and to him and I will send / receive faxes.
allow = alaw - preferred codec. It is alaw, because it is a “native” codec of faxes (it will work both on fax machines in the form of multifunction devices and on “iron” machines).
It is also necessary to register in sip.conf service number for example "5555". We will transfer the call to this number in order to receive the fax. This is done in order to explicitly set the set of codecs used (here there is one codec - alaw).
Further. We want the fax to be sent / received when a certain key combination is pressed. Let it be a combination of * 3 for sending and * 4 for receiving a fax.
To do this, add the following to the features.conf file in the [applicationmap] section:
As you can see, when you press * 3, the fax macro starts, and when you press * 4, it goes into the office-1 context, extension 5555.
The extensions.conf file:
Here we set the value of the variable DYNAMIC_FEATURES = fax_rec # fax_send.
fax_rec # fax_send - an enumeration of those “programs” and combinations that can be run from this number, let's say. If the value of the variable is not set, then the PBX will not respond to the combination of * 3 and * 4, at all.
Next is the dialing template for Rostov-on-Don. 92932214 (number taken from the bulldozer).
The sending algorithm is as follows:
0. The user converts the text file / document (in any way) into PDF format and copies it to the / var / spool / asterisk / fax folder.
1. The user dials 92932214.
2. The PBX calls 88632932214 - Rostov-on-Don.
3. Pick up the phone, we say “receive the fax”, we are answered “start”
4. We wait until the phone rings and press * 3.
Now the fax sending macro itself:
Using / usr / bin / gs, we convert the PDF file to TIFF (format for sending faxes). LOCALSTATIONID - a variable where we set the number from which we send the fax.
LOCALHEADERINFO - indicate the name of the organization. You can read more about these variables in the Asterisk documentation.
All settings are simple. They can be complicated by your wish.
Next, we actually send the fax and after sending it we hang up.
Receive a fax. This is a fragment of the file where the actions for incoming calls to our sip number are written (incoming_calls context).
The value of the variable DYNAMIC_FEATURES must be set.
1. They call us (our number is say 2204352, it is also registered in sip.conf as sipnet5).
2. We pick up the phone, talk, then we are told, “receive the fax”, we say “start”.
3. Click * 4.
4. There is a transition to extension 5555 to the first position.
Piece of extensions.conf file
1. We answer
2. we receive the fax
3. we convert from tiff to pdf.
4. delete tiff
Like everything. If I forgot to write something or something is not clear - I apologize in advance. If this material was useful, very happy.
Given:
1. There is an organization engaged in, say, sales (in fact, anything, because faxes are used a lot where). There are users in this organization who sometimes / often send / receive faxes.
2. There is also Asterisk with city lines connected (via SIP or through some VOIP gateway - it doesn’t matter. The main thing is that these peers are registered in sip.conf).
Task:
Configure Asterisk so that each user can receive / send a fax message by pressing a certain key combination on the phone.
Decision:
Everything described works on asterisk 1.8.27.0. Faxes sent by me are received without problems on fax machines such as multifunction devices and on ordinary machines located, for example, at customs. Our automatic telephone exchange should be collected / or the app_fax.so module is installed. This module includes two commands SendFAX and ReceiveFAX, and we will use them.
Sip.conf file
[sipnet5]
type = friend
username = 004ххххххххххх
secret = ххххххххххххх
allerid = "ххххххххххххх/sipnet.ru"
host = 212.53.40.40
port = 5060
nat = yes
fromuser = ххххххххххххх
fromdomain = sipnet.ru
insecure=invite
context = incoming_calls
disallow = all
;allow = g729
;allow = ulaw
allow = alaw
allow = gsm
allow = g723
allow = g723.1
As you can see, this is a piece of my sip.conf file. Here is a feast that is registered on sipnet.ru. I and I will be called from and to him and I will send / receive faxes.
allow = alaw - preferred codec. It is alaw, because it is a “native” codec of faxes (it will work both on fax machines in the form of multifunction devices and on “iron” machines).
It is also necessary to register in sip.conf service number for example "5555". We will transfer the call to this number in order to receive the fax. This is done in order to explicitly set the set of codecs used (here there is one codec - alaw).
[5555]
type = friend
host = 192.168.4.1
port = 5060
username = 5555
secret = ххххххххххххх
qualify = yes
videosupport = yes
nat = yes
context = office-1
host = dynamic
insecure=port,invite
dtmfmode = rfc2833
disallow = all
allow = alaw
call-limit = 0
callgroup = 1
pickupgroup = 1
Further. We want the fax to be sent / received when a certain key combination is pressed. Let it be a combination of * 3 for sending and * 4 for receiving a fax.
To do this, add the following to the features.conf file in the [applicationmap] section:
[applicationmap]
fax_rec => *4,callee,Goto(office-1,5555,1)
fax_send => *3,callee,Macro(fax)
As you can see, when you press * 3, the fax macro starts, and when you press * 4, it goes into the office-1 context, extension 5555.
The extensions.conf file:
exten => _92XXXXXX,1,Set(DYNAMIC_FEATURES=fax_rec#fax_send)
exten => _92XXXXXX,n,dial(sip/sipnet5/8863${EXTEN:1},,wWtT)
Here we set the value of the variable DYNAMIC_FEATURES = fax_rec # fax_send.
fax_rec # fax_send - an enumeration of those “programs” and combinations that can be run from this number, let's say. If the value of the variable is not set, then the PBX will not respond to the combination of * 3 and * 4, at all.
Next is the dialing template for Rostov-on-Don. 92932214 (number taken from the bulldozer).
The sending algorithm is as follows:
0. The user converts the text file / document (in any way) into PDF format and copies it to the / var / spool / asterisk / fax folder.
1. The user dials 92932214.
2. The PBX calls 88632932214 - Rostov-on-Don.
3. Pick up the phone, we say “receive the fax”, we are answered “start”
4. We wait until the phone rings and press * 3.
Now the fax sending macro itself:
[macro-fax]
exten => s,1,answer()
exten => s,n,NoOp(************** SENDING FAX... *****************)
exten => s,n,System(/usr/bin/gs -dSAFER -dBATCH -dQUIET -sDEVICE=tiffg3 -sPAPERSIZE=a4 -r204x196 -dNOPAUSE -sOutputFile=/var/spool/asterisk/fax/fax.tiff /var/spool/asterisk/fax/fax.pdf)
exten => s,n,Set(LOCALSTATIONID=+78632204352)
exten => s,n,Set(LOCALHEADERINFO="OOO Roga i Kopita")
exten => s,n,SendFAX(/var/spool/asterisk/fax/fax.tiff)
exten => s,n,Hangup()
Using / usr / bin / gs, we convert the PDF file to TIFF (format for sending faxes). LOCALSTATIONID - a variable where we set the number from which we send the fax.
LOCALHEADERINFO - indicate the name of the organization. You can read more about these variables in the Asterisk documentation.
All settings are simple. They can be complicated by your wish.
Next, we actually send the fax and after sending it we hang up.
Receive a fax. This is a fragment of the file where the actions for incoming calls to our sip number are written (incoming_calls context).
exten => 0042081926,1,Set(DYNAMIC_FEATURES=fax_rec)
The value of the variable DYNAMIC_FEATURES must be set.
1. They call us (our number is say 2204352, it is also registered in sip.conf as sipnet5).
2. We pick up the phone, talk, then we are told, “receive the fax”, we say “start”.
3. Click * 4.
4. There is a transition to extension 5555 to the first position.
Piece of extensions.conf file
exten => 5555,1,answer()
exten => 5555,n,Set(DYNAMIC_FEATURES=fax_rec)
exten => 5555,n,receivefax(/var/spool/asterisk/fax/sss.tif)
exten => 5555,n,System(/usr/bin/tiff2pdf /var/spool/asterisk/fax/sss.tif -o /var/spool/asterisk/fax/sss.pdf)
exten => 5555,n,System(rm -f /var/spool/asterisk/fax/sss.tif)
exten => 5555,n,hangup()
1. We answer
2. we receive the fax
3. we convert from tiff to pdf.
4. delete tiff
Like everything. If I forgot to write something or something is not clear - I apologize in advance. If this material was useful, very happy.