I'm developing a chatbot to provide support to workers in solving problems in a hypothetic assembly line. After the bot greets the user, it advices him to identify himself with his badge number. Then, if the user accepts the bot's prompt, the bot asks for which component in a list he needs support.
Every worker can manage only a subset of set of the assembly line components. My goal is to show to the user only the parts he is qualified to manage.
My question is about setting Quick Replies via Node.js webhook. Here you can see
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {QuickReplies}= require('dialogflow-fulfillment');
const https=require('https');
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
function getAllowedParts(agent){
/* deleted all unuseful details*/
agent.add(new QuickReplies(['A','B','C']);
} //close getAllowedParts
let intentMap = new Map();
intentMap.set('UserIntro', getAllowedParts);
agent.handleRequest(intentMap);
});
but it doesn't work, printing in console
TypeError: QuickReplies is not a constructor
I followed what I found here and I used the WebhookClient functions at https://github.com/dialogflow/dialogflow-fulfillment-nodejs/blob/master/docs/WebhookClient.md#WebhookClient+handleRequest .
The true problem is that I can't understand what is the correct procedure to add non-default quick replies using Node.js webhook in Dialogflow v2 . I also looked to the rich messages documentantion , but it found it very lacking on this topic. Any help will be appreciated, thanks
You should see commented out quick reply examples set in the default index.js file in Dialogflow's console.
agent.add(new Suggestion(`Quick Reply`));
agent.add(new Suggestion(`Suggestion`));
You can also see from the Github repo there's other available methods for Quick Replies:
let suggestion = new Suggestion('reply to be overwritten');
suggestion.setReply('reply overwritten');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.