I am creating a Questionnaire bot for smart speakers that asks a user several questions. And the answers are stored in firebase. I am using node.js, actions-on-google.
It conversation looks like this:
- Bot: Hi user, Are you ready to answer the questions? [welcome intent, with Yes/No folllow up intents]{output context = q1}
- User: Yes
- Bot: What is your answer for Q1? [intent q1]{input context = q1, output context = q2}
- User: Here is my answer.
- Bot: What is your answer for Q2? [intent q2]{input context = q2, output context = q2}
- ...
- ...
- User: Here is my answer.
- Bot: Thank you for answering. Bye.
In this conversation, if the the user does not respond (no.input), I want to handle it in fulfillment.
For no.input, I am using the code from: https://developers.google.com/assistant/conversational/reprompts#dialogflow_2. I have an intent 'No Input Prompt' with 'action and parameters' no.input. This intent does not have follow up intents or any contexts.
My question is: How can I provide a custom re-prompt for each intent on the event of no.input?
I am doing something like this:
const { dialogflow, SignIn, Confirmation } = require('actions-on-google');
const functions = require('firebase-functions');
const app = dialogflow({
debug: true
});
const admin = require("firebase-admin");
admin.initializeApp({
credential: admin.credential.applicationDefault(),
databaseURL: 'DATABASE URL',
});
const db = admin.firestore();
const db_ref = db.collection('users');
let current_context = '';
app.intent('q1', (conv, {response}) =>{
const payload = conv.user.profile.payload
db_ref.doc(`${payload.email}`).collection(today).doc('q1').set({
answer: response,
timestamp: time
});
current_context='q1';
conv.ask(question('Whats your answer for q1?'));
})
app.intent('No Input Prompt', (conv) => {
const repromptCount = parseInt(conv.arguments.get('REPROMPT_COUNT'));
if(current_context === 'q1'){
if (repromptCount === 0) {
conv.ask("What is your answer for Q1?");
} else if (repromptCount === 1) {
conv.ask("What is your answer for Q1? You can say option 1,2,3 or 4");
} else if (conv.arguments.get('IS_FINAL_REPROMPT')) {
conv.close("Lets talk some other time.");
}
}
})
With this code, when I simulate no input, I get this error:
Failed to parse Dialogflow response into AppResponse because of invalid platform response: Could not find a RichResponse or SystemIntent in the platform response for agentId: 12ae4038-8f17-4005-9bfa-1691ffcde5e5 and intentId: 218605f2-e718-47e0-97f6-e1925755fa7c