Let’s skip playing an annoying greeting for the caller, if he already called us withing the last 10 minutes.
Create a macro:
macro greetBlock( ext )
{
if(${DB_EXISTS(greetblock/${CALLERID(num)})}) {
// get the last call's timestamp.
Set(LASTCALL=${DB(greetblock/${CALLERID(num)})});
} else {
Set(LASTCALL=0);
}
Set(NOW=${EPOCH});
Set(DIFF=${MATH(${NOW} - ${LASTCALL},int)});
if ("${LASTCALL}" != "" & ${DIFF} < 600) {
// a person called less than 10 minutes ago - skip greeting.
NoOp(skip greeting to ${CALLERID(num)} for ${ext});
Set(GREETING=0);
} else {
Set(DB(greetblock/${CALLERID(num)})=${NOW});
Set(GREETING=1);
}
return;
};
And use this macro in your dialplan:
73333123456 =>
{
NoOp(${STRFTIME(,,%F %R)} . ${CALLERID(num)} dials SALES office . callid start: ${SIP_HEADER(Call-ID)});
&greetBlock(${EXTEN});
if ("${GREETING}" = "1") {
goto greeton;
} else {
goto greetoff;
}
greeton:
Playback(${SOUNDS}/welcome);
greetoff:
Queue(...);
...
}