<div dir="ltr">Finally I could do it using the <a href="https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+ManagerAction_Originate" target="_blank" style="font-family:arial,sans-serif;font-size:13px">AMI Originate</a><span style="font-family:arial,sans-serif;font-size:13px"> command and the parameter EarlyMedia=true. So, when you throw the call, when detects the EarlyMedia (SIP 183) the channels is bridged to context and you can do the recording.</span><br clear="all" style="font-family:arial,sans-serif;font-size:13px">
<div style="font-family:arial,sans-serif;font-size:13px">This works from Asterisk 11.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jun 27, 2014 at 11:00 AM, David Pinedo <span dir="ltr"><<a href="mailto:dpinedo@presenceco.com" target="_blank">dpinedo@presenceco.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span style="color:rgb(65,65,65);font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:20px;background-color:rgb(246,246,246)">Hello,</span><br style="color:rgb(65,65,65);font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:20px;background-color:rgb(246,246,246)">

<br style="color:rgb(65,65,65);font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:20px;background-color:rgb(246,246,246)"><span style="color:rgb(65,65,65);font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:20px;background-color:rgb(246,246,246)">Throwing calls from Asterisk to PSTN (via a VoIP gateway) some operators sends an explaining audio, in situations as:</span><br style="color:rgb(65,65,65);font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:20px;background-color:rgb(246,246,246)">

<span style="color:rgb(65,65,65);font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:20px;background-color:rgb(246,246,246)">The phone number does is not assigned</span><br style="color:rgb(65,65,65);font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:20px;background-color:rgb(246,246,246)">

<span style="color:rgb(65,65,65);font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:20px;background-color:rgb(246,246,246)">The phone is powered off</span><br style="color:rgb(65,65,65);font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:20px;background-color:rgb(246,246,246)">

<span style="color:rgb(65,65,65);font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:20px;background-color:rgb(246,246,246)">etc.</span><br style="color:rgb(65,65,65);font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:20px;background-color:rgb(246,246,246)">

<span style="color:rgb(65,65,65);font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:20px;background-color:rgb(246,246,246)">The audio is sent before the call to be answered.</span><br style="color:rgb(65,65,65);font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:20px;background-color:rgb(246,246,246)">

<span style="background-color:rgb(246,246,246)"><font color="#414141" face="Arial, Helvetica, sans-serif"><span style="line-height:20px">So, in an automatic dialling application I'd like to recognize that audio to know what to do with those calls (queue them to a service, mark as wrong number, unavailable, etc.).</span></font></span><br style="color:rgb(65,65,65);font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:20px;background-color:rgb(246,246,246)">

<br style="color:rgb(65,65,65);font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:20px;background-color:rgb(246,246,246)"><span style="background-color:rgb(246,246,246)"><font color="#414141" face="Arial, Helvetica, sans-serif"><span style="line-height:20px">Does Asterisk have any functionality to recognize the audio in early media (similar to the answer machine detection)?</span></font></span><br style="color:rgb(65,65,65);font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:20px;background-color:rgb(246,246,246)">

<br style="color:rgb(65,65,65);font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:20px;background-color:rgb(246,246,246)"><span style="color:rgb(65,65,65);font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:20px;background-color:rgb(246,246,246)">Is  there a way to record the audio in early media to implement my own early media detector?</span><br style="color:rgb(65,65,65);font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:20px;background-color:rgb(246,246,246)">

<br style="color:rgb(65,65,65);font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:20px;background-color:rgb(246,246,246)"><span style="color:rgb(65,65,65);font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:20px;background-color:rgb(246,246,246)">Thank you in advance</span>
<div><span style="color:rgb(65,65,65);font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:20px;background-color:rgb(246,246,246)"><br></span></div><div><span style="color:rgb(65,65,65);font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:20px;background-color:rgb(246,246,246)">---</span></div>

<div><span style="color:rgb(65,65,65);font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:20px;background-color:rgb(246,246,246)">David Pinedo</span></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><p style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;margin:0px"><b><span lang="EN-GB" style="font-size:8pt;color:rgb(255,102,0)">PRESENCE TECHNOLOGY</span></b><b><span lang="EN-GB" style="font-size:8pt;color:rgb(127,127,127)"><br>
</span></b><b><span lang="EN-GB" style="font-size:8pt">David Pinedo García</span></b><span lang="EN-GB" style="font-size:8pt"><br>Software Developer<br><span style="border-collapse:collapse">C/ Comte d'Urgell 240 3º-A</span><br>
Barcelona 08036<br></span><a href="mailto:dpinedo@presenceco.com" style="color:rgb(53,66,88)" target="_blank"><span lang="EN-GB" style="font-size:8pt;color:rgb(255,102,0)">dpinedo@presenceco.com</span></a><span lang="EN-US" style="font-size:8pt;color:rgb(255,102,0)"></span></p>
<p style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;margin:0px"><span lang="EN-GB" style="font-size:8pt">Ph: +34 93 10 10 300/313 </span></p><p style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;margin:0px">
<a href="http://www.presenceco.com/" style="color:rgb(53,66,88)" target="_blank"><b><span lang="EN-US" style="font-size:8pt;color:rgb(255,102,0)">www.presenceco.com</span></b></a><b><span lang="EN-US" style="font-size:8pt;color:rgb(255,102,0)"></span></b></p>
<p style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;margin:0px"><span lang="EN-GB" style="font-size:8pt"> </span></p><p style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;margin:0px">
<b><span lang="EN-GB" style="font-size:8pt"><span style="font-size:13px;font-weight:normal"></span></span></b></p><p style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;margin:0px"><b><b><span lang="EN-GB" style="font-size:8pt">Follow us on:</span></b></b></p>
<p style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px"></p><p style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px"></p><p style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;margin:0px">
<b><span lang="EN-GB" style="font-size:8pt;color:rgb(127,127,127)"> </span></b></p><p style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;margin:0px"><b><span lang="EN-US" style="font-size:8pt;color:rgb(127,127,127)">Presence Technology - Disclaimer</span></b><span lang="EN-US" style="font-size:8pt;color:rgb(127,127,127)"><br>
This message, its content and any file attached thereto is for the intended recipient only and is confidential and /or privileged. If you have received this e-mail in error or had access to it, you should note that the information in it is private and any use thereof is unauthorized. In such an event please notify us by e-mail or by telephone <a value="+34931010300">(+ 34 93 10 10 300</a>). Any reproduction of this e-mail by whatsoever means and any transmission or dissemination thereof to other persons is prohibited. It should be deleted immediately from your system. Presence Technology reserves the right to take legal action against any persons unlawfully gaining access to the content of any external message it has emitted.</span></p>
<p style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;margin:0px"><span lang="EN-US" style="font-size:8pt;color:rgb(127,127,127)">For additional information, please visit our website </span><b style="color:rgb(53,66,88)"><span lang="EN-US" style="font-size:8pt;color:rgb(255,102,0)"><a href="http://www.presenceco.com/" style="color:rgb(53,66,88)" target="_blank">www.presenceco.com</a></span></b><span lang="EN-US" style="font-size:8pt;color:rgb(127,127,127)"></span></p>
<br></div>
</div>