<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'><br><hr id="stopSpelling"><BR><div><div dir="ltr">Hi,<font face="Times New Roman">

</font><br></div><p dir="ltr" class="ecxMsoNormal">How to set hooks like api_on_answer/execute_on_answer using
mod_managed during originate.&nbsp;</p><div dir="ltr"><font face="Times New Roman">

</font></div><p dir="ltr" class="ecxMsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">Iam able to get call back
notification on Originate by ‘<span style="color: blue;">new</span> <span style="color: rgb(43, 145, 175);">Api</span>().ExecuteString("originate channel/params
&amp;managed(Myclassname"))</span></p><div dir="ltr"><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;">Iam not able to get notification
on outbound answer. I want my API to be called. Sample code looks like…</span><br><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">public</span> <span style="color: blue;">void</span> Run(<span style="color: rgb(43, 145, 175);">AppContext</span>
context)</span><br><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{</span><br><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">try</span></span><br><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{</span><br><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>context.Session.Answer();</span><br><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: green;">//
Create UUID</span></span><br><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">string</span>
OutboundUuid = <span style="color: blue;">new</span> <span style="color: rgb(43, 145, 175);">Api</span>().ExecuteString(<span style="color: rgb(163, 21, 21);">"create_uuid"</span>);</span><br><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">string</span>
route = <span style="color: rgb(163, 21, 21);">"{origination_caller_id_number=4154151234"</span>
+ <span style="color: rgb(163, 21, 21);">"}[origination_uuid="</span> +
OutboundUuid + <span style="color: rgb(163, 21, 21);">"]sofia/gateway/36/1234567890"</span>;</span><br><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">string</span>
dialPlan = <span style="color: rgb(163, 21, 21);">"originate "</span> + route + <span style="color: rgb(163, 21, 21);">" '&amp;managed(MyNameSpace.OutboundLeg)'"</span>;</span><br><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">new</span>
<span style="color: rgb(43, 145, 175);">Api</span>().ExecuteString(dialPlan);</span><br><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">string</span>
bridgeResult = <span style="color: blue;">new</span> <span style="color: rgb(43, 145, 175);">Api</span>().ExecuteString(<span style="color: blue;">string</span>.Format(<span style="color: rgb(163, 21, 21);">"uuid_bridge
{0} {1}"</span>, context.Session.GetUuid(), OutboundUuid));</span><br><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</span><br><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">catch</span>
(<span style="color: rgb(43, 145, 175);">Exception</span> exception)</span><br><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{</span><br><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: rgb(43, 145, 175);">Log</span>.WriteLine(<span style="color: rgb(43, 145, 175);">LogLevel</span>.Notice, exception.ToString());</span><br><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</span><br><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>} </span><br><font face="Times New Roman">

</font><br></div><p dir="ltr" class="ecxMsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;
</span><span style="color: blue;">public</span> <span style="color: blue;">class</span>
<span style="color: rgb(43, 145, 175);">OutboundLeg</span> : <span style="color: rgb(43, 145, 175);">IAppPlugin</span></span></p><div dir="ltr"><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;
</span>{</span><br><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">public</span> <span style="color: blue;">void</span> Run(<span style="color: rgb(43, 145, 175);">AppContext</span>
context)</span><br><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{</span><br><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>// This is getting called on
outboundleg orgination</span><br><font face="Times New Roman">

</font><span style="color: rgb(43, 145, 175); font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Log</span><span style="font-family: Consolas; font-size: 9.5pt;">.WriteLine(<span style="color: rgb(43, 145, 175);">LogLevel</span>.Warning, <span style="color: rgb(163, 21, 21);">"OutboundLeg
Notified -------&gt;"</span>);</span></div><p dir="ltr" class="ecxMsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</span></p><p dir="ltr" class="ecxMsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">public</span> <span style="color: blue;">void</span> OnAnswer()</span></p><div dir="ltr"><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{</span><br><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: rgb(43, 145, 175);">Log</span>.WriteLine(<span style="color: rgb(43, 145, 175);">LogLevel</span>.Warning, <span style="color: rgb(163, 21, 21);">"OutboundLeg
OnAnswered -------&gt;"</span>);</span></div><p dir="ltr" class="ecxMsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</span><br><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">public</span> <span style="color: blue;">void</span> OnAnswer(<span style="color: blue;">string</span>
uuid)</span><br><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{</span><br><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: rgb(43, 145, 175);">Log</span>.WriteLine(<span style="color: rgb(43, 145, 175);">LogLevel</span>.Warning, <span style="color: rgb(163, 21, 21);">"OutboundLeg
OnAnswered -------&gt;"</span>);</span><br><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</span><br><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;"><span>&nbsp;&nbsp;&nbsp;
</span>}</span><br><font face="Times New Roman">

</font><font face="Times New Roman">

</font></p><p dir="ltr" class="ecxMsoNormal">I want <span style="color: rgb(43, 145, 175); font-family: Consolas; font-size: 9.5pt;">OutboundLeg.OnAnswer() to be called on outbound answer. I tried
the following syntax but it didn’t work.</span></p><div dir="ltr"><font face="Times New Roman">

</font></div><p dir="ltr" class="ecxMsoNormal"><span style="color: rgb(163, 21, 21); font-family: Consolas; font-size: 9.5pt;">originate <span>&nbsp;</span></span><span style="color: green; font-family: Consolas; font-size: 9.5pt;">{origination_caller_id_number=</span><span style="color: rgb(163, 21, 21); font-family: Consolas; font-size: 9.5pt;">4154151234</span><span style="color: green; font-family: Consolas; font-size: 9.5pt;">,
nolocal:api_on_answer='managed </span><span style="color: rgb(163, 21, 21); font-family: Consolas; font-size: 9.5pt;">MyNameSpace</span><span style="color: green; font-family: Consolas; font-size: 9.5pt;">.OutboundLeg.OnAnswer OutboundUuid’}[origination_uuid=OutboundUuid]sofia/gateway/36/</span><span style="color: rgb(163, 21, 21); font-family: Consolas; font-size: 9.5pt;">1234567890</span><span style="color: green; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: rgb(163, 21, 21); font-family: Consolas; font-size: 9.5pt;">'&amp;managed(MyNameSpace.OutboundLeg)'</span></p><div dir="ltr"><font face="Times New Roman">

</font></div><p dir="ltr" class="ecxMsoNormal"><span style="color: rgb(163, 21, 21); font-family: Consolas; font-size: 9.5pt;">originate <span>&nbsp;</span></span><span style="color: green; font-family: Consolas; font-size: 9.5pt;">{origination_caller_id_number=</span><span style="color: rgb(163, 21, 21); font-family: Consolas; font-size: 9.5pt;">4154151234</span><span style="color: green; font-family: Consolas; font-size: 9.5pt;">,
nolocal:api_on_answer='&amp;managed </span><span style="color: rgb(163, 21, 21); font-family: Consolas; font-size: 9.5pt;">MyNameSpace</span><span style="color: green; font-family: Consolas; font-size: 9.5pt;">.OutboundLeg.OnAnswer OutboundUuid’}[origination_uuid=OutboundUuid]sofia/gateway/36/</span><span style="color: rgb(163, 21, 21); font-family: Consolas; font-size: 9.5pt;">1234567890</span><span style="color: green; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: rgb(163, 21, 21); font-family: Consolas; font-size: 9.5pt;">'&amp;managed(MyNameSpace.OutboundLeg)'</span></p><div dir="ltr"><font face="Times New Roman">

</font></div><p dir="ltr" class="ecxMsoNormal"><span style="color: green; font-family: Consolas; font-size: 9.5pt;">Also tried setting the
Session variable on the outbound leg by</span></p><div dir="ltr"><font face="Times New Roman">

</font><span style="font-family: Consolas; font-size: 9.5pt;">outboundSession.SetVariable(<span style="color: rgb(163, 21, 21);">"export"</span>, <span style="color: rgb(163, 21, 21);">"nolocal:api_on_answer='managed
MyNameSpace.OutboundLeg.OnAnswer"</span>);</span><br><font face="Times New Roman">

</font><br><span style="color: green; font-family: Consolas; font-size: 9.5pt;">Also tried </span><span lang="EN">execute_on_answer instead of
api_on_answer.</span><br><font face="Times New Roman">

</font><br><span style="color: green; font-family: Consolas; font-size: 9.5pt;">Please do let me know
the correct syntax to use </span><span lang="EN">execute_on_answer/api_on_answer.</span></div><div dir="ltr"><font face="Times New Roman">

</font></div><p dir="ltr" class="ecxMsoNormal"><span lang="EN">Note: I was able to play the prompt on
outbound answer by calling system api </span></p><div dir="ltr"><font face="Times New Roman">

</font><span style="color: rgb(163, 21, 21); font-family: Consolas; font-size: 9.5pt;">originate <span>&nbsp;</span></span><span style="color: green; font-family: Consolas; font-size: 9.5pt;">{origination_caller_id_number=</span><span style="color: rgb(163, 21, 21); font-family: Consolas; font-size: 9.5pt;">4154151234</span><span style="color: green; font-family: Consolas; font-size: 9.5pt;">, api_on_answer='uuid_broadcast
OutboundUuid prompt.wav both'}[origination_uuid=OutboundUuid]sofia/gateway/36/</span><span style="color: rgb(163, 21, 21); font-family: Consolas; font-size: 9.5pt;">1234567890</span><span style="color: green; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: rgb(163, 21, 21); font-family: Consolas; font-size: 9.5pt;">'&amp;managed(MyNameSpace.OutboundLeg)'</span><br><font face="Times New Roman">

</font><br><font face="Times New Roman">Thanks</font><br><font face="Times New Roman">Srini</font></div></div>                                               </div></body>
</html>