ODBC & extensions_custom.conf

Hi

I am using Asterisk 11.3.0
I am a newbe with this and any help will be appreciated.
I want asterisk to log all outbound calls in our CRM Database.
We are using PostgressSQL with a custom CRM Application.
But asterisk don’t want to execute the functions.
So I have done the following:

func_odbc.conf:

[LOG_GET_USERID]
dsn=django_odbc
readsql=SELECT ${ARG1} FROM userprofile WHERE asterisk_extension = ‘${ARG2}’

[LOG_GET_CONTACT1]
dsn=django_odbc
readsql=SELECT ${ARG1},${ARG2} FROM contact WHERE ${ARG3} = ‘${ARG4}’

[LOG_GET_CLIENT1]
dsn=django_odbc
readsql=SELECT ${ARG1},${ARG2} FROM client WHERE ${ARG3} = ‘${ARG4}’

[LOG_INTERACTION_OUTBOUND]
dsn=django_odbc
write=INSERT INTO call (subject,spoke_to,description,status,direction,date_start,assign_to_id,created_at,updated_at,sugarcrm_id) VALUE$ (‘To ${VAL2}’,’?’,’${VAL8} - ${VAL9} - ${VAL3} - ${VAL4} - ${VAL6}’,‘Not_Held’,‘Outbound’,’${VAL5}’,’${VAL7}’,’${VAL5}’,’${VAL5}’,’${VAL1}’);


I have tested it and it does “Insert” in our CRM Table.
So problem with connection.

My problem is with the executing of the functions.
Here are my extensions *.conf

extensions_additional.conf:

[outbound-allroutes]
include => outbound-allroutes-custom
include => outrt-001-SM
include => outrt-002-SB
include => outrt-003-SCF
include => outrt-004-HQ
include => outrt-005-InterOffice_IM
include => outrt-006-InterOffice_NL
include => outrt-007-InterOffice_DW
include => outrt-008-Local_Mobile
exten => foo,1,Noop(bar)

; end of [outbound-allroutes]

[outrt-001-SM]
include => outrt-001-SM-custom
exten => _12XX,1,Macro(user-callerid,SKIPTTL,)
exten => _12XX,n,Set(INTRACOMPANYROUTE=YES)
exten => _12XX,n,ExecIf($["${KEEPCID}"!=“TRUE” & ${LEN(${DB(AMPUSER/${AMPUSER}/outboundcid)}}=0 & ${LEN(${TRUNKCIDOVERRIDE}}=0]?Set(TRUNKCIDOVERRIDE=SM))
exten => _12XX,n,Set(_NODEST=)
exten => _12XX,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _12XX,n,Macro(dialout-trunk,7,${EXTEN},)
exten => _12XX,n,Macro(outisbusy,)

; end of [outrt-001-SM]

[outrt-002-SB]
include => outrt-002-SB-custom
exten => _14XX,1,Macro(user-callerid,SKIPTTL,)
exten => _14XX,n,Set(INTRACOMPANYROUTE=YES)
exten => _14XX,n,ExecIf($["${KEEPCID}"!=“TRUE” & ${LEN(${DB(AMPUSER/${AMPUSER}/outboundcid)}}=0 & ${LEN(${TRUNKCIDOVERRIDE}}=0]?Set(TRUNKCIDOVERRIDE=SB))
exten => _14XX,n,Set(_NODEST=)
exten => _14XX,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _14XX,n,Macro(dialout-trunk,5,${EXTEN},)
exten => _14XX,n,Macro(outisbusy,)
exten => _20X,1,Macro(user-callerid,SKIPTTL,)
exten => _20X,n,Set(INTRACOMPANYROUTE=YES)
exten => _20X,n,ExecIf($["${KEEPCID}"!=“TRUE” & ${LEN(${DB(AMPUSER/${AMPUSER}/outboundcid)}}=0 & ${LEN(${TRUNKCIDOVERRIDE}}=0]?Set(TRUNKCIDOVERRIDE=SB))
exten => _20X,n,Set(_NODEST=)
exten => _20X,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _20X,n,Macro(dialout-trunk,5,${EXTEN},)
exten => _20X,n,Macro(outisbusy,)

; end of [outrt-002-SB]

[outrt-003-SCF]
include => outrt-003-SCF-custom
exten => _16XX,1,Macro(user-callerid,SKIPTTL,)
exten => _16XX,n,Set(INTRACOMPANYROUTE=YES)
exten => _16XX,n,ExecIf($["${KEEPCID}"!=“TRUE” & ${LEN(${DB(AMPUSER/${AMPUSER}/outboundcid)}}=0 & ${LEN(${TRUNKCIDOVERRIDE}}=0]?Set(TRUNKCIDOVERRIDE=SCF))
exten => _16XX,n,Set(_NODEST=)
exten => _16XX,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _16XX,n,Macro(dialout-trunk,6,${EXTEN},)
exten => _16XX,n,Macro(outisbusy,)

; end of [outrt-003-SCF]

[outrt-004-HQ]
include => outrt-004-HQ-custom
exten => _15XX,1,Macro(user-callerid,SKIPTTL,)
exten => _15XX,n,Set(INTRACOMPANYROUTE=YES)
exten => _15XX,n,Set(_NODEST=)
exten => _15XX,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _15XX,n,Macro(dialout-trunk,4,${EXTEN},)
exten => _15XX,n,Macro(outisbusy,)

; end of [outrt-004-HQ]

[outrt-005-InterOffice_IM]
include => outrt-005-InterOffice_IM-custom
exten => _23XX,1,Macro(user-callerid,SKIPTTL,)
exten => _23XX,n,Set(INTRACOMPANYROUTE=YES)
exten => _23XX,n,Set(_NODEST=)
exten => _23XX,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _23XX,n,Macro(dialout-trunk,9,${EXTEN},)
exten => _23XX,n,Macro(outisbusy,)

; end of [outrt-005-InterOffice_IM]

[outrt-006-InterOffice_NL]
include => outrt-006-InterOffice_NL-custom
exten => _18XX,1,Macro(user-callerid,SKIPTTL,)
exten => _18XX,n,Set(INTRACOMPANYROUTE=YES)
exten => _18XX,n,Set(_NODEST=)
exten => _18XX,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _18XX,n,Macro(dialout-trunk,8,${EXTEN},)
exten => _18XX,n,Macro(outisbusy,)

; end of [outrt-006-InterOffice_NL]

[outrt-007-InterOffice_DW]
include => outrt-007-InterOffice_DW-custom
exten => _21XX,1,Macro(user-callerid,SKIPTTL,)
exten => _21XX,n,Set(INTRACOMPANYROUTE=YES)
exten => _21XX,n,Set(_NODEST=)
exten => _21XX,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _21XX,n,Macro(dialout-trunk,11,${EXTEN},)
exten => _21XX,n,Macro(outisbusy,)

; end of [outrt-007-InterOffice_DW]

[outrt-008-Local_Mobile]
include => outrt-008-Local_Mobile-custom
exten => _XX.,1,Macro(user-callerid,SKIPTTL,)
exten => _XX.,n,Set(_NODEST=)
exten => _XX.,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _XX.,n,Macro(dialout-trunk,3,${EXTEN},)
exten => _XX.,n,Macro(dialout-trunk,4,${EXTEN},)
exten => _XX.,n,Macro(outisbusy,)

; end of [outrt-008-Local_Mobile]

extensions_custom.conf :

[outrt-008-Local_Mobile-custom]
exten => _XX.,1,Set(CRMUSERID=${ODBC_LOG_GET_USERID(user_id,${CALLERID(number)})})
exten => _XX.,n,Set(CONTACT1=${ODBC_LOG_GET_CONTACT1(firstname,surname,cellular,${EXTEN})})
exten => _XX.,n,Set(CLIENT1=${ODBC_LOG_GET_CLIENT1(global_id,name,phone_office,${EXTEN})})
exten => _XX.,n,Set(ODBC_LOG_INTERACTION_OUTBOUND()=${UNIQUEID},${EXTEN},${CHANNEL},${CONTEXT},${STRFTIME(${EPOCH},%Y-%m-%d %H:%M:%S)},${CALLERID(number)},${CRMUSERID},${CONTACT1},${CLIENT1})


Can someone please help me in the right direction?
Not 100% sure what I am doing wrong.

I also need to log all the incoming calls on our “Queue 100”, but I 1st want to fix the logging of the outbound calls.

Thanks
Hendrik

Your dialplan is incomplete, but I suspect it is a FreePBX dialplan, so you may want to take this to the FreePBX people.

You have not provided any information about how calls get into the contexts you provided. However, the include for outrt-008-Local_Mobile-custom in outrt-008-Local_Mobile will be ineffective, because there are equally good matches for all priorities of all extension in outrt-008-Local_Mobile and actually matches for rather more priorities.

If you go direct to outrt-008-Local_Mobile-custom, none of the priorities will actually initiate an outbound call.

Context includes are only followed if there is no match for extension and priority in the including context.