Skip to content

Commit

Permalink
Handle arrays and empty strings in conversation response
Browse files Browse the repository at this point in the history
  • Loading branch information
jt-nti committed Jan 31, 2017
1 parent 7378aae commit 1b4f5f0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions recipes/conversation/conversation.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,16 @@ textStream.on('data', function(str) {
console.log('error:', err);
} else {
context = response.context ; //update conversation context
conversation_response = response.output.text[0] ;
if (conversation_response != undefined ){

if (Array.isArray(response.output.text)) {
conversation_response = response.output.text.join(' ').trim();
} else {
conversation_response = undefined;
}

if (conversation_response){
var params = {
text: response.output.text[0],
text: conversation_response,
voice: config.voice,
accept: 'audio/wav'
};
Expand Down

0 comments on commit 1b4f5f0

Please sign in to comment.