Office Code routing is in early stage beta. These will be refined over time especially as we add more features such as call ticketing.

This page provides details on how to connect your Asterisk PBX to PhoneNet when you have an IAX (ENUM) routed Office Code.

These instructions should be adapted to your environment.

We are still working on the guide for FreePBX and this will be added soon.

The following files will need to be modified.

iax.conf

In this file you will need to define a user. This is used to receive calls from PhoneNet and route them to the correct context. Replace the secret with the value you selected when submitting your request:

[from-phonenet]
type=user
username=from-phonenet
secret=<x>
auth=md5
encryption=yes
context=from-phonenet
CODE

extensions.conf

In your extensions.conf file under the [globals] stanza (or globals_custom.conf on FreePBX) you will need to add the following line with the PhoneNet key you have been assigned. The PhoneNet key is not in use yet but will be used with the PhoneNet API for call verification, ticketing, and other services once launched.

phonenetkey=<value>
CODE

You will also need to add the following stanzas either in extensions.conf (Asterisk) or extensions_custom.conf (FreePBX). You may also choose to put this in a separate PhoneNet specific file and include that file in your extensions.conf.

The following stanza is used for routing calls to PhoneNet. It will perform the ENUM lookup and route the call to the destination that is returned. PhoneNet also provides intercept services so an invalid number but there are intercepts listed in this example in the event a node is returned but either does not respond or rejects the call.

[to-phonenet]

exten => _NXXXXXX,1,NoOp
  same => n,Set(CONNECTEDLINE(name,i)=PhoneNet ${EXTEN})
  same => n,Set(CONNECTEDLINE(number,i)=${EXTEN})
  same => n,Set(CONNECTEDLINE(pres)=allowed)
  same => n,Progress()
  same => n,Set(enumresult=${ENUMLOOKUP(${EXTEN:0},iax,,,enum.phonenet.au)})
  same => n,GotoIf($["${enumresult}" != ""]?dial:invalid)
  same => n(dial),Dial(IAX2/${enumresult})
  same => n,Playback(all-circuits-busy-now,noanswer)
  same => n,Hangup(34)
  same => n(invalid),Playback(discon-or-out-of-service,noanswer)
  same => n,Hangup(1)
CODE

Your local user dialplan should route calls to this context. You could for example have an internal prefix that is used to access PhoneNet (such as 95) and strip off that prefix. For example:

exten => _95NXXXXXX,1,Goto(to-phonenet,${EXTEN:2},1)
CODE

You will also need a stanza to receive calls from PhoneNet. This should contain your local exchanges.

The following example would route calls received to 791XXXX to a local 4 digit extension:

[from-phonenet]
exten => _791XXXX,1,NoOp("PhoneNet Inbound for ${EXTEN}")
 same => n,Goto(from-internal,${EXTEN:3},1)
CODE

If you have issues getting connected you may log a support request or ask for help in the #phonenet-help channel in our Discord server.