I encountered the following error message:
Error: No response has been set. Is this being used in an async call that was not returned as a promise to the intent handler?
at DialogflowConversation.response (/user_code/node_modules/actions-on-google/dist/service/actionssdk/conversation/conversation.js:162:19)
at DialogflowConversation.serialize (/user_code/node_modules/actions-on-google/dist/service/dialogflow/conv.js:134:89)
at Function.<anonymous> (/user_code/node_modules/actions-on-google/dist/service/dialogflow/dialogflow.js:154: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)
Below is the code snippet where I believe the issue lies. I have utilized promises, but please correct me if I'm mistaken in their implementation.
public getTodaysEntryOfUser(conv: any) : any {
this.getDataFromDatabase(conv).then((todaysEntry) => {
conv.ask('<speak>Welcome to my application <break time="1"/> </speak>');
let question:Question = this.getStartQuestion(1);
conv.ask('<speak>'+question.ask+'</speak>');
conv.data.kind = question.resolution.kind;
return question;
})
.catch(err => {
console.log('Error getting document', err);
return err;
});
}
Here's the code for the method "getDataFromDatabase":
public async getDataFromDatabase(conv: any) : Promise<any> {
let getPromise = await this.getDAOaccess(conv);
return getPromise;
}
And the code for the method "getDAOaccess":
private getDAOaccess(conv:any) : Promise<any>{
return new Promise<any>((resolve,reject) => {
this.getDataFromDB(conv,(err:any,response:any)=>{
if(err)
reject(err);
else
resolve(response);
});
});
}
Lastly, here's the code for the method "getDataFromDB":
private getDataFromDB(conv:any, callback: (err:any,response:any) => void ) : Promise<any> {
let self = this;
let documentDetail;
let subjectId = conv.request.user.userId;
let questionID = conv.request.user.questionID;
let docRef= this.dbManager.collection('question').doc(subjectId);
return new Promise((resolve, reject) => {
docRef.get().then(doc => {
documentDetail = doc;
conv.user.response= doc.data();
return resolve(doc.data());
})
.catch(err => {
console.log('Error getting document', err);
reject(err);
});
});
}
If you could help pinpoint the issue in the code, I would greatly appreciate it. Thank you in advance.