[Solved]Calling out-Multiple Carriers/Trunks

Any and all non-support discussions

Moderators: gerski, enjay, williamconley, Op3r, Staydog, gardo, mflorell, MJCoate, mcargile, Kumba, Michael_N

[Solved]Calling out-Multiple Carriers/Trunks

Postby bmxmike » Tue Jan 10, 2017 12:19 pm

Edited*: So I think my original questions and title were a little confusing so editing to see if someone may understand better and make alil more sense.

So I have 1 carrier that has multiple IP's for Inbound, Outbound, and Dialer. The IP's consist of: 1)Default 2)Backup 3)Disaster 4)Disaster Backup. In Elastix/Freepbx you create a route plan that would go through and try each trunk/carrier until successful, Is it possible to do this in Vicidial (I know it possible in Asterisk) without messing up reporting or anything else? If so what's the best way to do this, manually editing the dialplan with a text editior, editing the dialplan of my default trunk to have it try the other carriers if it responds busy or some other error?

Below is an example of our default out route, from Elastix, that uses the agents default CID for outbound calls. User presses 9 and then it try's our default ip, if that fails it then tries the next trunk/carrier, if that fails it keeps going until it reaches the end of the list and then spits out and error.

Code: Select all
[outrt-1] ; Normal OutBound
include => outrt-1-custom
exten => _9[1]NXXNXXXXXX,1,Macro(user-callerid,LIMIT,EXTERNAL,)
exten => _9[1]NXXNXXXXXX,n,Gosub(sub-record-check,s,1(out,${EXTEN},dontcare))
exten => _9[1]NXXNXXXXXX,n,ExecIf($[ "${CALLEE_ACCOUNCODE}" != "" ] ?Set(CDR(accountcode)=${CALLEE_ACCOUNCODE}))
exten => _9[1]NXXNXXXXXX,n,Set(MOHCLASS=${IF($["${MOHCLASS}"=""]?default:${MOHCLASS})})
exten => _9[1]NXXNXXXXXX,n,Set(_NODEST=)
exten => _9[1]NXXNXXXXXX,n,Macro(dialout-trunk,4,${EXTEN:1},,on)
exten => _9[1]NXXNXXXXXX,n,Macro(dialout-trunk,1,${EXTEN:1},,on)
exten => _9[1]NXXNXXXXXX,n,Macro(dialout-trunk,3,${EXTEN:1},,on)
exten => _9[1]NXXNXXXXXX,n,Macro(dialout-trunk,2,${EXTEN:1},,on)
exten => _9[1]NXXNXXXXXX,n,Macro(dialout-trunk,5,${EXTEN:1},,on)
exten => _9[1]NXXNXXXXXX,n,Macro(dialout-trunk,6,${EXTEN:1},,on)
exten => _9[1]NXXNXXXXXX,n,Macro(dialout-trunk,7,${EXTEN:1},,on)
exten => _9[1]NXXNXXXXXX,n,Macro(dialout-trunk,8,${EXTEN:1},,on)
exten => _9[1]NXXNXXXXXX,n,Macro(dialout-trunk,9,${EXTEN:1},,on)
exten => _9[1]NXXNXXXXXX,n,Macro(outisbusy,)



The macro takes an ID which is associated to a trunk and then tries to call out using that specific trunk. It then checks for the dial status and hang up cause and if it the call fails it breaks out and tries the next trunk.

I guess my biggest question is if I go in and edit the dialplan to do this, am I going to see any issues on my outbound reporting where I may see multiple calls around the same time using multiple trunks or any other unwanted effects?

Being a noob to vicidial want to make sure I'm not going about it in the wrong way or if I'm possibly breaking something else by doing this


Asterisk Version: Asterisk 11.25.1-vici
VERSION: 2.14-583a
BUILD: 161226-2224
Last edited by bmxmike on Thu Jan 12, 2017 3:27 pm, edited 1 time in total.
bmxmike
 
Posts: 24
Joined: Sun Jan 01, 2017 6:54 pm

Re: Calling out- Trying multiple IP's till succesfully

Postby bmxmike » Thu Jan 12, 2017 3:18 pm

So I solved it myself finally with the following:

I did all of the following in extensions.conf vs Carrier Settings for 1 main reason; I had originally added this to 1 single carrier to handle for all of them, but if for some reason that carrier got set to Active:N the dial plan would of been lost and nothing would have called out. Adding to the extensions.conf, even if the carrier gets disabled it will just tell you that the it can't find the carrier and move on.

1) Remove Global's and Dialplan enteries for each carrier, you should only have carrier_id, name, description, and account entry. I'm IP authenticated so no registration string.

2)Added the following to my extensions.conf
*At the top I added the following:
Code: Select all
[globals]
TERM_PROVIDER1=SIP/vi-out1
TERM_PROVIDER2=SIP/vi-out2
TERM_PROVIDER3=SIP/vi-disaster1
TERM_PROVIDER4=SIP/vi-disaster2
TERM_PROVIDER5=SIP/vi-in1
TERM_PROVIDER6=SIP/vi-in2
TERM_PROVIDER7=SIP/vi-in3
MAX_PROVIDERS=7


Instead of assigning the globals in the carrier settings I have added it to the extension.conf, you also need to add MAX_PROVIDERS=X which is the number of providers your using so it knows you have gone through the list. Make sure to use your providers.

*Add this somewhere in your extensions.conf, I added this under the dialing examples:
Code: Select all
;Normal Outbound Dialing, Dial with 1 and Area Code
exten => _9[1]NXXNXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)
exten => _9[1]NXXNXXXXXX,2,Macro(direct-dial,${EXTEN:1})
exten => _9[1]NXXNXXXXXX,3,Hangup()
;Normal Outbound Dialing, Dial with Area Code
exten => _9NXXNXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)
exten => _9NXXNXXXXXX,2,Macro(direct-dial,1${EXTEN:1})
exten => _9NXXNXXXXXX,3,Hangup()
;Normal Outbound Dialing, Local Dialing
exten => _9NXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)
exten => _9NXXXXXX,2,Macro(direct-dial,1405${EXTEN:1})
exten => _9NXXXXXX,3,Hangup()

Here you set your dial pattern/plan like you would in the carrier settings; Call the AGI, then we call the macro which is next and then hangup.

*Now add this to the end of the file, This is the macro that does everything:
Code: Select all
[macro-direct-dial]
exten => s,1,Set(CALL_ATTEMPT=1)
exten => s,2,Set(TERM_PROVIDER=${TERM_PROVIDER1})
exten => s,3,Dial(${TERM_PROVIDER}/${ARG1},60)
exten => s,4,GotoIf($["${CALL_ATTEMPT}" >= "${MAX_PROVIDERS}"]?s-CANCEL,1)
exten => s,5,Set(CALL_ATTEMPT=$[${CALL_ATTEMPT} + 1])
exten => s,6,Goto(s-${DIALSTATUS},1)

exten => s-BUSY,1,Noop()
exten => s-NOANSWER,1,Noop()
exten => s-CANCEL,1,Hangup()
exten => s-HANGUP,1,Hangup()

exten => s-CHANUNAVAIL,1,Set(TERM_PROVIDER=${EVAL(${TERM_PROVIDER${CALL_ATTEMPT}})})
exten => s-CHANUNAVAIL,2,Goto(s,3)

exten => s-CONGESTION,1,Set(TERM_PROVIDER=${EVAL(${TERM_PROVIDER${CALL_ATTEMPT}})})
exten => s-CONGESTION,2,Goto(s,3)


The macro sets the attempt to 1 to start at the first entry and then runs through all providers till it hits the MAX_PROVIDERS or the call goes through.

Please chime in if you see anything that might cause problems, seems to be working great for this noob
bmxmike
 
Posts: 24
Joined: Sun Jan 01, 2017 6:54 pm

Re: [Solved]Calling out-Multiple Carriers/Trunks

Postby williamconley » Sat Jan 14, 2017 9:38 pm

NEVER edit your extensions.conf. You'll smack yourself in the back of the head the day you upgrade and forget to bring along the changes (and spend two hours trying to figure out what happened). Alternately, you could *not* install sample conf files during upgrade, but then you may not get required new lines in those files.

Solutions: Add a special carrier that has these entries that's not a real carrier at all, just to hold these entries. Also, this does not require a linux cli login for viewing or add/remove operations. This allows for SIP.conf entries as well as extensions.conf entries.

Extensions.conf entries can also be added in admin -> system settings (Custom Dialplan Entry) which requires "Allow Custom Dialplan Entries=1". This has the added advantage of adding to all servers at the same time, not to mention being "upgrade proof".
Vicidial Installation and Repair, plus Hosting and Colocation
Newest Product: Vicidial Agent Only Beep - Beta
http://www.PoundTeam.com # 352-269-0000 # +44(203) 769-2294
williamconley
 
Posts: 20018
Joined: Wed Oct 31, 2007 4:17 pm
Location: Davenport, FL (By Disney!)


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 56 guests