0

I have this code below in which I am trying to create a MediaObject to load an audio file, I am using the exact code from google here.

The error I get is final_response must be set. Even if I use conv.close as suggested by one answer here

What is the actual way to set final_response?

function yourFunctionHandler(agent) {
     agent.add(`This message is from Dialogflow's Cloud Functions for Firebase editor!`);
 let conv = agent.conv();
 conv.ask(new Suggestions('Suggestion Chips'));
 conv.close(new MediaObject({
  name: 'Jazz in Paris',
  url: 'https://storage.googleapis.com/automotive-media/Jazz_In_Paris.mp3',
  description: 'A funky Jazz tune',
  icon: new Image({
    url: 'https://storage.googleapis.com/automotive-media/album_art.jpg',
    alt: 'Media icon',
  }),
}));
conv.ask(new Suggestions(['suggestion 1', 'suggestion 2']));

  }
digi
  • 349
  • 2
  • 13
  • You are mixing conv.ask and conv.close in the same response. Is there a reason you're doing that? – Nick Felker Apr 29 '18 at 18:00
  • only one reason, nothing was working so I tried everything. :) – digi Apr 29 '18 at 18:18
  • I suspect that the problem isn't with the code you've included above, but with how your app is structured. Check [here](https://github.com/actions-on-google/dialogflow-webhook-template-nodejs/blob/master/functions/index.js) for an example (rather than just a snippet like you saw in the docs), and if you could include more of your code (specifically where you call app.intent) that would be helpful. – lukedavis Apr 30 '18 at 16:08
  • @lukedavis [this](https://gist.github.com/sherazlodhi/112e97cb881bfd38071fc386042c6ff1) is the complete code. and [this](https://gist.github.com/sherazlodhi/53dd79ac0212528209819901eb9360c4). both from google provided samples – digi Apr 30 '18 at 16:51

1 Answers1

0

When mixing the AoG client library and the Dialogflow fulfillment library the latter needs to have the conversation added explicitly with agent.add(conv) somewhere. Consider maybe adding agent.add(conv) on line 55 of your code here like the code here shows.

Also, conv.close ends the interaction, so just keep an eye on that as on line 54 you call conv.close and then conv.ask after it (which just won't be called and maybe will cause problems).

lukedavis
  • 384
  • 2
  • 7
  • thanks for the answer, Please check the latest code [here](https://gist.github.com/sherazlodhi/c5d350c15912226fc158299d9c48a9fa) , I still get the same error. and my package file [here](https://gist.github.com/sherazlodhi/fca21b5da2f870e11343fffd02e8bb35) – digi May 02 '18 at 11:23