Ok so here is what I set up, it is for many different trunks to load balance and then fail over. I have it set up this way because, each "trunk" is only one line, and the carrier identifies each line with a specific callerid, So I set up one carrier (trunk1) and just had to change the callerid for each "line" and if that line is not available because I am only allowed 1 to 1 then it will continue to go down the list till it finds a line available or hits the fail over line. Hope this helps someone.
exten => _9X.,1,AGI(
agi://127.0.0.1:4577/call_log)
exten => _9X.,2,NoOp(LB IS ${lb_trunk})
exten => _9X.,3,GotoIf($[${lb_trunk} != 1]?20)
exten => _9X.,4,Set(GLOBAL(lb_trunk)=2)
exten => _9X.,5,Set(CALLERID(num)=9166742654)
exten => _9X.,6,Dial(${trunk1}/${EXTEN:2},,tTor)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?20)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?20)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?20)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CANCEL"]?20)
exten => _9X.,20,GotoIf($[${lb_trunk} != 2]?30)
exten => _9X.,21,Set(GLOBAL(lb_trunk)=3)
exten => _9X.,22,Set(CALLERID(num)=9166742136)
exten => _9X.,23,Dial(${trunk1}/${EXTEN:2},,tTor)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?30)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?30)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?30)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CANCEL"]?30)
exten => _9X.,30,GotoIf($[${lb_trunk} != 3]?40)
exten => _9X.,31,Set(GLOBAL(lb_trunk)=4)
exten => _9X.,32,Set(CALLERID(num)=9166235416)
exten => _9X.,33,Dial(${trunk1}/${EXTEN:2},,tTor)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?40)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?40)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?40)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CANCEL"]?40)
exten => _9X.,40,GotoIf($[${lb_trunk} != 4]?50)
exten => _9X.,41,Set(GLOBAL(lb_trunk)=5)
exten => _9X.,42,Set(CALLERID(num)=9162377290)
exten => _9X.,43,Dial(${trunk1}/${EXTEN:2},,tTor)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?50)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?50)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?50)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CANCEL"]?50)
exten => _9X.,50,GotoIf($[${lb_trunk} != 5]?60)
exten => _9X.,51,Set(GLOBAL(lb_trunk)=6)
exten => _9X.,52,Set(CALLERID(num)=9166742362)
exten => _9X.,53,Dial(${trunk1}/${EXTEN:2},,tTor)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?60)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?60)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?60)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CANCEL"]?60)
exten => _9X.,60,GotoIf($[${lb_trunk} != 6]?70)
exten => _9X.,61,Set(GLOBAL(lb_trunk)=7)
exten => _9X.,62,Set(CALLERID(num)=9166294389)
exten => _9X.,63,Dial(${trunk1}/${EXTEN:2},,tTor)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?70)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?70)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?70)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CANCEL"]?70)
exten => _9X.,70,GotoIf($[${lb_trunk} != 7]?80)
exten => _9X.,71,Set(GLOBAL(lb_trunk)=8)
exten => _9X.,72,Set(CALLERID(num)=9166742336)
exten => _9X.,73,Dial(${trunk1}/${EXTEN:2},,tTor)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?80)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?80)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?80)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CANCEL"]?80)
exten => _9X.,80,GotoIf($[${lb_trunk} != 8]?90)
exten => _9X.,81,Set(GLOBAL(lb_trunk)=9)
exten => _9X.,82,Set(CALLERID(num)=9162593815)
exten => _9X.,83,Dial(${trunk1}/${EXTEN:2},,tTor)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?90)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?90)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?90)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CANCEL"]?90)
exten => _9X.,90,GotoIf($[${lb_trunk} != 9]?100)
exten => _9X.,91,Set(GLOBAL(lb_trunk)=10)
exten => _9X.,92,Set(CALLERID(num)=9162519152)
exten => _9X.,93,Dial(${trunk1}/${EXTEN:2},,tTor)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?100)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?100)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?100)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CANCEL"]?100)
exten => _9X.,100,GotoIf($[${lb_trunk} != 10]?110)
exten => _9X.,101,Set(GLOBAL(lb_trunk)=11)
exten => _9X.,102,Set(CALLERID(num)=9165728490)
exten => _9X.,103,Dial(${trunk1}/${EXTEN:2},,tTor)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?110)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?110)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?110)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CANCEL"]?110)
exten => _9X.,110,GotoIf($[${lb_trunk} != 11]?120)
exten => _9X.,111,Set(GLOBAL(lb_trunk)=12)
exten => _9X.,112,Set(CALLERID(num)=9166742193)
exten => _9X.,113,Dial(${trunk1}/${EXTEN:2},,tTor)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?120)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?120)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?120)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CANCEL"]?120)
exten => _9X.,120,GotoIf($[${lb_trunk} != 12]?130)
exten => _9X.,121,Set(GLOBAL(lb_trunk)=13)
exten => _9X.,122,Set(CALLERID(num)=9162413391)
exten => _9X.,123,Dial(${trunk1}/${EXTEN:2},,tTor)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?130)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?130)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?130)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CANCEL"]?130)
exten => _9X.,130,GotoIf($[${lb_trunk} != 13]?140)
exten => _9X.,131,Set(GLOBAL(lb_trunk)=14)
exten => _9X.,132,Set(CALLERID(num)=9162519145)
exten => _9X.,133,Dial(${trunk1}/${EXTEN:2},,tTor)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?140)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?140)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?140)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CANCEL"]?140)
exten => _9X.,140,GotoIf($[${lb_trunk} != 14]?150)
exten => _9X.,141,Set(GLOBAL(lb_trunk)=15)
exten => _9X.,142,Set(CALLERID(num)=9165838704)
exten => _9X.,143,Dial(${trunk1}/${EXTEN:2},,tTor)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?fail)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?fail)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?fail)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CANCEL"]?fail)
exten => _9X.,n(fail),Dial(${trunk2}/${EXTEN:1},,tTor)
exten => _9X.,150,GotoIf($[${lb_trunk} != 15]?160)
exten => _9X.,151,Set(GLOBAL(lb_trunk)=16)
exten => _9X.,152,Set(CALLERID(num)=9162593854)
exten => _9X.,153,Dial(${trunk1}/${EXTEN:2},,tTor)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?160)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?160)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?160)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CANCEL"]?160)
exten => _9X.,160,GotoIf($[${lb_trunk} != 16]?170)
exten => _9X.,161,Set(GLOBAL(lb_trunk)=17)
exten => _9X.,162,Set(CALLERID(num)=9162585396)
exten => _9X.,163,Dial(${trunk1}/${EXTEN:2},,tTor)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?170)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?170)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?170)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CANCEL"]?170)
exten => _9X.,170,GotoIf($[${lb_trunk} != 17]?180)
exten => _9X.,171,Set(GLOBAL(lb_trunk)=18)
exten => _9X.,172,Set(CALLERID(num)=9162519320)
exten => _9X.,173,Dial(${trunk1}/${EXTEN:2},,tTor)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?180)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?180)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?180)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CANCEL"]?180)
exten => _9X.,180,GotoIf($[${lb_trunk} != 18]?190)
exten => _9X.,181,Set(GLOBAL(lb_trunk)=19)
exten => _9X.,182,Set(CALLERID(num)=9165725174)
exten => _9X.,183,Dial(${trunk1}/${EXTEN:2},,tTor)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?190)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?190)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?190)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CANCEL"]?190)
exten => _9X.,190,GotoIf($[${lb_trunk} != 19]?200)
exten => _9X.,191,Set(GLOBAL(lb_trunk)=20)
exten => _9X.,192,Set(CALLERID(num)=9162353716)
exten => _9X.,193,Dial(${trunk1}/${EXTEN:2},,tTor)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?200)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?200)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?200)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CANCEL"]?200)
exten => _9X.,200,GotoIf($[${lb_trunk} != 20]?210)
exten => _9X.,201,Set(GLOBAL(lb_trunk)=21)
exten => _9X.,202,Set(CALLERID(num)=9165724174)
exten => _9X.,203,Dial(${trunk1}/${EXTEN:2},,tTor)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?210)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?210)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?210)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CANCEL"]?210)
exten => _9X.,210,GotoIf($[${lb_trunk} != 21]?220)
exten => _9X.,211,Set(GLOBAL(lb_trunk)=22)
exten => _9X.,212,Set(CALLERID(num)=9162430542)
exten => _9X.,213,Dial(${trunk1}/${EXTEN:2},,tTor)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?220)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?220)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?220)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CANCEL"]?220)
exten => _9X.,220,GotoIf($[${lb_trunk} != 22]?230)
exten => _9X.,221,Set(GLOBAL(lb_trunk)=23)
exten => _9X.,222,Set(CALLERID(num)=9166235248)
exten => _9X.,223,Dial(${trunk1}/${EXTEN:2},,tTor)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?230)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?230)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?230)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CANCEL"]?230)
exten => _9X.,230,GotoIf($[${lb_trunk} != 23]?240)
exten => _9X.,231,Set(GLOBAL(lb_trunk)=24)
exten => _9X.,232,Set(CALLERID(num)=9162430546)
exten => _9X.,233,Dial(${trunk1}/${EXTEN:2},,tTor)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?240)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?240)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?240)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CANCEL"]?240)
exten => _9X.,240,GotoIf($[${lb_trunk} != 24]?250)
exten => _9X.,241,Set(GLOBAL(lb_trunk)=25)
exten => _9X.,242,Set(CALLERID(num)=9165468804)
exten => _9X.,243,Dial(${trunk1}/${EXTEN:2},,tTor)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?250)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?250)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?250)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CANCEL"]?250)
exten => _9X.,250,GotoIf($[${lb_trunk} != 25]?260)
exten => _9X.,251,Set(GLOBAL(lb_trunk)=26)
exten => _9X.,252,Set(CALLERID(num)=9165728458)
exten => _9X.,253,Dial(${trunk1}/${EXTEN:2},,tTor)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?260)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?260)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?260)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CANCEL"]?260)
exten => _9X.,260,GotoIf($[${lb_trunk} != 26]?270)
exten => _9X.,261,Set(GLOBAL(lb_trunk)=27)
exten => _9X.,262,Set(CALLERID(num)=9165725268)
exten => _9X.,263,Dial(${trunk1}/${EXTEN:2},,tTor)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?270)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?270)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?270)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CANCEL"]?270)
exten => _9X.,270,GotoIf($[${lb_trunk} != 27]?280)
exten => _9X.,271,Set(GLOBAL(lb_trunk)=28)
exten => _9X.,272,Set(CALLERID(num)=9162353714)
exten => _9X.,273,Dial(${trunk1}/${EXTEN:2},,tTor)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?fail)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?fail)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?fail)
exten => _9X.,n,GotoIf($["${DIALSTATUS}" = "CANCEL"]?fail)
exten => _9X.,n(fail),Dial(${trunk2}/${EXTEN:1},,tTor)
exten => _9X.,280,Set(GLOBAL(lb_trunk)=1)
exten => _9X.,281,Goto(2)