<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span>Thanks Mathew. That is really helpful. I need to do something before music on hold could be played, upon hold. However it appears,&nbsp; AMI musiconhold event occurs when channel is placed on hold (thats is exactly I need), but MOH is played (I don't want this)?<br></span></div><div><br></div>  <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div dir="ltr"> <font face="Arial" size="2"> <hr size="1">  <b><span style="font-weight:bold;">From:</span></b> Matthew  Jordan &lt;mjordan@digium.com&gt;<br> <b><span style="font-weight: bold;">To:</span></b> Asterisk Developers Mailing List &lt;asterisk-dev@lists.digium.com&gt; <br> <b><span style="font-weight: bold;">Sent:</span></b> Tuesday, August 28, 2012
 7:05 AM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [asterisk-dev] Need to run an AGI from dialplan only upon call hold<br> </font> </div> <br>
<br><br>----- Original Message ----- <br><br>&gt; From: "uma udupi" &lt;<a ymailto="mailto:umaudupi@yahoo.com" href="mailto:umaudupi@yahoo.com">umaudupi@yahoo.com</a>&gt;<br>&gt; To: "uma udupi" &lt;<a ymailto="mailto:umaudupi@yahoo.com" href="mailto:umaudupi@yahoo.com">umaudupi@yahoo.com</a>&gt;, <a ymailto="mailto:asterisk-dev@lists.digium.com" href="mailto:asterisk-dev@lists.digium.com">asterisk-dev@lists.digium.com</a>,<br>&gt; "Asterisk Developers Mailing List" &lt;<a ymailto="mailto:asterisk-dev@lists.digium.com" href="mailto:asterisk-dev@lists.digium.com">asterisk-dev@lists.digium.com</a>&gt;<br>&gt; Sent: Tuesday, August 28, 2012 7:15:50 AM<br>&gt; Subject: Re: [asterisk-dev] Need to run an AGI from dialplan only<br>&gt; upon call hold<br><br>&gt; Hello<br><br>&gt; I need help on this one. Could anyone suggest what can be done to<br>&gt; trigger "something" upon HOLD? I hope this is the right mailling<br>&gt; list for this topic. If not please
 let me know where can I take<br>&gt; this.<br><br>&lt;snip&gt;<br><br>&gt; I'm new to Asterisk. I need to call (from dialplan) a macro or a<br>&gt; gosub or an AGI upon one of the connected party in a bridged call<br>&gt; (on sip trunk) puts the call on HOLD. Anyhelp greatly appreciated<br><br>There is no functionality that I'm aware of in Asterisk that would allow<br>this scenario.&nbsp; It could certainly be written.<br><br>&gt; PS: I looked into app_dial.c if I can capture AST_CONTROL_HOLD event,<br>&gt; and call a macro, however once ast_bridge_call() is called, Dial app<br>&gt; does not get mid-call events on the call (like<br>&gt; AST_CONTROL_HOLD/AST_CONTROL_UNHOLD)<br><br>Once two channels are bridged, the application that 'helped' those channels<br>get bridged - be it app_dial or some other mechanism - is no longer responsible<br>for servicing the frames on those channels.&nbsp; The various bridging<br>implementations handle it after that
 point.&nbsp; This could be in the channel<br>technology itself, in ast_generic_bridge, or in one of the bridging<br>layer implementations (only used by app_confbridge (Asterisk 10 and later) and<br>app_page (Asterisk 11 and later)).<br><br>You could explore having an option that would cause some portion of dialplan<br>to be executed on a channel when an AST_CONTROL_HOLD frame is received by any<br>one of the various bridging implementations; however, that would be quite an<br>extensive feature given the different types of bridging available in Asterisk.<br><br>If you don't need to use AGI, or you don't need to execute your logic<br>immediately in the dialplan, you could try a different approach and use<br>AMI.&nbsp; An external application could listen for the Bridge and MusicOnHold<br>events.&nbsp; The Bridge event will tell you when two channels are bridged<br>together.&nbsp; Any MusicOnHold events after that should indicate that one<br>of the
 channels was either put on Hold or taken off Hold.<br><br>You would need to have res_musiconhold loaded and configured for this<br>scenario to work, but would much easier and less intrusive to implement than<br>altering Asterisk.<br><br>--<br>Matthew Jordan<br>Digium, Inc. | Engineering Manager<br>445 Jan Davis Drive NW - Huntsville, AL 35806 - USA<br>Check us out at: http://digium.com &amp; http://asterisk.org<br><br>--<br>_____________________________________________________________________<br>-- Bandwidth and Colocation Provided by http://www.api-digital.com --<br><br>asterisk-dev mailing list<br>To UNSUBSCRIBE or update options visit:<br>&nbsp;  http://lists.digium.com/mailman/listinfo/asterisk-dev<br><br><br> </div> </div>  </div></body></html>