You can use this code in your asterisk gateway and just add callerid variable on that code.
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} != 0]?10)
exten => _9X.,4,Set(GLOBAL(lb_trunk)=1)
exten => _9X.,5,Dial(${trunk_1}/${EXTEN:1},,tTor)
exten => _9X.,10,GotoIf($[${lb_trunk} != 1]?20)
exten => _9X.,11,Set(GLOBAL(lb_trunk)=2)
exten => _9X.,12,Dial(${trunk_2}/${EXTEN:1},,tTor)
exten => _9X.,20,GotoIf($[${lb_trunk} != 2]?30)
exten => _9X.,21,Set(GLOBAL(lb_trunk)=3)
exten => _9X.,22,Dial(${trunk_3}/${EXTEN:1},,tTor)
exten => _9X.,30,Set(GLOBAL(lb_trunk)=0)
exten => _9X.,31,Goto(1)