1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. If you had a PIAF Forum account in the vBulletin days, log in with your old credentials. Otherwise, sign up again and we'll get you back in business as soon as we can.
  3. A serious FreePBX vulnerability has been reported. Update your Framework Module immediately. Click here for details.

Hylafax+Avantfax+Gvoice

Discussion in 'Add-On Install Instructions' started by Karnith, Apr 18, 2011.

  1. Karnith New Member

    I know this topic has been touched on several times, but I thought I would create a tutorial on how to do this, if not for my own recollection and reference in the future. I hope this will help other if they are trying to do the same thing.

    My setup:
    VMware whitebox host (built myself)
    Comcast voice,Cable Internet 7Mb upload/22Mb download
    Piaf x86_64 1.8.3.2 Purple (Incredible PBX)
    Avantfax 3.3.3
    Hylafax 6.0.5 Client x86_64 --needed
    Hylafax 6.0.5 Server x86_64
    *I used iaxmodem because my OS is virtual and pass through of a PSTN card might be too much for me to take on, if it is even possible.

    I modified a script from Piaf for the install and I will add it this post for anyone who wants to try/do this. I also pooled info from other threads on the forum for this
    Modify the script as needed with your editor (can be done if needed although the script can be run as is)

    I have done things different with the Google voice contexts which we will go into first to create the proper routes and trunks for our Google voice system.

    Contexts:

    In your Freepbx dashboard click on tools and config edit
    Find extensions_custom.conf and click to edit it.
    Comment out the entire [ext-fax], [sendfax], [faxit] and [googlein] contexts.

    Add these to the bottom of the file:
    Code:
      
    [from-fax]
      exten => _x.,1,Dial(local/${EXTEN}@[B][COLOR=red]username1faxout[/COLOR][/B])
      exten => _x.,n,Hangup()
       
      [from-fax1]
      exten => _x.,1,Dial(local/${EXTEN}@[B][COLOR=red]username2faxout[/COLOR][/B]) 
      exten => _x.,n,Hangup()
       
      [googlein]
      ;Allows anonymous calls through travelin man and replaces onymous@vo with anonymous. Waits removed
      exten => _[0-9a-z].,1,Noop(Incoming Google Voice call for ${EXTEN})
      exten => _[0-9a-z].,n,Set(CALLERID(name)=${CUT(CALLERID(name),@,1)})
      exten => _[0-9a-z].,n,GotoIf($["${CALLERID(name):0:2}" != "+1"]?notrim)
      exten => _[0-9a-z].,n,Set(CALLERID(name)=${CALLERID(name):2})
      exten => _[0-9a-z].,n(notrim),Set(CALLERID(number)=${CALLERID(name)})
      exten => _[0-9a-z].,n,Answer
      exten => _[0-9a-z].,n,Wait(10)
      exten => _[0-9a-z].,n,SendDTMF(1)
      exten => _[0-9a-z].,n,Goto(from-google-voice,${CUT(EXTEN,@,1)},1)
      exten => h,1,Macro(hangupcall,)
      
    *I use travelin man, but this context can still be used without it. This custom gvoice context has the waits removed and passes the inbound call to the [from-google-voice] context where the call is routed based on username of the gvoice account.

    Replace username and gvoice number with the appropriate values of your environment
    Code:
      
    [from-google-voice]
      ;Allows multiple gvoice accounts. Waits removed.
      exten => [B][COLOR=red]username1[/COLOR][/B],1,Goto(from-trunk,[B][COLOR=red]gvoice Number1[/COLOR][/B],1)
      exten => [B][COLOR=red]username2[/COLOR][/B],1,Goto(from-trunk,[B][COLOR=red]gvoice Number2[/COLOR][/B],1)
      exten => [B][COLOR=red]username3[/COLOR][/B],1,Goto(from-trunk,[B][COLOR=red]gvoice Number3[/COLOR][/B],1)
      ;exten => [B][COLOR=red]username4[/COLOR][/B],1,Goto(from-trunk,[B][COLOR=red]gvoice Number4[/COLOR][/B],1)
      exten => h,1,Macro(hangupcall,)
      
    This context matches a username to the Google voice number which in turn will be used for a alias or CID lookup by asterisk to the correct extension. I used the CID lookup via number for my box.

    The first gvoice context should be there already, so you really just need to add the second and third contexts. Make sure that asterisk in the context is stepped up by one for each new context you add. I believe this has to do with channels. It should look like this:
    Code:
      
    [gvoice]
      exten => _X.,1,Wait(1)
      exten => _X.,n,Set(ALERTNAME=[B][COLOR=red]username1[/COLOR][/B]@gmail.com)
      ;exten => _X.,n,Set(STATUS=${JABBER_STATUS([B][COLOR=red]asterisk[/COLOR][/B],${ALERTNAME})});
      ;exten => _X.,n,NoOp(Gvoice/Jabber Status: ${STATUS})
      exten => _X.,n,JABBERSend([B][COLOR=red]asterisk[/COLOR][/B],${ALERTNAME},Placing GVoice Call: ${EXTEN})
      exten => _X.,n,GotoIf($["${LEN(${EXTEN})}"="10"]?us:other)
      exten => _X.,n(us),Dial(Gtalk/[B][COLOR=red]asterisk[/COLOR][/B]/+1${EXTEN}@voice.google.com)
      exten => _X.,n,Goto(done)
      exten => _X.,n(other),Dial(Gtalk/[B][COLOR=red]asterisk[/COLOR][/B]/+${EXTEN}@voice.google.com)
      exten => _X.,n(done),NoOp(GVoice Call to ${EXTEN} failed)
       
      [FONT=Calibri][gvoice1][/FONT]
      [FONT=Calibri]exten => _X.,1,Wait(1)[/FONT]
      [FONT=Calibri]exten => _X.,n,Set(ALERTNAME=[B][COLOR=red]username2[/COLOR][/B]@gmail.com)[/FONT]
      [FONT=Calibri];exten => _X.,n,Set(STATUS=${JABBER_STATUS([B][COLOR=red]asterisk1[/COLOR][/B],${ALERTNAME})});[/FONT]
      [FONT=Calibri];exten => _X.,n,NoOp(Gvoice/Jabber Status: ${STATUS})[/FONT]
      [FONT=Calibri]exten => _X.,n,JABBERSend([B][COLOR=red]asterisk1[/COLOR][/B],${ALERTNAME},Placing GVoice Call: ${EXTEN})[/FONT]
      [FONT=Calibri]exten => _X.,n,GotoIf($["${LEN(${EXTEN})}"="10"]?us:other)[/FONT]
      [FONT=Calibri]exten => _X.,n(us),Dial(Gtalk/[B][COLOR=red]asterisk1[/COLOR][/B]/+1${EXTEN}@voice.google.com)[/FONT]
      [FONT=Calibri]exten => _X.,n,Goto(done)[/FONT]
      [FONT=Calibri]exten => _X.,n(other),Dial(Gtalk/[B][COLOR=red]asterisk1[/COLOR][/B]/+${EXTEN}@voice.google.com)[/FONT]
      [FONT=Calibri]exten => _X.,n(done),NoOp(GVoice Call to ${EXTEN} failed)[/FONT]
      
      [FONT=Calibri][gvoice2][/FONT]
      [FONT=Calibri]exten => _X.,1,Wait(1)[/FONT]
      [FONT=Calibri]exten => _X.,n,Set(ALERTNAME=[B][COLOR=red]username3[/COLOR][/B]@gmail.com)[/FONT]
      [FONT=Calibri];exten => _X.,n,Set(STATUS=${JABBER_STATUS([B][COLOR=red]asterisk2[/COLOR][/B],${ALERTNAME})});[/FONT]
      [FONT=Calibri];exten => _X.,n,NoOp(Gvoice/Jabber Status: ${STATUS})[/FONT]
      [FONT=Calibri]exten => _X.,n,JABBERSend([B][COLOR=red]asterisk2[/COLOR][/B],${ALERTNAME},Placing GVoice Call: ${EXTEN})[/FONT]
      [FONT=Calibri]exten => _X.,n,GotoIf($["${LEN(${EXTEN})}"="10"]?us:other)[/FONT]
      [FONT=Calibri]exten => _X.,n(us),Dial(Gtalk/[B][COLOR=red]asterisk2[/COLOR][/B]/+1${EXTEN}@voice.google.com)[/FONT]
      [FONT=Calibri]exten => _X.,n,Goto(done)[/FONT]
      [FONT=Calibri]exten => _X.,n(other),Dial(Gtalk/[B][COLOR=red]asterisk2[/COLOR][/B]/+${EXTEN}@voice.google.com)[/FONT]
      [FONT=Calibri]exten => _X.,n(done),NoOp(GVoice Call to ${EXTEN} failed) [/FONT]
      
    continued on next post
  2. Karnith New Member

    Routes:

    We now need to create some extensions, routes and trunks for our fax setup.

    [FONT=&quot]In FreePBX, Setup, Extensions, Add Extension, add a Generic IAX2 Device. [/FONT]
    [FONT=&quot]Create the extensions with the following Characteristics: [/FONT]

    [FONT=&quot]Display Name:[/FONT][FONT=&quot] Bob’s Fax (Give it a Descriptive Name) [/FONT]
    [FONT=&quot]Outbound CID:[/FONT][FONT=&quot] As appropriate [/FONT]
    [FONT=&quot]Secret:[/FONT][FONT=&quot] An Appropriate STRONG secret. (We also use permit/deny) [/FONT]

    [FONT=&quot]Save your changes. Then, open the newly created extension again and configure the following characteristics: [/FONT]

    [FONT=&quot]notransfer[/FONT][FONT=&quot] = yes [/FONT]
    [FONT=&quot]host[/FONT][FONT=&quot] = 127.0.0.1 [/FONT]
    [FONT=&quot]type[/FONT][FONT=&quot] = friend [/FONT]
    [FONT=&quot]port[/FONT][FONT=&quot] = 4574 <=== * Must be unique. I used 4570 and 4571 since the script creates the modems with these ports.[/FONT]
    [FONT=&quot]qualify[/FONT][FONT=&quot] = yes [/FONT]
    [FONT=&quot]disallow[/FONT][FONT=&quot] = all [/FONT]
    [FONT=&quot]allow[/FONT][FONT=&quot] = ulaw [/FONT]
    [FONT=&quot]permit[/FONT][FONT=&quot] = 127.0.0.1/255.255.255.0 (We also use Secrets) [/FONT]
    [FONT=&quot]secret=[/FONT][FONT=&quot] XXXXXX <=== An appropriate string secret. [/FONT]
    • [FONT=&quot]This must be a unique port. I selected 4574 because the first 4 virtual modems are already set to use ports 4570-4573. Each time you add a new Virtual modem, increment this port by 1. [/FONT]
    [FONT=&quot]Do not enable voice mail or VMX. You can disable call waiting as this won’t be needed either for this particular setup.[/FONT]

    Next, go to trunks and create the trunks needed for outbound calls. The trunks will be Custom trunks.

    Trunk Name: name the trunk something meaningful

    Leave everything else default except Custom Dial string

    Custom Dial String: local/$OUTNUM$@gvoice1
    *The custom dial string is referencing the gvoice context we made earlier
    Do this for all gvoice extensions you added in the extensions_custom file.

    Now we need to create the outbound routes

    The quick way to do this would be to duplicate the default route for as many times you have fax extensions created. This gives each fax line its own out route and enables multiple ax modems to send faxes at a time.

    Change the name of each duplicated route to something meaningful. I have given a suffix to each of my routes using FaxOutRoute. Be sure to select only the matching trunk for the route in Trunk Sequence section of the outbound route. You can also add these routes to the Toll Free and Google voice out routes. I removed the default outbound route as I have all of my extensions using their own custom context for segregation of calls.

    In the freepbx dashboard find the custom contexts module in the menu and go there. We need to create a custom context for each of our extensions.

    Name the context and give a meaningful description to it. Select set all to “yes” and change the Entire Basic dial plan and All outbound routesto “No”. In outbound routes change everything to “No” except the route we created for this extension. Be sure to save.

    Go back to the extensions you created and select the custom context from the Custom Context section under device settings.

    OK, now we have our extensions, routes and trunks created. On we go to the install of our fax system.



    Script
    Code:
      
    cd /root
      use download the script
      chmod +x piaf-hylafax.sh
      ./piaf-hylafax.sh
      Reboot server when it is done.
      
    The script will download and install everything for you. It will also create 2 modems with ports 4570 and 4571.

    Modem config
    Edit the config of both modem IAX0 and IAX1 (this will need to be done for each modem if the script was edited to create more than two modems) *I used nano


    Code:
      
    nano /var/spool/hylafax/etc/config.ttyIAX0
      add to bottom of file
      #
      #       AvantFAX
      #
      FaxRcvdCmd: bin/faxrcvd.php
      DynamicConfig: bin/dynconf.php
      UseJobTSI: true
      JobReqNoAnswer: 180
      JobReqNoCarrier: 180
       
      ModemRate:             14400           # rate for DCE-DTE communication
      
    The ModemRate is the speed of the modem and I found 14400 to work over my internet connection. Results may vary depending on your internet connection speed and quality.

    [FONT=&quot]In freePBX using config editor, edit the following of the iax_custom.conf file: [/FONT]
    [FONT=&quot][iax-fax0][/FONT]
    [FONT=&quot]type=[/FONT][FONT=&quot]friend [/FONT]
    [FONT=&quot]host=[/FONT][FONT=&quot]127.0.0.1 [/FONT]
    [FONT=&quot]port=[/FONT][FONT=&quot]4570[/FONT]
    [FONT=&quot]context=[/FONT][FONT=&quot]from-internal[/FONT]ç[FONT=&quot]===Change from-internal to the context your created [from-fax]. Raise the number for each context you created. (eg. from-fax1,from-fax2……)[/FONT]
    [FONT=&quot]disallow=[/FONT][FONT=&quot]all [/FONT]
    [FONT=&quot]allow=[/FONT][FONT=&quot]ulaw [/FONT]
    [FONT=&quot]jitterbuffer=[/FONT][FONT=&quot]no [/FONT]
    [FONT=&quot]qualify=[/FONT][FONT=&quot]yes [/FONT]
    [FONT=&quot]deny=[/FONT][FONT=&quot]0.0.0.0/0.0.0.0 [/FONT]
    [FONT=&quot]permit=[/FONT][FONT=&quot]127.0.0.1/255.255.255.0 [/FONT]
    [FONT=&quot]secret=[/FONT][FONT=&quot] XXXXXX<=== The same strong secret you assigned to the shared fax occurrence, above. [/FONT]
    [FONT=&quot]Save your changes. [/FONT]

    Configure avantfax as this post describes. You can follow the instructions for webmin module installation also. I would use the 1.9 module as that is what I am using without any problems.

    Reboot server to set the new configuration of the modems. You should now have a working fax system using hylafax, avantfax and Google voice.


    When I have more time I will clean this up and give a better outline of what to do.


    Karnith

    **I see the link is broken for the webmin module download. I have provided here for you.

    Attached Files:

  3. trupsalms Member

    gv and hylafax/avantfax working/not working

    faxes are detected but, hangsup shortly after, faxing does not complete, prematurely terminates i believe.
  4. Karnith New Member

    Would this be incoming or outgoing faxes?
  5. trupsalms Member

    this would be incoming faxes

Share This Page