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 <<a href="mailto:john@feith.com">john@feith.com</a>> 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&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'm creating a javascript to parse the DTMF and do the right thing.<br>
<br>
Questions:<br>
<br>
1) Following the example I found on <a href="http://thelostpacket.org" target="_blank">thelostpacket.org</a> I've created<br>
a script and placed it in /usr/local/freeswitch/scripts. I've<br>
added:<br>
<br>
<extension name="system25_vmail"><br>
<condition field="destination_number" expression="^5590$"><br>
<action application="javascript" data="$${basedir}/scripts/system25vmail.js"/><br>
</condition><br>
</extension><br>
<br>
to dialplan/default.xml. When I call 5590 freeswitch can't find<br>
the script. If I replace $${basedir} with /usr/local/freeswitch,<br>
then the script is called.<br>
<br>
What's the proper way to specify the path to a script in the dialplan?<br>
Is there a way to say that it's in the script directory under the<br>
freeswitch installation point without using a full path?<br>
</blockquote><div><br>it's actually $${base_dir}<br>also a script with a relative path will assume $${base_dir}/scripts/ in front of it.<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>
2) The DTMF looks something like 123#456# . If I use getDigits(3, '#')<br>
followed by another getDigits(3, '#'), then the first call returns<br>
123, however the second call doesn't return 456.<br>
<br>
It appears that getDigits returns when it either gets the requested<br>
number of digits * or * it encounters the terminator. Is that correct?<br>
So should I simply do something like getDigits(9, '#') followed by<br>
another getDigits(9, '#')?<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, "#");<br>b = session.getDigits(9, "#");<br>consoleLog("err", "READ A=" + a + " B=" + b + "\n");<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>
3) One thought I had was to do something like:<br>
<br>
<extension name="system25_vmail"><br>
<condition field="destination_number" expression="^5590$"><br>
<action application="javascript" data="$${basedir}/scripts/system25vmail.js"/><br>
<br>
<!-- Inside extension checking voicemail --><br>
<condition field="system25_vmail_mode" expression="00"><br>
<action application="voicemail" data="check default $${domain} ${system25_vmail_caller}"/><br>
</condition><br>
<br>
<!-- Inside extension bounced to voicemail --><br>
<condition field="system25_vmail_mode" expression="02"><br>
<action application="voicemail" data="default $${domain} ${system25_vmail_callee}"/><br>
<action application="send_dtmf" data="#90${system25_vmail_callee}"/><br>
</condition><br>
<br>
the idea being that when 5590 is dialed the script will be called<br>
to parse the DTMF and set the system25_vmail_XXX variables which<br>
are then used by the later conditions. However the wiki for<br>
Dialplan XML says:<br>
<br>
Those accustomed to Asterisk may expect the call to follow the<br>
dialplan by executing the applications as it parses them allowing<br>
data obtained from one action to influence the next action. This<br>
is not the case ...<br>
<br>
so it sounds like I can't use an action to set variables to be used<br>
for the next condition / action. However the example on<br>
<a href="http://thelostpacket.org" target="_blank">thelostpacket.org</a> does:<br>
<br>
<action application="javascript" data="$${basedir}/scripts/read.js conf-getconfno.wav 5"/><br>
<action application="conference" data="${res}@default"/><br>
<br>
which appears to do exactly what wiki says you can't so I'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. The variables that begin with $$ are parsed once when FS starts and permanently 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't do is set a variable in one action of your dialplan and then expect that variable to be set to do more <condition> tags inside that same dialplan.<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>
4) My other thought was to have the javascript call the voicemail<br>
application after parsing the DTMF. I.e.:<br>
<br>
switch (mode) {<br>
// Direct Inside Access<br>
case "00":<br>
if (isNaN (parseInt (from))) {<br>
console_log ("err", "Invalid VMAIL calling PDC from PBX\n");<br>
session.flushDigits ();<br>
exit();<br>
}<br>
<br>
session.setVariable ("voicemail_authorized", "false");<br>
apiExecute ("voicemail", "check default " + domain + " " + from);<br>
<br>
however the apiExecute doesn't seem to invoke voicemail. Probably<br>
because there's a difference between invoking an application and<br>
an api. So, how do you invoke an application from a javascript<br>
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("voicemail", "<voicemail args>");<br>
session.execute("transfer", "<some ext that leads to voicemail>");<br> <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>
| Feith Systems | Voice: 1-215-646-8000 | Email: <a href="mailto:john@feith.com">john@feith.com</a> |<br>
| John Wehle | Fax: 1-215-540-5495 | |<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