Saturday, October 27, 2007

Enabling outbound calls from Exchange UM (OVA) to the PSTN using Asterisk

One of the great features of Outlook Voice Access is the ability to lookup a person in the directory or your personal contacts list and have OVA connect you to that person. This obviously requires support some form of connection to the PSTN. The guide will take you through the steps of configuring the systems to allow OVA to make calls to the PSTN.

A big thanks to Sander de Rijk who provided the basis of these instructions earlier this year.

This guide assumes you have configured Asterisk to connect to your PSTN provider. If not, see my earlier post, then come back when your done.

The first thing you need to do is decide if you want to configure an 'outside line' access code. The most common numbers used for access to the trunk are 0 and 9. However, its becoming increasingly popular not to use such a code, and configure appropriate rules in the various dial plans instead. The following instructions will be based on NOT using a trunk access code, but adding this functionality is very straightforward.

Open the Exchange Management Console, and in the left hand pane, select Organization Configuration, Unified Messaging. Right click on your dial plan, and select Properties. On the Dial Codes tab, enter the dial codes relevant to your location. This can be a little confusing, but the Help button will reveal some information that can guide you through this process. Note that all this information is optional, and if you are only have one dial plan, and are going to making calls within our country/region, you can leave all the fields on this tab blank.

image

Next, click on the Dialing Rule Groups tab, and add a new In-Country/Region Rule. Give your rule a name, and enter a number mask. In my example below, I take a local 8 digit phone number, and add my state's extension (03) to it.

image

If I have a number in my contacts or directory that contains the country code (61 for Australia), this rule will remove it, and replace it with a 0 which is used for In-Country dialing.

image

Continue adding rules for your numbers as required, unfortunately I can't include all the various country and region codes in this guide, but I'm sure you will work them out without too much trouble. Once completed, you should have a list similar to that below.

image

That completes the Exchange portion of this configuration. Now we need to configure the appropriate rules on the sipX server. Visit the sipXconfig web site, and open the Asterisk dial plan (System->Dial plans->AsteriskDialPlan). Add the dial rules required for your area. If you configured an outside line access number, then you can simply enter that number as the prefix, and select "Any number of digits" from the drop down list.

image

Save the dial plan, and click Activate above the list of dial plans. Finally, we need to configure the route in Asterisk to send these calls through our PSTN provider. Visit the asterisk configuration page, and from within FreePBX, select Outbound Routes from the left menu. If you have already configured a route to the PSTN, then use that, otherwise add a new route. Add your dial patterns, and select the trunk you configured for your PSTN provider, and save.

image

Note that I have used different dial patterns on the sipX and Asterisk server. This is just to demonstrate the various ways you can go about configuring these systems. Both sets of rules work and are valid. You can choose less specific rules to make administration easier, or you might need more control over where your calls go (i.e certain calls need to be routed over a specific trunk). All are valid - adjust as needed for your requirements.

Apply your changes to the server, and you are done!

4 comments :

chad.harmon@hotmail.com said...

The guide you have is wonderful and our system could never have reached the point it is without it. I am stuck on a problem with exchange transfering a call back through asterisk to another SIP phone. Here is the situation. I can call from my softphone through Asterisk, across sipx into Exchange UM. I can have Exchange read me my email. When I try to use the option of calling the sender of the email I get a message from Exchange "Sorry, the sender could not be called at this time."

I have sniffed the messages and can see Exchange talking to SipX and SipX talking to Asterisk to handle the transfer. I can see Asterisk giving a reply to SipX "SIP: Status: 404 Not Found" by sniffing the traffic.

At the console of the Asterisk box I can see the following message:
Nov 27 14:03:41 DEBUG [790]: chan_sip.c:11172 sipsock_read: SIP message could not be handled, bad request: 3a8f3a4e688f81625clb5a815a9bc6a8@xxx.xxx.xxx.xxx

xxx.xxx.xxx.xxx is the IP address of the Asterisk box.

I can setup a softphone on the SipX box and use it to call other SIP phones on the Asterisk box, so I know SipX and Asterisk are properly communicating, at least on some level.

I am guessing there is a configuration problem in the extensions.conf on asterisk, but I'm not sure where to start with resolving this.

Ryan Newington said...

Hi Chad,

Have you seen this post http://blog.lithiumblue.com/2007/10/asterisksipx-bugs-and-modifications-for.html

Try the modifications required for play-on-phone and see if that resolves the problem

Cheers

ryan

dbakker said...

I had to change the to insecure line to insecure=port,invite . SipX uses random ports which asterisk doesnt like. the port option tells asterisk to ignore this. The problem I have is inbound calling is great, outbound from sipx to asterisk to the outside is greate. ocs -> sipx -> asterisk -> outside is not so great. I can hear the ocs's client voice but I cannot hear anything from the user I called. Also when the user hangs up OCS never sees this.

Any ideas?

Mitch said...

Hello Ryan,
Very well done and thank you for documenting and sharing the result of your countless hours work.

It took me a little while to get outbound calls from Exchange(OVA) to PSTN to work because there is an additional tab in the Exchange Dial Plan Properties. I assume as part of Exch SP1 there is now a "Dialing Rule Restrictions" tab in addition to the "Dialing Rule Groups." The "Restrictions" tab also appears in the UM Mailbox Policy AND the UM Autoattendant.

My configuration:
I am in a part of the US where we have to dial 10 digits for all calls and it does not matter if there is a "1" prefix, so our dialing rules are pretty simple.
I created (2) dialing Rule Groups;
10-Digit xxxxxxxxxx xxxxxxxxxx
1+10-Digit 1xxxxxxxxxx xxxxxxxxxx
The second one is not really necessary because all of the my Outlook contact numbers are already 10 digits, but it was useful for proving the process.

This alone still did not allow me to dial out through Exchange though, it wasn't 'till I started toying with the "Restrictions" tabs that I got results. Through trial & error, I found that you have to add the "Dialing Rule Groups" created in the Dial Plan to the the Mailbox Policy. I added only the 10-Digit Rule to my policy, added a 1 to the Home number in my contact and sure enough, was only able to access the Cell number for that contact. Removed the 1 and was then able to get to both cell and home. Very nice.

For the sake of thouroghness, I add the 10-digit rule to the autoattendant and was then able to have the autoattendant dial home and cell numbers for users in my Directory. Could be dangerous, but still very cool! Changing the restrictions tab in the Dial Plan seems to have no affect, so I'm not sure why they put it in there.

Keep up the good work and Thanks Again.