You may want to join IRC for some real-time help but I will try to answer your questions.<br><br><br><div class="gmail_quote">On Wed, Jun 25, 2008 at 10:32 PM, John Wehle &lt;<a href="mailto:john@feith.com">john@feith.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">The AT&amp;T System 25 sends inband DTMF at the beginning of a call being<br>
transferred to voicemail which identifies the extension that was called<br>
so I&#39;m creating a javascript to parse the DTMF and do the right thing.<br>
<br>
Questions:<br>
<br>
 &nbsp;1) Following the example I found on <a href="http://thelostpacket.org" target="_blank">thelostpacket.org</a> I&#39;ve created<br>
 &nbsp; &nbsp; a script and placed it in /usr/local/freeswitch/scripts. &nbsp;I&#39;ve<br>
 &nbsp; &nbsp; added:<br>
<br>
 &nbsp; &nbsp;&lt;extension name=&quot;system25_vmail&quot;&gt;<br>
 &nbsp; &nbsp; &nbsp;&lt;condition field=&quot;destination_number&quot; expression=&quot;^5590$&quot;&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;action application=&quot;javascript&quot; data=&quot;$${basedir}/scripts/system25vmail.js&quot;/&gt;<br>
 &nbsp; &nbsp; &nbsp;&lt;/condition&gt;<br>
 &nbsp; &nbsp;&lt;/extension&gt;<br>
<br>
 &nbsp; &nbsp;to dialplan/default.xml. &nbsp;When I call 5590 freeswitch can&#39;t find<br>
 &nbsp; &nbsp;the script. &nbsp;If I replace $${basedir} with /usr/local/freeswitch,<br>
 &nbsp; &nbsp;then the script is called.<br>
<br>
 &nbsp; &nbsp;What&#39;s the proper way to specify the path to a script in the dialplan?<br>
 &nbsp; &nbsp;Is there a way to say that it&#39;s in the script directory under the<br>
 &nbsp; &nbsp;freeswitch installation point without using a full path?<br>
</blockquote><div><br>it&#39;s actually $${base_dir}<br>also a script with a relative path will assume $${base_dir}/scripts/ in front of it.<br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
 &nbsp;2) The DTMF looks something like 123#456# . &nbsp;If I use getDigits(3, &#39;#&#39;)<br>
 &nbsp; &nbsp; followed by another getDigits(3, &#39;#&#39;), then the first call returns<br>
 &nbsp; &nbsp; 123, however the second call doesn&#39;t return 456.<br>
<br>
 &nbsp; &nbsp; It appears that getDigits returns when it either gets the requested<br>
 &nbsp; &nbsp; number of digits * or * it encounters the terminator. &nbsp;Is that correct?<br>
 &nbsp; &nbsp; So should I simply do something like getDigits(9, &#39;#&#39;) followed by<br>
 &nbsp; &nbsp; another getDigits(9, &#39;#&#39;)?<br>
</blockquote><div><br>Yes that is correct I have tested this script and it works:<br><br>session.answer();<br>a = session.getDigits(9, &quot;#&quot;);<br>b = session.getDigits(9, &quot;#&quot;);<br>consoleLog(&quot;err&quot;, &quot;READ A=&quot; + a + &quot; B=&quot; + b + &quot;\n&quot;);<br>
<br><br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
 &nbsp;3) One thought I had was to do something like:<br>
<br>
 &nbsp; &nbsp; &lt;extension name=&quot;system25_vmail&quot;&gt;<br>
 &nbsp; &nbsp; &nbsp; &lt;condition field=&quot;destination_number&quot; expression=&quot;^5590$&quot;&gt;<br>
 &nbsp; &nbsp; &nbsp; &lt;action application=&quot;javascript&quot; data=&quot;$${basedir}/scripts/system25vmail.js&quot;/&gt;<br>
<br>
 &nbsp; &nbsp; &nbsp; &lt;!-- Inside extension checking voicemail --&gt;<br>
 &nbsp; &nbsp; &nbsp; &lt;condition field=&quot;system25_vmail_mode&quot; expression=&quot;00&quot;&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &lt;action application=&quot;voicemail&quot; data=&quot;check default $${domain} ${system25_vmail_caller}&quot;/&gt;<br>
 &nbsp; &nbsp; &nbsp; &lt;/condition&gt;<br>
<br>
 &nbsp; &nbsp; &nbsp; &lt;!-- Inside extension bounced to voicemail --&gt;<br>
 &nbsp; &nbsp; &nbsp; &lt;condition field=&quot;system25_vmail_mode&quot; expression=&quot;02&quot;&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &lt;action application=&quot;voicemail&quot; data=&quot;default $${domain} ${system25_vmail_callee}&quot;/&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &lt;action application=&quot;send_dtmf&quot; data=&quot;#90${system25_vmail_callee}&quot;/&gt;<br>
 &nbsp; &nbsp; &nbsp; &lt;/condition&gt;<br>
<br>
 &nbsp; &nbsp; the idea being that when 5590 is dialed the script will be called<br>
 &nbsp; &nbsp; to parse the DTMF and set the system25_vmail_XXX variables which<br>
 &nbsp; &nbsp; are then used by the later conditions. &nbsp;However the wiki for<br>
 &nbsp; &nbsp; Dialplan XML says:<br>
<br>
 &nbsp; &nbsp; &nbsp; Those accustomed to Asterisk may expect the call to follow the<br>
 &nbsp; &nbsp; &nbsp; dialplan by executing the applications as it parses them allowing<br>
 &nbsp; &nbsp; &nbsp; data obtained from one action to influence the next action. This<br>
 &nbsp; &nbsp; &nbsp; is not the case ...<br>
<br>
 &nbsp; &nbsp; so it sounds like I can&#39;t use an action to set variables to be used<br>
 &nbsp; &nbsp; for the next condition / action. &nbsp;However the example on<br>
 &nbsp; &nbsp; <a href="http://thelostpacket.org" target="_blank">thelostpacket.org</a> does:<br>
<br>
 &nbsp; &nbsp; &nbsp; &lt;action application=&quot;javascript&quot; data=&quot;$${basedir}/scripts/read.js conf-getconfno.wav 5&quot;/&gt;<br>
 &nbsp; &nbsp; &nbsp; &lt;action application=&quot;conference&quot; data=&quot;${res}@default&quot;/&gt;<br>
<br>
 &nbsp; &nbsp; which appears to do exactly what wiki says you can&#39;t so I&#39;m confused.<br>
</blockquote><div><br>What that means is that when the *dialplan* is being parsed it does not begin executing anything until it has parsed then entire dialplan.&nbsp; The variables that begin with $$ are parsed once when FS starts and permanently&nbsp; substituted while the ones that start with just 1 $ are parsed when the extension executes.<br>
<br>So the jist is that you cannot assume the XML dialplan is executing the apps as the XML is being parsed.<br>Rather, it parses it all and is left with a set of instructions with all the variables not yet expanded.<br><br>
So the example is correct because you can choose to execute one application and expect that application to set some critical variables then assume those variables to be set in the next application because those applications are called in order.<br>
<br>The only thing you can&#39;t do is set a variable in one action of your dialplan and then expect that variable to be set to do more &lt;condition&gt; tags inside that same dialplan.<br><br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
 &nbsp;4) My other thought was to have the javascript call the voicemail<br>
 &nbsp; &nbsp; application after parsing the DTMF. &nbsp;I.e.:<br>
<br>
 &nbsp; &nbsp; switch (mode) {<br>
 &nbsp; &nbsp; &nbsp;// Direct Inside Access<br>
 &nbsp; &nbsp; &nbsp;case &quot;00&quot;:<br>
 &nbsp; &nbsp; &nbsp; &nbsp;if (isNaN (parseInt (from))) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;console_log (&quot;err&quot;, &quot;Invalid VMAIL calling PDC from PBX\n&quot;);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;session.flushDigits ();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;session.setVariable (&quot;voicemail_authorized&quot;, &quot;false&quot;);<br>
 &nbsp; &nbsp; &nbsp; &nbsp;apiExecute (&quot;voicemail&quot;, &quot;check default &quot; + domain + &quot; &quot; + from);<br>
<br>
 &nbsp; &nbsp; however the apiExecute doesn&#39;t seem to invoke voicemail. &nbsp;Probably<br>
 &nbsp; &nbsp; because there&#39;s a difference between invoking an application and<br>
 &nbsp; &nbsp; an api. &nbsp;So, how do you invoke an application from a javascript<br>
 &nbsp; &nbsp; called from a dialplan?<br>
</blockquote><div><br><br>apiExecute is for FSAPI calls voicemail is a dialplan application.<br>you would want to do one of the following:<br><br>session.execute(&quot;voicemail&quot;, &quot;&lt;voicemail args&gt;&quot;);<br>
session.execute(&quot;transfer&quot;, &quot;&lt;some ext that leads to voicemail&gt;&quot;);<br>&nbsp;<br>Your plan to set the variables is the best one to avoid overhead of leaving JS running.<br>You may also want to investigate LUA which is a lighter weight scripting engine that is similar to JS and also available.<br>
<br><br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
-- John<br>
-------------------------------------------------------------------------<br>
| &nbsp; Feith Systems &nbsp;| &nbsp; Voice: 1-215-646-8000 &nbsp;| &nbsp;Email: <a href="mailto:john@feith.com">john@feith.com</a> &nbsp;|<br>
| &nbsp; &nbsp;John Wehle &nbsp; &nbsp;| &nbsp; &nbsp; Fax: 1-215-540-5495 &nbsp;| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |<br>
-------------------------------------------------------------------------<br>
<br>
<br>
_______________________________________________<br>
Freeswitch-users mailing list<br>
<a href="mailto:Freeswitch-users@lists.freeswitch.org">Freeswitch-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Anthony Minessale II<br><br>FreeSWITCH <a href="http://www.freeswitch.org/">http://www.freeswitch.org/</a><br>ClueCon <a href="http://www.cluecon.com/">http://www.cluecon.com/</a><br>
<br>AIM: anthm<br><a href="mailto:MSN%3Aanthony_minessale@hotmail.com">MSN:anthony_minessale@hotmail.com</a><br>GTALK/JABBER/<a href="mailto:PAYPAL%3Aanthony.minessale@gmail.com">PAYPAL:anthony.minessale@gmail.com</a><br>
IRC: <a href="http://irc.freenode.net">irc.freenode.net</a> #freeswitch<br><br>FreeSWITCH Developer Conference<br><a href="mailto:sip%3A888@conference.freeswitch.org">sip:888@conference.freeswitch.org</a><br><a href="http://iax:guest@conference.freeswitch.org/888">iax:guest@conference.freeswitch.org/888</a><br>
<a href="mailto:googletalk%3Aconf%2B888@conference.freeswitch.org">googletalk:conf+888@conference.freeswitch.org</a><br>pstn:213-799-1400