Fixing event bug in ask() #7

Merged
merged 1 commit into from Jul 2, 2011

3 participants

@abv
abv commented Apr 8, 2011

The code in the README wasn't working as expected because of a bug is how the ask() was generating JSON. Specifically, the "Never heard of it." and "Speak up!" says never got spoken, because the JSON that was output, listed "What is your favorite programming language?" before any of the event specific says... and order apparently matters.

The PHP (from README):

$tropo->ask('What is your favorite programming language?', array(
'choices'=>'PHP, Ruby(Ruby, Rails, Ruby on Rails), Python, Java(Groovy, Java), Perl',
'event'=> array(
'nomatch' => 'Never heard of it.',
'timeout' => 'Speak up!',
)
));

What the JSON used to look like (this would say "What is your favorite programming language?" every time, no matter the event:

"say":[
{
"value":"What is your favorite programming language?"
},
{
"event":"nomatch",
"value":"Never heard of it."
},
{
"event":"timeout",
"value":"Speak up!"
}
]

What it looks like now (after the bug fix):

"say":[
{
"event":"nomatch",
"value":"Never heard of it."
},
{
"event":"timeout",
"value":"Speak up!"
},
{
"value":"What is your favorite programming language?"
},
]

@abv abv Bug fix. Event specific code wasn't getting spoken because the eventl…
…ess say came before the event says. And order of operations matters.
77876d3
@akalsey akalsey merged commit b221fc0 into tropo:master Jul 2, 2011
@fbartolini

I think there is still a bug here. Even though the json output is as shown after the bug fix, the "nomatch" event is still not working properly. I get a "fantastic, I love that too" repeated twice rather than the "Never heard of it"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment