Search code examples
dialogflow-esdialogflow-es-fulfillment

How can i send Quick Replies to Facebook Through Dialogflow Fulfillment


I am trying to send Quick Replies to Facebook users through Dialogflow Fulfillment and I have not been able to achieve that I have tried a lot and have not succeeded Is there any help Codes i have tried:

#1 :

    function QuickReplies(agent) {
    agent.add(“Select one”);
    agent.add(new Suggestion(“Quick Reply”));
    agent.add(new Suggestion(“Suggestion”));
    }

#2 :

function QuickReplies(agent)
{
  const quickReplies1 = new Suggestion({
    title: "What do you want to do?",
    reply: "Next",
    platform: 'FACEBOOK'
  })
  quickReplies1.addReply_("Cancel");

  agent.add(quickReplies1);
}

Solution

  • So, the first step is to import the Suggestion module as:

    const {Suggestion} = require('dialogflow-fulfillment')
    

    Then you can do something like your first function (I do not see any problem in your code). Finally, you have to associate it with one of your intents:

    let intentMap = new Map();
    intentMap.set('Your intent's name', QuickReplies);
    agent.handleRequest(intentMap);
    

    Keep in mind that even if your intent has other components (text, cards) you can still append quick replies to it.