Search code examples
dialogflow-esactions-on-googlefulfillment

How to exit conversation in DialogFlow Fullfilment for an Action


I have an action which is a simple word game and upon completing the game should exit the conversation. I want the action to support Google Assistant and speaker based devices ( mobile phone etc) so i am handling the intent in a general fashion.

const {WebhookClient} = require('dialogflow-fulfillment');
...
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
  ...
  function answerIntent(agent) {
     if (gameShouldEnd) {
       agent.end("Your score is 3/5. Cheers! GoodBye!");
     }
  }
  ...
}

This results in log error MalformedResponse: 'final_response' must be set

I tried the conv api too and that results in the same error.

const {WebhookClient} = require('dialogflow-fulfillment');
...
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
  ...
  function answerIntent(agent) {
    if (gameShouldEnd) {
      let conv = agent.conv();
      conv.tell("Your score is 3/5. Cheers! GoodBye!");
      agent.add(conv);
    }
  }
  ...
}

Please suggest how to close the Mic when the game ends and still sends a response.


Solution

  • Seems there is an issue with version 0.5.0 of the dialogflow-fullfillment package according to the issue logged https://github.com/dialogflow/dialogflow-fulfillment-nodejs/issues/149

    I tried updating to 0.6.0 which has breaking changes which solved the current question i posted but created context related problems.