<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hello all<div class=""><br class=""></div><div class="">We’re using scripts now, in particular with the v8 engine. So far so good, but a couple of questions I’m hoping someone can answer:</div><div class=""><br class=""></div><div class="">1. How do we terminate the script early? I’ve tried ‘return;’ but that doesn’t seem to do it?</div><div class=""><br class=""></div><div class="">2. What’s the best way to invoke a delay? ...see the second part of the script below, the standard js ways of waiting generate syntax errors, and using ‘session.execute’ with sleep isn’t fixing it… the problem we’re getting is that either the outgoing message is part of the way through by the time it connects, or if the call is going to a person, it’s possible to answer the call before the audio has established (this might be two separate issues though I guess)...<br class="">
<br class=""></div><div class=""><br class=""></div><div class=""><div class=""><font face="Menlo" class="">re = session.destination.match(/^555555555$/);</font></div><div class=""><font face="Menlo" class="">if(re) {</font></div><div class=""><font face="Menlo" class=""> if(office_open) {</font></div><div class=""><font face="Menlo" class=""> session.setVariable("call_timeout", 8);</font></div><div class=""><font face="Menlo" class=""> session.setVariable("hangup_after_bridge", true);</font></div><div class=""><font face="Menlo" class=""> session.setVariable("continue_on_fail", true);</font></div><div class=""><font face="Menlo" class=""> session.execute("export", "alert_info=Bellcore-dr4");</font></div><div class=""><font face="Menlo" class=""> session.execute("db", "insert/call_pickup_uuid/201/" + session.uuid);</font></div><div class=""><font face="Menlo" class=""> session.answer();</font></div><div class=""><font face="Menlo" class=""> session.streamFile(“custom/open.wav");</font></div><div class=""><font face="Menlo" class=""> session.execute("bridge", "user/201@" + domain);</font></div><div class=""><font face="Menlo" class=""> session.setVariable("call_timeout", 30);</font></div><div class=""><font face="Menlo" class=""> session.execute("bridge", "group/mainq@" + domain);</font></div><div class=""><font face="Menlo" class=""> } else {</font></div><span style="font-family: Menlo;" class=""> session.answer();</span><div class=""><font face="Menlo" class=""> await sleep(1000); <font color="#ff2600" class="">// tried this</font></font></div><div class=""><font face="Menlo" class=""> setTimeout(function() { <font color="#ff2600" class="">// and this</font></font></div><div class=""><font face="Menlo" class=""> session.streamFile(“custom/closed.wav”); </font><span style="color: rgb(255, 38, 0); font-family: Menlo;" class="">// but this has already started</span></div><div class=""><font face="Menlo" class=""> session.setVariable("skip_greeting", true);</font></div><div class=""><font face="Menlo" class=""> session.setVariable("skip_instructions", true);</font></div><div class=""><font face="Menlo" class=""> session.execute("voicemail", "default " + domain + " 201");</font></div><div class=""><font face="Menlo" class=""> }, 1000);</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class=""> }</font></div><div class=""><font face="Menlo" class="">}</font></div></div></body></html>