codelabs-nodejs
codelabs-nodejs copied to clipboard
Error: A simple response is required in addition to this type of response
In Level 2 - Step 6 it describes how to add speech through SSML to our responses.
However when I follow the instructions I receive the following error in my firebase logs:
Error: A simple response is required in addition to this type of response
at DialogflowConversation.response (/user_code/node_modules/actions-on-google/dist/service/actionssdk/conversation/conversation.js:267:19)
at DialogflowConversation.serialize (/user_code/node_modules/actions-on-google/dist/service/dialogflow/conv.js:159:129)
at Function.<anonymous> (/user_code/node_modules/actions-on-google/dist/service/dialogflow/dialogflow.js:157:28)
at next (native)
at fulfilled (/user_code/node_modules/actions-on-google/dist/service/dialogflow/dialogflow.js:19:58)
at process._tickDomainCallback (internal/process/next_tick.js:135:7)
I can resolve this by modifying the favourite colour intent to look like this:
// Handle the Dialogflow intent named 'favorite color'.
// The intent collects a parameter named 'color'
app.intent('favorite color', (conv, {color}) => {
const luckyNumber = color.length;
const audioSound = 'https://actions.google.com/sounds/v1/cartoon/clang_and_wobble.ogg';
if (conv.data.userName) {
// If we collected user name previously, address them by name and use SSML
// to embed an audio snippet in the response.
conv.close(new SimpleResponse({
speech: `<speak>${conv.data.userName}, your lucky number is ` +
`${luckyNumber}.<audio src="${audioSound}"></audio></speak>`,
text: `${conv.data.userName}, your lucky number is ` + `${luckyNumber}.`,
}));
} else {
conv.close(new SimpleResponse({
speech: `<speak>Your lucky number is ${luckyNumber}.` +
`<audio src="${audioSound}"></audio></speak>`,
text: `Your lucky number is ` + `${luckyNumber}.`,
}));
}
});
Could be worth documenting, unless I missed something! -Thanks :)
Hi, can you show the code that threw the error for you?
It was the previously given implementation of favouriteColor from the linked page.
Currently it's:
// Handle the Dialogflow intent named 'favorite color'.
// The intent collects a parameter named 'color'
app.intent('favorite color', (conv, {color}) => {
const luckyNumber = color.length;
const audioSound = 'https://actions.google.com/sounds/v1/cartoon/clang_and_wobble.ogg';
if (conv.data.userName) {
// If we collected user name previously, address them by name and use SSML
// to embed an audio snippet in the response.
conv.close(`<speak>${conv.data.userName}, your lucky number is ` +
`${luckyNumber}.<audio src="${audioSound}"></audio></speak>`);
} else {
conv.close(`<speak>Your lucky number is ${luckyNumber}.` +
`<audio src="${audioSound}"></audio></speak>`);
}
});
not sure if it's the same