If I originate an outgoing call from FreeSwitch and want to tts a phrase or play an audio once the call has been answered (i.e, someone answered their cell phone or I got their voicemail) then how do I detect that.
Otherwise, I've tried the following but it relies in getting the timing right which won't always work or looping the tts phrase over and over.
var s;
while (tryCalling()) {}
s.hangup();
exit();
function tryCalling() {
s = new Session("sofia/gateway/spa3102/12223334444@10.0.0.5:5061");
s.waitForAnswer(10000);
if (s.cause == "USER_BUSY") {
return true;
}
if (s.ready()) {
s.sleep(10000);
s.speak("cepstral","Callie","Hello from FreeSwitch");
}
return false;
}
Another way is to keep replaying the tts phrase by replacing
if (s.ready()) {
s.sleep(10000);
s.speak("cepstral","Callie","Hello from FreeSwitch");
}
with something like:
while (s.ready()) {
s.speak("cepstral","Callie","Hello from FreeSwitch");
}
Thanks. Mark.