{"id":2735,"date":"2021-02-12T14:12:21","date_gmt":"2021-02-12T14:12:21","guid":{"rendered":"https:\/\/www.cyber-cottage.co.uk\/?p=2735"},"modified":"2022-09-21T11:25:19","modified_gmt":"2022-09-21T10:25:19","slug":"running-subroutines-on-answer-for-queues","status":"publish","type":"post","link":"https:\/\/www.cyber-cottage.co.uk\/?p=2735","title":{"rendered":"Running Subroutines  on answer for Queues"},"content":{"rendered":"\n<p>Some years ago we wrote a post on running macros on queue answer <a rel=\"noreferrer noopener\" href=\"https:\/\/www.cyber-cottage.co.uk\/?p=836\" data-type=\"post\" data-id=\"836\" target=\"_blank\">here.<\/a> this was very useful for integration with backends, At the time we raised a feature request to get it added to Freepbx, But this never happened. <\/p>\n\n\n\n<p>Now the variable QGOSUB is in the dialplan for freepbx queues, But still there is no way of setting this in a default freepbx installation and it requires a snip-it of custom dialplan that is called from freepbx by a  &#8216;custom destination&#8217; . For example at its simplest the dialplan to set it could be :- <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[qmacro-set]\nexten =&gt; <em>.,1,Noop(ians test) <\/em>\n<em>exten =&gt; <\/em>.,n,Set(<em>_QGOSUB=ians_routine) <\/em>\n<em>exten =&gt; <\/em>.,n,Goto(app-daynight,1,1)  <\/pre>\n\n\n\n<p>and this sets the variable for all channels in this call, and when the Queue command is run in the default freepbx dialplan<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Queue(9471,${QOPTIONS},,${QAANNOUNCE},${QMAXWAIT},${QAGI},,${QGOSUB},${QRULE},${QPOSITION})&nbsp; <\/pre>\n\n\n\n<p>This allows simple or more complicated routines to be run. For example sending an email on answer which was a request we had that caused us to revisit this.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[ians_routine]\nexten = s,1,Set(origtime=${EPOCH})\nexten = s,n,Noop(${CHANNEL})\nexten = s,n,Set(Agent11=${CUT(CHANNEL,@,1)})\nexten = s,n,Set(Agent12=${CUT(Agent11,\/,2)})\nexten = s,n,Noop(${Agent11} , ${Agent12} )\nexten = s,n,Set(fulltime=${STRFTIME(${EPOCH},,%d%m%Y-%H:%M:%S)})\nexten = s,n,system(echo \"There has been a call , Callers Details: ${CALLERID(number)} ,  ${CRM_SOURCE} , Date and Time: ${fulltime} ,  Agent: ${Agent12} ,Timestamp: ${origtime} , Queue Number: ${QUEUENUM} \" | mail -s \"failed recall at ${fulltime}\" email@address.com)\nsame = n,Return()<\/pre>\n\n\n\n<p>If you think that you would like to be able to set this variable in the freepbx gui give it a vote <a href=\"https:\/\/issues.freepbx.org\/browse\/FREEPBX-22274\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/issues.freepbx.org\/browse\/FREEPBX-22274<\/a> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>This allows simple or more complicated routines to be run. For example sending an email on answer <\/p>\n","protected":false},"author":1,"featured_media":2567,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"content-type":"","advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"Running Subroutines on answer for Queues in @freepbx ","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[2,104,11],"tags":[23,40,212,76],"class_list":["post-2735","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","category-freepbx","category-knowledge","tag-asterisk","tag-freepbx","tag-queues","tag-voip"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.cyber-cottage.co.uk\/wp-content\/uploads\/2019\/03\/collaboration.png?fit=97%2C97&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p5daZy-I7","jetpack_sharing_enabled":true,"jetpack_likes_enabled":false,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2735","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2735"}],"version-history":[{"count":4,"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2735\/revisions"}],"predecessor-version":[{"id":2838,"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2735\/revisions\/2838"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=\/wp\/v2\/media\/2567"}],"wp:attachment":[{"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2735"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2735"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2735"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}