Asterisk Server Setup

The Asterisk server requires some customization of the dialplan for OpenAnswer to work correctly. Below is an example of a dialplan for OpenAnswer. Copy and paste the dialplan into /etc/asterisk/extensions_custom.conf

[from-pstn-custom]
exten => s,1,Macro(pre-init-tas-vars)

[previous-ext-did-post-custom]
exten => _X.,n,Noop(No Asterisk Route - Lookup DID in TAS)
exten => _X.,n,GotoIf($["${TASACCT}foo" = "foo"]?notfound)
exten => _X.,n,Noop(Found openanswer Acct ${TASACCT} for DID ${FROM_DID})
exten => _X.,n,Noop(Found openanswer Acct Name ${TASNAME} FOR did ${FROM_DID})
exten => _X.,n,Set(__TASPRIORITY=${ODBC_LOOKUPTASPRIORITY(${TASACCT})})
exten => _X.,n,Noop(Found OA Priority ${TASPRIORITY} FOR did ${FROM_DID})
exten => _X.,n,Set(__FROM_DID=${EXTEN})
exten => _X.,n,Set(CDR(userfield)=${TASACCT})
exten => _X.,n,Gosub(app-blacklist-check,s,1)
exten => _X.,n,ExecIf($[ "${CALLERID(name)}" = "" ] ?Set(CALLERID(name)=${CALLERID(num)}))
exten => _X.,n,Set(__CALLINGPRES_SV=${CALLINGPRES_${CALLINGPRES}})
exten => _X.,n,SetCallerPres(allowed_not_screened)
exten => _X.,n,GotoIf($["${TASPRIORITY}" = "1"]?priorityone)
exten => _X.,n,GotoIf($["${TASPRIORITY}" = "2"]?prioritytwo)
exten => _X.,n,GotoIf($["${TASPRIORITY}" = "3"]?prioritythree)
exten => _X.,n,GotoIf($["${TASPRIORITY}" = "4"]?priorityfour)
exten => _X.,n,GotoIf($["${TASPRIORITY}" = "5"]?priorityfive)
exten => _X.,n,GotoIf($["${TASPRIORITY}" = "6"]?prioritysix)
exten => _X.,n,GotoIf($["${TASPRIORITY}" = "7"]?priorityseven)
exten => _X.,n,GotoIf($["${TASPRIORITY}" = "8"]?priorityeight)
exten => _X.,n,GotoIf($["${TASPRIORITY}" = "9"]?prioritynine)
exten => _X.,n,Goto(ext-queues,999,1)
exten => _X.,n(priorityone),Noop("TAS DID ${EXTEN} for P1 Q991.")
exten => _X.,n,Goto(ext-queues,991,1)
exten => _X.,n(prioritytwo),Noop("TAS DID ${EXTEN} for P2 Q992.")
exten => _X.,n,Goto(ext-queues,992,1)
exten => _X.,n(prioritythree),Noop("TAS DID ${EXTEN} for P3 Q993.")
exten => _X.,n,Goto(ext-queues,993,1)
exten => _X.,n(priorityfour),Noop("TAS DID ${EXTEN} for P4 Q994.")
exten => _X.,n,Goto(ext-queues,994,1)
exten => _X.,n(priorityfive),Noop("TAS DID ${EXTEN} for P5 Q995.")
exten => _X.,n,Goto(ext-queues,995,1)
exten => _X.,n(prioritysix),Noop("TAS DID ${EXTEN} for P6 Q996.")
exten => _X.,n,Goto(ext-queues,996,1)
exten => _X.,n(priorityseven),Noop("TAS DID ${EXTEN} for P7 Q997.")
exten => _X.,n,Goto(ext-queues,997,1)
exten => _X.,n(priorityeight),Noop("TAS DID ${EXTEN} for P8 Q998.")
exten => _X.,n,Goto(ext-queues,998,1)
exten => _X.,n(prioritynine),Noop("TAS DID ${EXTEN} for P9 Q999.")
exten => _X.,n,Goto(ext-queues,999,1)
exten => _X.,n(notfound),Noop("TAS DID ${EXTEN} not found.")

[from-internal-custom]
exten => 555,1,Macro(user-callerid)
exten => 555,2,Authenticate(1234)
exten => 555,3,Read(QVSPYNUM,agent-newlocation)
exten => 555,4,Macro(qview-supervise)
exten => 555,n,Hangup
exten => 556,1,NoOp(Qview Supervise Request)
exten => 556,2,NoOp(${QVSPYNUM})
exten => 556,3,Macro(user-callerid)
exten => 556,4,GotoIf($[{$QVSPYNUM}]?5:6)
exten => 900,1,NoOp(Agent Callback Login from ${CALLERIDNUM})
exten => 900,2,AgentCallbackLogin(,,${CALLERIDNUM}@ext-local)
exten => 900,3,Hangup

[qvapps]
exten => 556,1,NoOp(Qview Supervise Request)
exten => 556,2,NoOp(${QVSPYNUM})
exten => 556,3,Macro(user-callerid)
exten => 556,4,GotoIf($[{$QVSPYNUM}]?5:6)
exten => 556,5,Macro(qview-supervise)
exten => 556,6,NoOp(supervise done)
exten => 556,7,Hangup

[qvredirect]
exten => _X.,1,Set(MIXMONITOR_FILENAME=${EXTEN}-${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${UNIQUEID})
exten => _X.,n,NoOp(QVRedirect to ${EXTEN} and record to ${MIXMONITOR_FILENAME} call from ${CALLERID(num)})
exten => _X.,n,ResetCDR(w)
exten => _X.,n,ExecIf($["${CDR(oc_uniqueid)}foo" = "foo"]?Set(CDR(oc_uniqueid)=${OCUNIQUEID}))
exten => _X.,n,Dial(Local/${EXTEN}@qvredirect-txfr/n)
exten => _X.,n,Goto(ext-queues,998,1)
exten => h,1,Macro(hangupcall)

[qvredirect-txfr]
exten => _X.,n,ExecIf($["${CDR(oc_uniqueid)}foo" = "foo"]?Set(CDR(oc_uniqueid)=${OCUNIQUEID}))
exten => _X.,1,Goto(default,${EXTEN},1)

[macro-qview-supervise]
exten => s,1,ChanSpy(SIP/${QVSPYNUM))

[qvmusiconhold]
exten => _X.,1,Answer
exten => _X.,n,ExecIf($["${CDR(oc_uniqueid)}foo" = "foo"]?Set(CDR(oc_uniqueid)=${OCUNIQUEID}))
exten => _X.,n,StartMusicOnHold()
exten => _X.,n,Wait(3600)
exten => _X.,n,Hangup
exten => i,1,Answer
exten => i,n,MusicOnHold()

[qvpark]
exten => h,1,Hangup
exten => _X.,1,Answer
exten => _X.,n,ExecIf($["${CDR(oc_uniqueid)}foo" = "foo"]?Set(CDR(oc_uniqueid)=${OCUNIQUEID}))
exten => _X.,n,Wait(1)
exten => _X.,n,ParkAndAnnounce(,,,ext-local,${QVPARKEDBY},1)
exten => i,1,Answer
exten => i,n,Wait(1)
exten => i,n,ParkAndAnnounce(,,,ext-local,${QVPARKEDBY},1)

[qvmeetme]
exten => h,1,StopMixMonitor()
exten => h,n,Macro(hangupcall)
exten => _X.,1,Answer
exten => _X.,n,NoOp(QVMeetme Bridge ${EXTEN})
exten => _X.,n,ExecIf($["${FROM_ACCT}foo" != "foo"]?Set(CDR(userfield)=${FROM_ACCT}))
exten => _X.,n,ExecIf($["${CDR(oc_uniqueid)}foo" = "foo"]?Set(CDR(oc_uniqueid)=${OCUNIQUEID}))
exten => _X.,n,StopMixMonitor()
exten => _X.,n,SetAMAFlags(billing)
exten => _X.,n,Wait(1)
exten => _X.,n,GotoIf($["${FROM_TASAGENT}foo" != "foo"]?from_tasagent)
exten => _X.,n,MeetMe(${EXTEN},1dFqAx)
exten => _X.,n,MeetMeAdmin(${EXTEN},K)
exten => _X.,n,Hangup
exten => _X.,n,Return()
exten => _X.,n(from_tasagent),Noop("MEETME SETUP FROM AGENT ${FROM_TASAGENT} for ${FROM_DID}")
exten => _X.,n,MeetMe(${EXTEN},1dFqAx)
exten => _X.,n,MeetMeAdmin(${EXTEN},K)
exten => _X.,n,Hangup
exten => _X.,n,Return()

[qvpickup]
exten => h,1,StopMixMonitor()
exten => h,n,Macro(hangupcall)
exten => _X.,1,Answer
exten => _X.,n,NoOp(QVPickup Bridge ${EXTEN})
exten => _X.,n,ExecIf($["${FROM_ACCT}foo" != "foo"]?Set(CDR(userfield)=${FROM_ACCT}))
exten => _X.,n,ExecIf($["${CDR(oc_uniqueid)}foo" = "foo"]?Set(CDR(oc_uniqueid)=${OCUNIQUEID}))
exten => _X.,n,Wait(1)
exten => _X.,n,SetAMAFlags(billing)
exten => _X.,n,MeetMe(${EXTEN},1dFqx)
exten => _X.,n,Hangup

[qvcallpickup]
exten => h,1,StopMixMonitor()
exten => h,n,Macro(hangupcall)
exten => _X.,1,Answer
exten => _X.,n,NoOp(QVCallPickup Bridge ${EXTEN} for ${FROM_TASAGENT})
exten => _X.,n,ExecIf($["${FROM_ACCT}foo" != "foo"]?Set(__TASACCT=${FROM_ACCT}))
exten => _X.,n,ExecIf($["${CDR(oc_uniqueid)}foo" = "foo"]?Set(CDR(oc_uniqueid)=${OCUNIQUEID}))
exten => _X.,n,ExecIf($["${FROM_DID}foo" != "foo"]?Set(CDR(accountcode)=${FROM_DID}))
exten => _X.,n,ExecIf($["${TASACCT}foo" != "foo"]?Set(CDR(userfield)=${TASACCT}))
exten => _X.,n,Set(CDR(agent)=${FROM_TASAGENT}) 
exten => _X.,n,MeetMe(${EXTEN},1dFqx)
exten => _X.,n,Hangup

[qvremoteagent]
exten => h,1,Hangup
exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n,Authenticate(5089)
exten => s,n,NoOp(QV Remote Agent Login from ${CALLERIDNUM})
exten => s,n,Wait(1)
exten => s,n,AgentLogin()
exten => s,n,Hangup
exten => _X.,1,Answer
exten => _X.,n,Wait(1)
exten => _x.,n,Authenticate(5089)
exten => _X.,n,NoOp(QV Remote Agent Login from ${CALLERIDNUM})
exten => _X.,n,Wait(1)
exten => _X.,n,AgentLogin()
exten => _X.,n,Hangup

[qvdummy]
exten => _X.,1,NoCDR()
exten => _X.,n,Answer()
exten => _X.,n,Wait(30)
exten => _X.,n,Hangup
exten => h,1,Hangup

[pause-queue-from-internal]
exten => _X.,1,PauseQueueMember(,SIP/${EXTEN})
exten => _X.,n,Goto(from-internal,${EXTEN},1)

[unpause-queue-from-openanswer]
exten => _X.,1,UnPauseQueueMember(,SIP/${FROM_TASAGENT})
exten => _X.,n,Goto(from-openanswer,${EXTEN},1)

[from-openanswer]
exten => h,1,StopMixMonitor()
exten => h,n,Macro(hangupcall)
exten => _X.,1,ExecIf($["${REALCALLERIDNUM}foo" != "foo"]?Set(__KEEPCID=TRUE))
exten => _X.,n,ExecIf($["${FROM_DID}foo" = "foo"]?Set(__FROM_DID=${REALCALLERIDNUM}))
exten => _X.,n,ExecIf($["${TASACCT}foo" = "foo"]?Gosub(app-prep-tas-vars,s,1))
exten => _X.,n,ExecIf($["${FROM_DID}foo" != "foo"]?Set(CDR(accountcode)=${FROM_DID}))
exten => _X.,n,ExecIf($["${TASACCT}foo" = "foo"]?Set(__TASACCT=${FROM_ACCT}))
exten => _X.,n,ExecIf($["${TASACCT}foo" != "foo"]?Set(CDR(userfield)=${TASACCT}))
exten => _X.,n,ExecIf($["${CDR(oc_uniqueid)}foo" = "foo"]?Set(CDR(oc_uniqueid)=${OCUNIQUEID}))
exten => _X.,n,ExecIf($["${REALCALLERIDNUM}foo" != "foo"]?Set(__OUTCID_2=${REALCALLERIDNUM}))
exten => _X.,n,Set(CDR(agent)=${FROM_TASAGENT})
exten => _X.,n,Set(MIXMONITOR_FILENAME=OUT${FROM_TASAGENT}-${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${UNIQUEID})
exten => _X.,n,Goto(from-internal,${EXTEN},1)

[app-prep-tas-vars]
exten => s,1,NoOp(In app-prep-tas-vars)
exten => s,n,Set(__TASACCT=)
exten => s,n,Set(__TASACCT=${ODBC_LOOKUPTASDID(${FROM_DID})})
exten => s,n,ExecIf($["${FROM_ACCT}foo" != "foo"]?Set(__TASACCT=${FROM_ACCT}))
exten => s,n,ExecIf($["${TASACCT}foo" != "foo"]?Set(__TASNAME=${ODBC_LOOKUPTASNAME(${TASACCT})}-))
exten => s,n,ExecIf($["${TASACCT}foo" != "foo"]?Set(CDR(userfield)=${TASACCT}))
exten => s,n,Return()

[app-check-tas-loop]
exten => s,1,Set(__TASLOOP=)
exten => s,n,ExecIf($["${CALLERID(num)}foo" != "foo"]?Set(__TASLOOP=${ODBC_LOOKUPTASDID(${CALLERID(num)})}))
exten => s,n,ExecIf($["${TASLOOP}foo" != "foo"]?Set(__TASNAME=*TASLOOP*-${TASNAME}))
exten => s,n,Return()

[macro-check-meetme-recording]
exten => h,1,MacroExit
exten => h,n,Set(MEETME_RECORDINGFILE=)
exten => h,n,MacroExit
exten => s,1,MacroExit
exten => s,n,Set(MEETME_RECORDINGFILE=)
exten => s,n,MacroExit

[macro-pre-init-tas-vars]
exten => s,1,Set(__FROM_DID=${MACRO_EXTEN})
exten => s,n,Set(CALLINGPRES=0)
exten => s,n,ExecIf($[ "${CHANNEL:0:5}" = "DAHDI" ]?Wait(1))
exten => s,n,Set(CDR(accountcode)=${MACRO_EXTEN})
exten => s,n,Set(CDR(oc_uniqueid)=${UNIQUEID})
exten => s,n,Set(__OCUNIQUEID=${UNIQUEID})
exten => s,n,ExecIf($[${LEN(${MACRO_EXTEN})}>9]?Gosub(app-prep-tas-vars,s,1))
exten => s,n,ExecIf($[${LEN(${MACRO_EXTEN})}>9]?Gosub(app-check-tas-loop,s,1))
exten => s,n,Set(__CALLINGCHANNEL=${CHANNEL})

 

Additional Asterisk Setup

 

The setup assumes that the user has setup the necessary queues and extensions for the calls to be routed properly to the agents

Parking a call in OpenQView requires that a 'Park Queue' is created in FreePbx. By default OpenConnector expects the park queue to be Queue 998. Modify the' asterisk_park_queue' setting in OpenConnector's settings.js file.

 

Setting up an OAUser in MySQL

You will need to setup a mysql user for OpenAnswer to connect to the asterisk Database:

Make sure to change the password and if you're OpenAnswer is running on top of your FreePBX install you can change 'oauser'@'%' to 'oauser'@'localhost' or if it's running on a separate server 'oauser'@'xxx.xxx.xxx.xxx'

mysql -uroot -p
CREATE USER 'oauser'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON asterisk.* TO 'oauser'@'%';
FLUSH PRIVILEGES
EXIT

 
/etc/asterisk/manager.conf

Go ahead and add the following under the [admin] section

[oa-admin] secret = Password deny=0.0.0.0/0.0.0.0 permit=127.0.0.1/255.255.255.0 read = system,call,log,verbose,command,agent,user,all write = system,call,log,verbose,command,agent,user,al