Ever wondered how to instrument an existing application for use with the NuBot IVR Testing Platform? My colleague Pascal wrote a helper function in Groovy for easy instrumentation of applications built using the Tropo Scripting API.
The trick is to define a closure encapsulating the playing of DTMF sequences (these sequences are required in order to synchronize the IVR application with the NuBot test scenario):
def sequencer = { sequence, closure ->
if (dtmfSequencerEnabled) {
for (dtmf in sequence) {
switch (dtmf) {
case "*":say("${baseAudioUrl}/dtmf/star.wav");;
case "#":say("${baseAudioUrl}/dtmf/pound.wav");
default:say("${baseAudioUrl}/dtmf/${dtmf.toLowerCase()}.wav");
}
}
}
if (closure) return closure()
}
Using this definition, one can instrument an application very easily:
sequencer("a") {
say("Hello. Thank you for calling the Travel Agency Customer Satisfaction Department")
};
The code, as well as a complete NuBot project and a few instrumented Tropo examples, is on github.
