How to use the Obihai OBi100 or OBi110 VoIP device as a gateway between Asterisk/FreePBX and Google Voice and/or the OBiTALK network — Part 2: Using the Phone port as an Asterisk extension

This article has been moved. Please click here to read it.

12 Comments

  1. Justin Herman said

    I love your posts but I am having some issues.

    What I want to have is the OBi110 act as a gateway for all phone traffic in my house.

    I have followed your directions for getting GV on the Obi110 (no problem)
    I have followed your directions for getting FXO on the Obi110 to Asterisk (no problem)
    I have followed your directions to get GV to direct back to Asterisk (then everything Breaks)

    What I want to have happen is my Asterisk system (asterisknow/freepbx) to use the OBi110 to send and receive both POTS and GV communication (using GV as the primary outgoing route). THEN use the FXS port on the OBi110 to run the old handsets that are in my house as an ext. in Asterisk.

    Can this be done?

    I have searched for more information but have yet to get it ALL to work only pieces.

  2. (If anyone subscribes to comments on this thread, please ignore the THREE earlier (now deleted) posts, they all had bugs I only saw after posting. This is attempt #4 #5 [found another bug that required an edit] – hopefully I have it right THIS time.)

    Justin,

    Yes, it can be done, but it gets tricky because there are only two available Service Provider slots on the OBi. So what you have to do is follow the instructions in the previous article and then make the changes shown in the article above. You’ll first get Google Voice working on SP1 and get a trunk back to FreePBX going on SP2, and then (using the changes and additions in this article) get the Phone port working as an extension on FreePBX by “piggybacking” it on the trunk connection. Don’t even worry about the FXO until you get all that working — the point is you want to make sure your Google Voice, your Asterisk trunk, and your extension are all working as desired.

    Only THEN go back to the article, Review of the Obihai OBi110 VoIP device, Part 4: How to use the OBi110 as an FXO port with Asterisk and FreePBX, and to begin with only make the changes shown on the Physical Interface, Line Port page (the InboundCallRoute and RingDelay settings, plus whichever PSTN Disconnect Detection settings are right for your situation). ONLY change those things, submit and reboot. Then in FreePBX create an inbound route and for the DID use the ten digit number associated with your PSTN line (same as you used in the Line Port InboundCallRoute setting mentioned above).

    And in your [custom-from-obi] context, you’ll need to add another line near the top to accommodate the PSTN line, so the first few lines should look like this:

    [custom-from-obi]
    exten => 9-DIGIT-OBiTALK-NUMBER,1,Goto(from-trunk,${EXTEN},1)
    exten => 10-DIGIT-GV-NUMBER,1,Goto(from-trunk,${EXTEN},1)
    exten => 10-DIGIT-PSTN-NUMBER,1,Goto(from-trunk,${EXTEN},1)
    …..

    After you have done that, this is how everything should work:

    PHONE port is an extension off your Asterisk server.
    Google Voice is on SP1. Any incoming traffic on SP1 is redirected to Asterisk on SP2.
    Your Asterisk trunk is on SP2. Any incoming traffic from SP2 is directed as follows: If it’s and 11-digit call starting with “1″, it goes to Google Voice on SP1; if it’s a nine-digit number that’s called it is directed to the OBiTALK network, and if it’s the FreePBX extension number it goes to the Phone port. At this point no outgoing traffic will go to the Line port (more on that in a second).
    Any incoming calls on your Line port are redirected to Asterisk on SP2.

    Remember that you need THREE inbound routes in FreePBX: One for your 10 digit Google Voice number, one for your 10 digit PSTN number (connected to the Line port), and one for your OBiTALK number (assuming you are sending incoming OBiTALK network calls to Asterisk).

    Now as I said above, under this scheme NO outbound traffic is sent to the Line port. That may not be what you want. In that case you have to make your changes in the X_InboundCallRoute setting of Voice Services, SP2 Service and add any new rules there. For example, let’s say you wanted to send 911 calls to the Line port — you could add a rule such as {>(911):li}, (including the comma at the end) to the start of your X_InboundCallRoute (or, if you wanted all *11 calls to go via the Line port, you could use {>([2-9]11):li}, — note that this is untested by me (I don’t have an actual PSTN line here, but I think those are correct patterns) and please note that this also assumes you have FreePBX configured to send 911 calls to the OBi110 trunk in the first place (which is beyond the scope of this article).

    Beyond that, if you want to have certain calls going out the Line port, you have to decide how you want to do the routing. You have a couple of options. One is to simply add routing rules in the OBi device itself. For example, let’s say you live in a very small town that only has three “local” exchanges (222, 333, and 444) and they are all in the 999 area code, and your phone company wants them dialed using seven digits only. Asterisk will send them to the OBi with the full 11 digits (if you have followed my instructions) so what you can do is add a rule such as this (untested, but I believe this is correct):

    {>(<1999:> 222 xxxx|<1999:> 333 xxxx|<1999:> 444 xxxx):li},

    Obviously, that’s pretty cumbersome. So the other thing you can do is have Asterisk prepend a prefix on all calls that you want to go out the FXO (Line) port. Let’s say we follow the OBi convention of using **8 as a prefix for the Line port. In our FreePBX rules, at either the route or trunk level, you could add this prefix to certain patterns. Using the previous example, you might do something like this at the TRUNK level (assuming the called numbers are already in 11 digit format before they reach the trunk):

    **8 + 1999222XXXX
    **8 + 1999333XXXX
    **8 + 1999444XXXX

    This would add the **8 prefix at the trunk level, but only to calls matching those patterns. Then in the X_InboundCallRoute setting of Voice Services, SP2 Service, instead of using specific rules for each local prefix, you could do something more general such as:

    {>(<**81xxx:> xxx xxxx):li},

    The above rule should strip off the **8, the 1 and the area code and send the call to the Line port (again — untested by me). If you don’t need to strip the 1 plus area code then you could just strip the **8:

    {>(<**8:>1xxx xxx xxxx):li},

    Or if you just want to send anything with the **8 prefix totally “as is” to the Line port, except for stripping off the **8 prefix first, then you could use an even more generic pattern such as:

    {(<**8:>x.):li},

    The above rule should even correctly route something like **8911 to the line port — of course you’d then need to prepend the **8 in FreePBX before sending the call. If you use this rule then it’s your responsibility to make sure that Asterisk sends the calls in the format that the PSTN line wants to see (7 digit, 10 digit, 11 digit or whatever) because this rule does no translations other than removing the **8 prepend.

    Now I just want to emphasize one more time that most of what I have written above is not tested by me, so don’t rely on anything I’ve posted here (particularly the 911 stuff) until you test it and verify that it works as it’s supposed to. You may need to make some additional tweaks. But the point is that if you start out by getting everything working except the Line port, then add that capability in small steps (first incoming calls, then outgoing if you need them) and test after each step, you will know precisely where things went wrong (hopefully nowhere, and it will work perfectly for you).

  3. Walden said

    Perhaps you can give me an idea if the obi device (110 or 110 model) might serve for something I need to accomplish. I have a girlfriend in the Dominican Republic. I’ve been communicating with her via Skype, but when she’s out & about with her cell phone it costs me 11 cents per minute to talk to her. Can an Obi somehow be used in conjuction with her computer to take an incoming Skype VOIP call (from me, of course!) and re-route it out her land-line to her cell phone number? Since I can call for free on Skype (to her computer), this would make for a free call to her cell phone (would have to discuss with her possible issues regarding potential to eat up her cell-phone minutes), rather than paying a per-minute fee for dialing the cell phone directly (I’m assuming that a land-line call from her home to her cell phone should be free, except for any minutes on her cell-phone it might burn through). What say you? …am I barking up the wrong tree here, or might an Obi be viable to accomplish something like this?

  4. Walden, forget Skype, this is how I’d do it. Buy an OBi100 (on sale this weekend – act quick and you can get it for $40, but the sale ends tonight) and an OBi110 (or you could get two OBi110′s if you still have a landline at your location). Set up both under the same OBiTalk account. If you get an OBi100 then you keep it and ship the OBi110 to her. Now, when you want to call her, you’ll dial **9 plus her 9 digit OBiTalk number (she can do the same to call you, using your OBiTalk number) and because both devices are under the same account, you’ll get a menu. If you press 1 to complete the call, it will ring the phone connected to her OBiTalk device. If you press 2, however, you’ll be able to make an outgoing call from her device. So you would press **8 (to access her landline) and then the number for her cell phone. On her end, all she has to do is plug her phone into the PHONE port on the device, then use the supplied cord to connect the LINE port of the device to the landline jack. You then set the LINE port as the primary service, so if she just picks up the phone and dials a number without a prefix it will go out the LINE port, but if she dials **9 and your OBiTalk number it goes to you. Of course you can always put your respective OBiTalk numbers (with the **9 prefix) in speed dial slots, so you only need to dial a single digit followed by the # key to call each other. If you do that I’m pretty sure there’s even a way to bypass the built-in menu (so, for example, speed dial 2# would ring her phone connected to the OBiTalk device, while speed dial 3# would ring her cell phone using her landline to complete the call) but I’d have to do some reading tell you how that’s done.

    If you don’t want to spend the $40 for the OBi100 and your computer is running Windows, you could run the OBiAPP software and use a softphone on your computer. It would be similar to the way you now use Skype, but it would not be Skype. Personally I’d recommend spending the extra $40 or $50 (for an OBi100 or OBi110) because your calls will be a lot clearer, and because your computer doesn’t need to be on for you to use it. Keep in mind that nothing is stopping you from continuing to use Skype for those long video chats, but when you want to get a quick message to the other person, nothing beats just being able to pick up a phone and dial a number.

    If there’s anything I have said about the way this would operate that you don’t like or think she wouldn’t like (other than the need for her to have an OBi110) there’s probably a way around it. These devices are so flexible that you can configure them just about any way you want to.(including tricks to reduce the number of digits you’d have to dial, or avoid interacting with the menu). And of course you could also add a Google Voice account so you get free calling in the U.S. and Canada, and she could use the menu on your device and then dial **1 or **2 (depending on which service provider slot you use) and make Google Voice calls through your device (she could also try connecting to Google Voice directly, but you should set up the account for her from within the U.S.A. before shipping the device to her. The problem is that I’ve heard some reports that Google Voice tracks the location of the originating IP address, and if a call originates outside the U.S. or Canada the will charge something like a penny a minute, but that charge would not apply if her calls were routed through an OBi device in the U.S. The only way to know for sure if that charge would apply is to set it up to use Google Voice directly and then have her make a couple of short test calls, and watch that Google Voice account to see if the balance decreases, or if calls won’t complete because there’s no balance left).

    Another nice thing is that if both devices are on the same account, and you configure them using the OBiTalk portal (which I highly recommend), then if you need to make any changes to her configuration after she receives the device you will very likely be able to do them through the portal (there are only a few settings that can’t be configured using the portal). So now I will give you a recommendation that may seem a bit strange, but I think it’s good advice. If you buy any of these devices, go onto the OBiTalk forum to get help with configuring your device, but beware of the forum’s resident “know-it-all” (you’ll probably figure out who I’m talking about pretty quickly). He sometimes gives great advice, particularly with regard to configuring dial plans, but in other areas he’s full of shit, and nowhere is that more apparent than in his bias against using the OBiTalk portal for configuration. He will tell you very emphatically not to do it, and as I say, on that particular topic he’s full of shit. In your case, where you are sending a device to a remote location far away, to someone that may not be as technically knowledgeable as you are, you want to use the portal so that if you need to make configuration changes (such as dial plan changes) you can do it easily via the portal, without bothering your girlfriend to set up some kind of remote desktop software (which would be about the only other way to do it). There’s no good reason not to use the portal, and no one can understand why he’s so anti-portal, but don’t argue with him about it because he gets really upset when people don’t take his advice. I would say to try to avoid him entirely, but unfortunately that’s nearly impossible in that forum, and he is rather knowledgeable about OBi device dial plans.

    The problem with trying to use Skype for any part of this is that Skype uses a proprietary protocol that doesn’t interface with much of anything else. While it’s remotely possible that a very knowledgeable person could use the “siptosis” software to somehow bridge a Skype account to an Obihai device, almost any other way of doing it will be easier and will probably produce better sound quality. Your real goal is to be able to call her cell phone without spending 11 cents a minute, and using two Obihai devices is by far the simplest way to do that, and using only a single OBi110 (sent to her after you configure it) and the OBiAPP software on your Windows-based computer would probably be the next simplest.

  5. Dave Stuart said

    I have set up the obi110 with Google, pstn, and asterisk extension as per your instructions. Everything works fine, but when there is a voicemail on the asterisk box, there is no indication on the phone attached to the obi110.

    Is there a way to accomplish this?

    thanks

    dave

  6. SILENT said

    Great guide. The info you provided was incredibly valuable. I was able to setup my piaf box and obi110, with google voice on sp1 and a pstn line on sp2. I am trying to take your project further by also implementing tandem transfer function that my pstn line offers but it is driving me nuts trying to figure out how. I utilized a script I googled

    [custom-tandem-transfer]
    exten => _X.,1,Playback(followme/pls-hold-while-try)
    exten => _X.,n,Flash()
    exten => _X.,n,senddtmf(${EXTEN})
    exten => _X.,n,Hangup()

    to try to Flash my incoming pstn line but it would end the program with an error code -1. Later, after about 8 hours of research…., I discovered to my dismay that the Flash cmd only works with Zap lines. I tried every trick I could find from senddtmf with *98 or ## to altering individual parts of the obi110 itself but all to no avail. I am not sure what cmd to replace the Flash() cmd in custom-tandem-transfer and whether the pstn flash function is handled by piaf box or obi110. Any help would be appreciated.

    Another newb question, do you know how to get obi110 syslogs? According to the obi documentation, the sip debug feature needs to be enabled (which I did) but it also mentions some syslog server which I am unable to ascertain the server ip via the auto attendant.

    Once again, great guide.

    Thanks!!!

  7. Dave said

    michigantelephone – this works great but somehow MessageWaiting indicator does not work when there is a voicemail for the extension registered to Asterisk. I suspect its because Asterisk does not know how to send the notification to since its not a “typical” extension. Can you help? Thanks..Dave.

  8. Dave, funny you should ask. I’ve been thinking about this since I already have figured out about half of what you want – see How to divert incoming Google Voice calls from an Obihai VoIP device to an Asterisk server for additional processing (such as Caller ID lookup) Since the extension there is registered in the normal manner (not “piggybacked” on an Asterisk trunk) the MWI should work fine. The problem is that it only sends INCOMING Google Voice calls to the Asterisk server. You can’t use it for outgoing calls.

    I wish I had a better solution that would allow both incoming and outgoing calls. If there were a way to send direct SIP calls to an Obihai device (assuming you know the device’s IP address) without using a Service Provider configuration, then there would be a possibility of making this work both ways.

  9. Dave said

    Awesome. This new solution actually works better for me as I only need one phone that needs access for outgoing via GV. And that phone will be connected to the Phone port on the Obi110. I only want incoming GV calls going into Asterisk for call handling. Thanks for the discovery.

  10. Dave, THE PLOT THICKENS! It turns out you CAN send calls to an Obihai device without using up a Service Provider IF you have the device at a fixed IP address. But it’s a little tricky. You have to have at least one of your Service Providers configured as SIP (which you would if you have made one SP a standard SIP extension off an Asterisk server) and you have to know the X_UserAgentPort for that Service (unless you have changed it, it will be SP1=5060, SP2=5061, etc.) and you also have to make sure you aren’t blocking traffic from your server. Then, let’s say you create a CUSTOM Extension in Asterisk, and make the Dial string something like this:

    sip/number@OBi_ip_address:port

    Now if you try that, chances are that no matter what you use for “number” your phone will ring, because by default X_InboundCallRoute is set to {ph} (or {ph1} and/or {ph2} on an OBi202). BUT let’s say you changed X_InboundCallRoute to this:

    {sp1($2)}

    It would bridge the call to Service Provider 1 (which of course could be Google Voice) and then send the value of $2, which is the “number” part of the dial string to Service Provider 1. I have tested that part and it works (at least with my OBi202)!

    EDIT: Sheesh, I should read my own articles. It would have saved me a lot of useless typing. Anyway, if you extend that trick and do this:

    {>(1xxxxxxxxxx):sp1($2)},{ph}

    On an OBi202 you’d use whatever was originally there after the comma, instead of {ph}.

    Then if you call the original extension it rings, and if you dial the number associated with your Custom Extension it will send the call to whatever number you have specified in the Dial string.

    There should be some way to construct a trunk in Asterisk (either SIP trunk or Custom trunk) that would send the calls to the device. When I figure it out, believe me when I say I’ll write it up if at all humanly possible, but right now I have to take a break for a while! (EDIT: And I did – see How to use the Obihai OBi100, OBi110, or OBi202 VoIP device as a gateway between Asterisk/F—PBX and Google Voice and/or the OBiTALK network (UPDATED))

    NOTE: Particularly if your OBi is not behind a firewall, you may want to restrict access to your Asterisk server, so that not just anybody can send calls to your OBi. Without going into details here, the parameter to use to restrict access is Service Providers | ITSP Profile A|B|C|D SIP (pick the one that corresponds to the port you are using to connect, in other words A for 5060, B for 5061, etc.) and the setting is X_AccessList, which according to the manual is:

    A comma separated list of IP addresses such that the device only accepts SIP requests coming from one of the given addresses. If the list is empty, the device accepts SIP requests from any IP address

  11. Dave, sorry I didn’t see your comment earlier, but you inspired me to get the outgoing portion of this working (How to use the Obihai OBi100, OBi110, or OBi202 VoIP device as a gateway between Asterisk/F—PBX and Google Voice and/or the OBiTALK network (UPDATED)). So you’re the guy who’s to blame for me being hunched over a computer for most of the evening! :) (Just kidding, this is one nut I’ve wanted to crack for a long time).

  12. Dave said

    LOL. Glad to hear I “pushed” you to get this working :) I was about to spend this dreary weekend trying to get outgoing also working since there is nothing much better to do today as its raining. Frankly, this is more of the satisfaction of getting it to work. My Asterisk GV is fortunately still working great for outgoing calls, so I dont have much need to get GV working on the OBi but its nice to know I have options if the other route breaks. Now I wont have anything to do on this dreary weekend… oh well, maybe try to break something else instead! Keep up the great discoveries.

RSS feed for comments on this post

Comments are closed.

Follow

Get every new post delivered to your Inbox.

Join 136 other followers

%d bloggers like this: