Asterisk IVR Trixbox
This version is for older Asterisk implementation and uses the Flite TTS system.
// the xapcmd handles the cmd request by setting a special variable // that axc looks for and then looks for axc's response macro xapcmd(cmd, curexten) {
set(xapresponse=""); set(maxcount=5); if ("${curexten}" != "") { set(last_exten=${curexten}); }; NoOp(xapsend:${cmd});
START:
Wait(1); if ("${xapresponse}" != "") { Flite(${xapresponse}); set(xapresponse=""); return; } else { set(maxcount=${maxount}-1); if ("${maxcount}" != "0") { goto START; } else { return; }; };
}; // house-attendant is a possible entry point for home automation // If you specify your initial contexts within extensions.conf // then add something like the following to your default or // corresponding context to associate the attendant w/ dialing // the operator: // // exten => 0,1,Goto(house-attendant, s, 1) context house-attendant {
s => { Wait(1); Answer(); TIMEOUT(digit)=7; TIMEOUT(response)=10; Wait(1);
greeting:
Flite("welcome to the house attendant");
menu:
Flite("press 1 for current time"); Flite("press 2 for local weather"); Flite("press 3 for the heating status");
// specify a timeout so that the user comes back to the menu if no selection made
WaitExten(10); };
// each numeric extension is the "handler" for the xap command
1 => { &xapcmd(what time is it,1); goto s|menu; }; 2 => { &xapcmd(what is the weather like,2); goto s|menu; }; 3 => { &xapcmd(what is the status of Heating GO,2); goto s|menu; }; * => { if ("${last_exten}" != "") { goto ${last_exten}|1; } else { goto s|menu; }; }; o => goto s|menu; # => { Playback(goodbye); Hangup(); }; t => goto s|menu; i => { Playback(invalid); goto s|menu; };
};