{"id":12504,"date":"2025-04-29T15:41:07","date_gmt":"2025-04-29T10:41:07","guid":{"rendered":"https:\/\/alexeyka.zantsev.com\/?p=12504"},"modified":"2025-04-29T15:48:25","modified_gmt":"2025-04-29T10:48:25","slug":"asterisk-skip-some-action-within-timeout-after-a-call","status":"publish","type":"post","link":"https:\/\/alexeyka.zantsev.com\/?p=12504","title":{"rendered":"Asterisk: skip some action within timeout after a call"},"content":{"rendered":"\n<p>Let&#8217;s skip playing an annoying greeting for the caller, if he already called us withing the last 10 minutes. <\/p>\n\n\n\n<p>Create a macro:<\/p>\n\n\n\n<pre class=\"wp-block-code has-vivid-red-color has-text-color has-link-color wp-elements-7f507830bcfe7fb17e7e3c53b285b104\"><code>macro greetBlock( ext )\n{\n    if(${DB_EXISTS(greetblock\/${CALLERID(num)})}) {\n        \/\/ get the last call's timestamp.\n        Set(LASTCALL=${DB(greetblock\/${CALLERID(num)})});\n    } else {\n        Set(LASTCALL=0);\n    }\n\n    Set(NOW=${EPOCH});\n    Set(DIFF=${MATH(${NOW} - ${LASTCALL},int)});\n\n    if (\"${LASTCALL}\" != \"\" &amp; ${DIFF} &lt; 600) {\n        \/\/ a person called less than 10 minutes ago - skip greeting.\n        NoOp(skip greeting to ${CALLERID(num)} for ${ext});\n        Set(GREETING=0);\n    } else {\n        Set(DB(greetblock\/${CALLERID(num)})=${NOW});\n        Set(GREETING=1);\n    }\n\n    return;\n};<\/code><\/pre>\n\n\n\n<p>And use this macro in your dialplan:<\/p>\n\n\n\n<pre class=\"wp-block-code has-vivid-red-color has-text-color has-link-color wp-elements-6e1d3f59fee8bc9ab8a28ae81fb4f48e\"><code>73333123456 =&gt;\n{\n  NoOp(${STRFTIME(,,%F %R)} . ${CALLERID(num)} dials SALES office . callid start: ${SIP_HEADER(Call-ID)});\n\n  &amp;greetBlock(${EXTEN});\n    \n  if (\"${GREETING}\" = \"1\") {\n    goto greeton;\n  } else {\n    goto greetoff;\n  }\n\n  greeton:\n    Playback(${SOUNDS}\/welcome);\n\n  greetoff:\n    Queue(...);\n    ...\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Let&#8217;s skip playing an annoying greeting for the caller, if he already called us withing the last 10 minutes. Create a macro: And use this macro in your dialplan:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[157,43,297,298,232],"class_list":["post-12504","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-ael","tag-asterisk","tag-skip","tag-skipping","tag-timeout"],"_links":{"self":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts\/12504","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=12504"}],"version-history":[{"count":29,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts\/12504\/revisions"}],"predecessor-version":[{"id":12533,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts\/12504\/revisions\/12533"}],"wp:attachment":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12504"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12504"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12504"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}