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.
  4. Critical FreePBX vulnerability! Update your server immediately. Details here.

New Multi-Tenant PIAF Purple w/ ALL latest Gtalk fixes! 12/10/2010

Discussion in 'Add-On Install Instructions' started by rentpbx, Nov 9, 2010.

  1. rentpbx Guru

    Go to this link for the current methodology using PIAF-Purple, Incredible PBX, and Asterisk


    PIAF incredible 1.8 comes with script which will configure one google voice account as a trunk. It is a huge and cool features. Kudos to PIAF team for bringing this new feature to us. Some of us, see the opportunity to expand the idea of connecting PIAF incredible 1.8 into multiple google voice account. It is driven by some of us who would like to share their PBX resources with multiple department or family usage by spliting the PBX into multiple tenant model.

    This work is made possible by foundation that PIAF laid in their PIAF purple edition. As prerequisite, you will need a PIAF purple edition configured as in http://nerdvittles.com/?p=705. We will make some changes on the premade script. We will also take advatage the custom context module that come pre installed in their PIAF purple edition.

    We will split the work into two part. Part one, we will be modify context and configuration file to get multiple GVoice account connected. We will be taking care of the incomming route. In the second part, we will be configuring custom context to handle out going call.

    Here we go......

    Part 1.

    1. add additional google account to your jabber.conf (please refer to http://nerdvittles.com/?p=705) to configure your google account. Login to your freepbx. Then, go to the tool tab and click on config edit. Look for jabber.conf and let start modifying it. Here is what I have in my configuration (modify the username and password according to your gvoice credential)

    type=client ;connection
    serverhost=talk.google.com ;route to server
    username=account1@gmail.com/Talk ;change to your username
    secret=pass1 ;change to your password
    port=5222 ;
    usetls=yes ;
    usesasl=yes ;
    status=Available ;
    statusmessage="Incredible PBX" ;
    timeout=100 ;

    type=client ;connection
    serverhost=talk.google.com ;route to server
    username=account2@gmail.com/Talk ;change to your username
    secret=pass2 ;change to your password
    port=5222 ;
    usetls=yes ;
    usesasl=yes ;
    status=Available ;
    statusmessage="Incredible PBX" ;
    timeout=100 ;

    save this file by clicking update.

    2. go back to config edit. now lets edit the extensions_custom.conf. Look for the [googlein] context and modify it as follow. BTW, you acn enhance/ optimize the dialplan better. I am giving you quick and dirty implementation

    exten => _.,1,GotoIf($["${EXTEN}" = "account1@gmail.com"]?googlein1,s,1:googlein2,s,1])

    exten => s,1,Wait(1)
    exten => s,n,Set(ALERTNAME=account1@gmail.com)
    ;exten => _X.,n,Set(STATUS=${JABBER_STATUS(asterisk,${ALERTNAME})});
    ;exten => _X.,n,NoOp(Gvoice/Jabber Status: ${STATUS})
    exten => s,n,JABBERSend(asterisk,${ALERTNAME},Incoming Google Voice Call: ${CALLERID(name):2:10})
    exten => s,n,Set(CALLERID(number)=${CALLERID(name):2:10})
    exten => s,n,Set(CALLERID(name)=${CALLERID(number)})
    exten => s,n,Answer
    exten => s,n,Wait(2)
    exten => s,n,SendDTMF(1)
    exten => s,n,Goto(from-trunk,gv-incoming,1)

    exten => s,1,Wait(1)
    exten => s,n,Set(ALERTNAME=account2@gmail.com)
    ;exten => _X.,n,Set(STATUS=${JABBER_STATUS(asterisk2,${ALERTNAME})});
    ;exten => _X.,n,NoOp(Gvoice/Jabber Status: ${STATUS})
    exten => s,n,JABBERSend(asterisk2,${ALERTNAME},Incoming Google Voice Call: ${CALLERID(name):2:10})
    exten => s,n,Set(CALLERID(number)=${CALLERID(name):2:10})
    exten => s,n,Set(CALLERID(name)=${CALLERID(number)})
    exten => s,n,Answer
    exten => s,n,Wait(2)
    exten => s,n,SendDTMF(1)
    exten => s,n,Goto(from-trunk,gv-incoming2,1)

    replace account1@gmail.com and account2@gmail.com. If you do not care about notifcation, you can refactor this code into much better dialplan context.

    while we are at this file, we are going to modify the outgoing gvoice context too.

    [gvoice] // notice this one is created by incredible script leave it alone for now.
    exten => _X.,1,Wait(1)
    exten => _X.,n,Set(ALERTNAME=account1@gmail.com)
    ;exten => _X.,n,Set(STATUS=${JABBER_STATUS(asterisk,${ALERTNAME})});
    ;exten => _X.,n,NoOp(Gvoice/Jabber Status: ${STATUS})
    exten => _X.,n,JABBERSend(asterisk,${ALERTNAME},Placing GVoice Call: ${EXTEN})
    exten => _X.,n,GotoIf($["${LEN(${EXTEN})}"="10"]?us:eek:ther)
    exten => _X.,n(us),Dial(Gtalk/asterisk/+1${EXTEN}@voice.google.com)
    exten => _X.,n,Goto(done)
    exten => _X.,n(other),Dial(Gtalk/asterisk/+${EXTEN}@voice.google.com)
    exten => _X.,n(done),NoOp(GVoice Call to ${EXTEN} failed)

    [gvoice2] //this is just quick and dirty copy of the above. Again, If you do not care about notifcation, you can refactor this code into much better dialplan.
    exten => _X.,1,Wait(1)
    exten => _X.,n,Set(ALERTNAME=account2@gmail.com)
    ;exten => _X.,n,Set(STATUS=${JABBER_STATUS(asterisk2,${ALERTNAME})});
    ;exten => _X.,n,NoOp(Gvoice/Jabber Status: ${STATUS})
    exten => _X.,n,JABBERSend(asterisk2,${ALERTNAME},Placing GVoice Call: ${EXTEN})
    exten => _X.,n,GotoIf($["${LEN(${EXTEN})}"="10"]?us:eek:ther)
    exten => _X.,n(us),Dial(Gtalk/asterisk2/+1${EXTEN}@voice.google.com)
    exten => _X.,n,Goto(done)
    exten => _X.,n(other),Dial(Gtalk/asterisk2/+${EXTEN}@voice.google.com)
    exten => _X.,n(done),NoOp(GVoice Call to ${EXTEN} failed)

    Save your modification. That is it. We are close to get multiple incoming gvoice.

    3. Next you will be modifying (more likely playing around) with inbound route. Lets go there, first modify the gv-incoming/ any cid. set the destination to extension 701. This is just for the demo. you can set the destination to ivr, ring group. etc etc.

    4. Create a new inbound route.

    Description: gvoice2
    DID Number: gv-incoming2

    set the destination to extension 702. This is just for the demo. you can set the destination to ivr, ring group. etc etc.

    That is all. You have multiple gvoice inbound call now.

    Part 2.

    In this part we are going to play around with custom context. We are done with modifying script.

    1. lets go to freepbx. create a new trunk call it gvoice2. Make a copy from the existing gvoice which is a custom trunk.

    On Custom Dial String put local/$OUTNUM$@gvoice2 (remember we create this on part1).

    2. Lets create an outbound route. This time, copy the existing default outbound route. give it Route Name: Default2. copy the other setting from the Default with the exception that the second trunk should be set to gvoice2.

    3. now on the third party addon click on Custom Context. Add Context. Name it googlevoice2out. submit it.

    4. now select what we want to be included in googlevoice2out. Please start from deny for all.
    diligently set everything to Allow except for the following

    ENTIRE Basic Internal Dialplan

    You can deny all contexts under Outbound Route except for Default2. You can play around to add other route except you do not want to add route that has trunk in gvoice. It will confuse you.

    5. Last step is go to extensions. modify extension 702 and set Custom Context to googlevoice2out.

    6. Don't forget to reload. I did amportal restart.

    That is all. you can create a group of extension that share the gvoice2 trunk by setting the Custom Context to googlevoice2out. All out going from these extensions will go through gvoice2 trunk. While other extension call out will be through gvoice trunk. It is a poor man multi tenant system. However, it works for me.
  2. lowno Guru

    Wow, thanks for all the info. I'll be trying this tomorrow.
  3. wardmundy Nerd Uno

    WOW! WOW! Why didn't we think of that.

  4. Somehow I assumed gtalk would be limited to one account per ip, but I guess since you can make multiple calls per gtalk account then secondary account logins should work okay as well, thanks big brother Google.

    In this implementation the outbound calls are being defaulted from set extensions, I suppose you could route them out like prior implementations of gvoice calling in Piaf "GV|, GV2|..."

    Nice... I'll play with this this morning.... unless Ward want's to test this and bundle this up into a nice install script in the next few minutes....:drool5:
  5. rentpbx Guru

    Just FYI, after the first step (configuring incoming ....) you need to do amportal restart. It seem gtalk does not how to do reload yet. Otherwise, it would not recognize the additional gv account
  6. keepalive=yes

    was added to the end of yes gtalk configuration in jabber.conf to keep the google chat connection from timing out, shouldn't that be in place here as well?
  7. wardmundy Nerd Uno

    Probably for every jabber context that you want to keep alive although we've found keepalive to be very unpredictable. The jabber test cron job works much better. :wink5:
  8. rentpbx Guru

    My server has public ip. I do not have to change any parameter. I have it for couple of days with this configuration. I have not experience any issue yet. I would suggest try the existing configuration. If you have some sort of long term issue, you can play around with other setting.
  9. ojthecat New Member

    Thanks this works great. I can now assign an extension it's own gv number.
  10. nlucier New Member

    I have this on the cusp of working with 3 GV numbers attached to 3 separate extensions.

    To get the [googlein] section to work correctly with more than 2 options for the 'GotoIf' according to how I read the documentation I had to do this:

    exten => _.,1,GotoIf($["${EXTEN}" = "account1@gmail.com"]?googlein1,s,1)
    exten => _.,n,GotoIf($["${EXTEN}" = "account2@gmail.com"]?googlein2,s,1)
    exten => _.,n,GotoIf($["${EXTEN}" = "account3@gmail.com"]?googlein3,s,1)

    The rest of the rentpbx's instructions were followed adding a 3rd entry in each section where a 2nd was added. As far as I can tell, this would work for as many GV numbers as you want.

    The above works a treat for incoming calls. They all go to the assigned extension without problems once the first call works. It seems that I have to do an amportal restart and then manually fire off the jabber cron job and then wait a few minutes and it magically works. This is only needed once I change a config affecting the GV stuff.

    My issue at this point is outbound calls. They go out the correction extension according to the panel and the logs, but the CID being presented to the other end is the same one every time, that of my original account1@gmail.com GV number configured during the Incredible setup. The logs show the calls all using the expected context and route (Default, Default2, Default3) on every test.

    Has anyone that is working on this configuration been able to get the individual GV CIDs to show on the receiving end?

    My system is currently supporting the home phones of 3 households now and would really like to be able to utilize this setup to further shrink the phone bills, but if I can't get this one feature to work, it's a non-starter due to callbacks based on CID will go to the wrong household 67% of the time.
  11. rentpbx Guru

    I would suggest you log into account2 and account3 in google.com/voice. Check on the history if the call is made from those account. If it does, you have big issue since you have to deal with google. They are different kind of animal.

    If not, your configuration is not quite correct.

    check the following.

    1. do you use custom context? does it set correctly on each extension?
    2 You custom context, make sure you follow my exception DENY "ENTIRE Basic Internal Dialplan" and "ALL OUTBOUND ROUTES". open up (MAKE SURE you do not edit) /etc/asterisk/extension_additional.conf look for you custom context. check if from_internal is included. If it is, you still have not set your custom context correctly.

    For the record, my CID show up correctly on the receiving phone. That is why we go through all this custom context setting. Otherwise, you can just do the Part1. It will handle only the incoming route. Without doing part2, you will be getting the same behavior as yours now.
  12. vcallaway Guru

    Starting to see a pattern.

    If my internet connection goes down, the first gv account comes back online. Not so with the others. I have to restart asterisk to get them back online.

    I use the google chat sidebar plugin to monitor if they go offline.
  13. nlucier New Member

    When you say that your CID is showing up correctly, you get unique CIDs on the remote phone when you are dialing from the configured extensions on the * box? Just making sure that part was explained correctly in my issues.

    I checked the extensions_additional.conf file from the CLI (strange that that file isn't in the list in Config Edit), and I did not find "from_internal" in the includes, but did find "from_internal_custom", so I went into the Custom Contexts Add-On again and found the line for that and changed it to Deny. Currently the Deny's in my Custom Contexts for "googlevoice2out"are:
    • Custom Internal Dialplan
    • ENTIRE Basic Internal Dialplan
    • outrt-001-OutSkype
    • outrt-002-OutFreeNUM
    • outrt-003-GoogleVoice
    • outrt-004-TollFree
    • Default3
    • outrt-005-Default

    The only entry in Outbound Routes with Allow is Default2.

    No change in what happens with CID though, my original GV number is seen on the remote phones regardless of which extension I use to dial out from. Checking the actual GV accounts, the calls are indeed only going out account1.
  14. rentpbx Guru

    Yes, I confirm it is a unique ID.

    One more trick I'll pass on here. Go to asterisk cli. and try to type dialplan show 14255222222@googlevoice2out

    Make sure there is only one

    [ Included context 'outrt-8' created by 'pbx_config' ]
    '_1NXXNXXXXXX' => 1. Macro(user-callerid,SKIPTTL,) [pbx_config]
    2. Noop(Calling Out Route: Default2) [pbx_config]
    3. Set(MOHCLASS=${IF($["${MOHCLASS}"=""]?default:${MOHCLASS})}) [pbx_config]
    4. Set(_NODEST=) [pbx_config]
    5. Macro(record-enable,${AMPUSER},OUT,) [pbx_config]
    6. Macro(dialout-enum,6,${EXTEN},) [pbx_config]
    7. Macro(dialout-trunk,2,${EXTEN},) [pbx_config]
    8. Macro(outisbusy,) [pbx_config]

    If you have another one, you need to resolve it with the priority on the custom context.

    Once that is done. You need to check.
    1. Go to your out bound route (Default2). check if the trunk used is gvoice2 not gvoice
    2. Then go to your extensions page. In this page, there is a custom context field. Set that to googlevoice2out

    You should be golden.
  15. nlucier New Member

    OK. Call back the search party. Just got a second set of eyes on my config and found a typo in the [gvoice2] & [gvoice3] sections where they were both pointing at [asterisk] and not [asterisk2] & [asterisk3]. I blame staying up way too late playing with my new toy :lol:

    This works splendidly now with full CID differentiation.

    Only problem I have now is I get to flatten the current switch and install Purple.

  16. warraich Member

    EXELENT WORK "rentpbx" Thank you and WARD for the great work you have done! :wink5:
  17. mainenotarynet Not really a Guru - Just a long time user

    Yes - Great work RentPBX and Mr. Ward. But I have a bit of a funky one. I can call out on all 4 of my separate GV accounts - Yeah :D but... :confused: I can not get calls in on any but the original one set up with Incredible That has in and out but the second one gives me 'Google subscriber unavailable' message as does the third. The fourth, however gives me a Fast Busy (congestion tone?).

    Anyone have this happen? If so... anything I can Try?

  18. JRoque Member

    Sssweeeeeet!! Got 3 in/out trunks going on a VirtualBox machine. I skipped the custom context stuff since I don't need it in my setup but everything was spot on. Nlucier's post also helped getting the 3 working.

  19. mainenotarynet Not really a Guru - Just a long time user

    -bump- Mr. Ward - RentPBX -- any ideas on what to try re:#17?

    All 4 show connected to PBX through the cli

    I have the jabber cron thing going but where do I add my four accounts to 'keepalive'?

    Thanks again

  20. Check post 10 and 15 in this thread, make sure you have your syntax correct [gvoice2] & [gvoice3] sections where they were both pointing at [asterisk] and not [asterisk2] & [asterisk3]

Share This Page