“Simple things should be simple, complex things should be possible.” – Alan Kay
One of the things we’ve done with Tropo is balanced simplicity and power. We’ve made it easy to build a basic application, including speech recognition. Our API uses intelligent defaults, ensuring that for most applications you don’t have to configure every detail. We’ve done it for you already. And we’ve taken complex concepts like voice recognition grammars and created simpler languages for writing them.
Consider if you have an application that asks a caller for their credit card number, expiration date, and three digit CCV security code. Here’s the code (in Javascript) you might use for that, assuming that a card number is 16 digits long.
ask('What is your credit card number?', {choices: '[16 DIGITS]'});
ask('What is the expiration month?', {choices: 'January, February, March, April, May, June, July, August, September, October, November, December'});
ask('What is the expiration year?', {choices: '2010, 2011, 2012, 2013, 2014'});
ask('What is your C C V code?', {choices: '[3 DIGITS]'});
Pretty simple, right?
Now lets start looking at how you can extend your app by drilling into Tropo’s powerful API.
A number of CVV codes are 4 digits instead of 3. We need to handle both cases. Easy enough.
ask('What is your C C V code?', {choices: '[3-4 DIGITS]'});
Now you’d like to validate that the credit card number passes MOD10 before you accept it. So you’d like to add a validation routine.
event = ask('What is your credit card number?', {
choices: '[16 DIGITS]',
onChoice: function( event ) { validateCard(event.choice) }
})
Now you notice that people tend to pause a lot when saying their number and Tropo takes their silence to mean they’re done giving it. You can adjust the silence timeout.
event = ask('What is your credit card number?', {
choices: '[16 DIGITS]',
silenceTimeout: 10 }
})
Perhaps for added security, you don’t want people saying their number out loud, so you restrict it to touch tone input.
ask('Using your telephone keypad, please enter your credit card number.', {
choices: '[16 DIGITS]',
mode: 'dtmf'
})
Now that you’re doing DTMF input, maybe you want the caller to tell you they are done, instead of waiting for the system to recognize it.
ask('Using your telephone keypad, please enter your credit card number. Press pound when finished.', {
choices: '[16 DIGITS]',
mode: 'dtmf',
terminator: '#'
})
In your usability testing, you find that callers are starting immediately entering their card number, and you have instructions you want to make sure they hear first. So you don’t want to accept input until you’re done asking the question.
ask('Using your telephone keypad, please enter your credit card number.', {
choices: '[16 DIGITS]',
bargein: false
})
Most of your calls come in the morning, and you notice a high number of declined transactions because your callers tend to talk with a mouth full of cereal when they give their expiration month. Tropo keeps thinking they say ‘November’ when they’ve really said ‘December’. To combat this, you can tell Tropo to be more confident in it’s recognition, repeating the question up to five times if it’s not sure.
ask('What is the expiration month?', {
choices: 'January, February, March, April, May, June, July, August, September, October, November, December',
minConfidence: '0.9',
repeat: 5
});
Some callers say their expiration month as a number instead of the month name. So you add support for that.
ask('What is the expiration month?', {
choices: 'January(1, 01, january), February(2, 02, february), ... December(12, december)'
});
You’d really like to allow a caller to give their expiration date all at once, instead of asking for the month and year separately. But how do you write a grammar that can do that? Tropo supports a number of sophisticated grammar formats that can be used to write very powerful grammars. An example is a credit card expiration grammar that we’ve built as a sample.
Put that grammar at a URL and replace your choices with a URL, and Tropo will fetch that grammar for you and use it.
ask('When does your credit card expire?', {
choices: 'http://example.com/credit_card_expiration.gsl'
});
Tropo uses the content type of the file to figure out what type of grammar it is. Don’t have your web server set up to serve “gsl” as the right content type? No problem you can give Tropo a hint.
ask('When does your credit card expire?', {
choices: 'http://example.com/credit_card_expiration.gsl;type=text/gsl'
});
Those are just some of the things you can do with Tropo’s Ask function. All of Tropo’s other functions have the same simplicity with access to the raw power underneath. And all these things work on either the Scripting API or the WebAPI.
Of course, you don’t need to do any of these things if you don’t want. Tropo handles the simple cases just fine without any configuration on your part. But this way, as you develop your app on Tropo, you can be confident that your application can grow to handle anything you want to throw at it.