Are you planning to change this at runtime? I seem to remember a post on the mailing list from very long time ago (years) changing global variables that were being read at the same time had a small risk of a race condition that might segfault.<div><br></div><div>If so that has almost certainly been fixed by now, but if not you could also look at using mod_hash or mod_db.</div><div><br></div><div>Your simple script can be done in xml by the way without lua using inline api calls in the condition&#39;s field attributes. Entirely personal preference which you use. Lua will fetch the variable just once so dies have that advantage.<span></span><br><div><br></div><div><br></div><div><br></div><div><br><br>On Thursday, 9 June 2016, Pete Ashdown &lt;<a href="mailto:pashdown@xmission.com">pashdown@xmission.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Answered my own question:<br>
<br>
In your dialplan:<br>
&lt;action application=&quot;lua&quot; data=&quot;script.lua&quot;/&gt;<br>
<br>
In script.lua:<br>
mode = freeswitch.getGlobalVariable(&quot;mode&quot;)<br>
if (mode == &quot;open&quot;) then<br>
  session:speak(&quot;open&quot;)<br>
end<br>
if (mode == &quot;techonly&quot;) then<br>
  session:speak(&quot;teck only&quot;)<br>
end<br>
if (mode == &quot;event&quot;) then<br>
  session:speak(&quot;event&quot;)<br>
else<br>
  session:speak(&quot;i dont know&quot;)<br>
end<br>
<br>
Make sure the global is created somewhere, like vars.xml:<br>
&lt;X-PRE-PROCESS cmd=&quot;set&quot; data=&quot;mode=open&quot;/&gt;<br>
<br>
<br>
On 06/07/2016 08:50 AM, Pete Ashdown wrote:<br>
&gt; What is the simplest way to have a conditional branch based on a global<br>
&gt; variable in a dialplan?  Actually using a global variable and xml is<br>
&gt; giving me mixed results.  Do I need to use Lua or another scripting<br>
&gt; language?<br>
&gt;<br>
&gt; This is what I have, which doesn&#39;t give the results desired.   The<br>
&gt; &quot;speak&quot; actions are merely debug placeholders.  I know there are better<br>
&gt; ways to do conditional voice to text.<br>
&gt;<br>
&gt;       &lt;condition regex=&quot;any&quot; field=&quot;${cond(${mode} == &#39;open&#39; ? YES :<br>
&gt; NO)}&quot; expression=&quot;^YES$&quot;&gt;<br>
&gt;             &lt;action application=&quot;speak&quot; data=&quot;open&quot;/&gt;<br>
&gt;       &lt;/condition&gt;<br>
&gt;<br>
&gt;       &lt;condition regex=&quot;any&quot; field=&quot;${cond(${mode} == &#39;tech only&#39; ? YES<br>
&gt; : NO)}&quot; expression=&quot;^YES$&quot;&gt;<br>
&gt;             &lt;action application=&quot;speak&quot; data=&quot;teck only&quot;/&gt;<br>
&gt;       &lt;/condition&gt;<br>
&gt;<br>
&gt;       &lt;condition regex=&quot;any&quot; field=&quot;${cond(${mode} == &#39;event&#39; ? YES :<br>
&gt; NO)}&quot; expression=&quot;^YES$&quot;&gt;<br>
&gt;             &lt;action application=&quot;speak&quot; data=&quot;event&quot;/&gt;<br>
&gt;       &lt;/condition&gt;<br>
&gt;<br>
<br>
_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="javascript:;" onclick="_e(event, &#39;cvml&#39;, &#39;consulting@freeswitch.org&#39;)">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://confluence.freeswitch.org" target="_blank">http://confluence.freeswitch.org</a><br>
<a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="javascript:;" onclick="_e(event, &#39;cvml&#39;, &#39;FreeSWITCH-users@lists.freeswitch.org&#39;)">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></div>