Mizlul
Mizlul

Reputation: 2280

Dialogflow Fullfilments responses

I have a case where I need to send an email when user types in something therefore I need to use the fulfillments using node.js and amazon for handling the email part but then I would like the response to be from dialogflow interface.

Currently I have something like this:

   let intentMap = new Map();
   intentMap.set('Default Welcome Intent', welcome);

   agent.handleRequest(intentMap);

   function welcome(agent) {
      var content = "Hello.\n\n"
                +""
                +"phone : " + agent.parameters.phoneNumber + ""
                +"\nIA";
      sendEmail("phone number", sendToEmail, content);
      agent.add(`Thank you`);
}

As you can see I want the response "Thank you" to be responded from Dialogflow Dashboard and i would remove the agent.add(Thank you).

Is this possible?

Upvotes: 1

Views: 318

Answers (1)

Sachit Mishra
Sachit Mishra

Reputation: 309

If "Thank you" is written as your Dialogflow intent Text Response, and your webhook responds with either a non-200 HTTP response or an invalid response, Dialogflow will fallback to the "Thank you" from the Text Response field in the intent.

Even better, Dialogflow's request to your webhook includes a fulfillmentText property which contains the text Dialogflow will use from the Text Response in the intent from the Dialogflow console. You can use this string in the agent.add call to ensure your webhook succeeds, and you still control the response from the console.

Upvotes: 3

Related Questions