... in the /var/lib/asterisk/agi-bin folder and put in dialplan something like:
exten => _X.,1,ExecIf($[${LEN(${DB(cidname/${CALLERID(num)})})} > 0]?SET(CALLERID(name)=${DB(cidname/${CALLERID(num)})}):AGI(reversecheck.agi,${CALLERID(num)}))
same => n,ExecIf($[${LEN(${RESULTREV})} > 0]?SET(CALLERID(name)=${RESULTREV}))
same => n,GotoIf($[${REGEX("[7-9]" ${SPAMSCORE})}]?spamtrap,${EXTEN},1)