Suggestions are not working for the v2 agent with the latest version of dialogflow-fulfillment
Steps to reproduce-:
const {Suggestion} = require("dialogflow-fulfillment");
let someSuggestion = new Suggestion('My Reply');
let conv = agent.conv();
conv.add("Hello");
conv.add(someSuggestion);
agent.add(conv);
Generates the following response
{"payload":{"google":{"expectUserResponse":true,"richResponse":{"items":[{"simpleResponse":{"textToSpeech":Hello"}},{"replies":["My Reply"]}]},"userStorage":"{\"data\":{}}"}},"outputContexts":[{"name":"projects/brucewayne-e700f/agent/sessions/1531903223104/contexts/_actions_on_google","lifespanCount":99,"parameters":{"data":"{}"}}]}
And the corresponding error on Dialogflow
expected_inputs[0].input_prompt.rich_initial_prompt: 'item[1]' must not be empty.
We want to use the conv object specifically because we also want to send a response and save user details in the conv() object.
The Action on Google integration you're using (with the conv object) is supported through a payload response. This means that the Actions on Google response is sent in lieu of any other response you've added with agent.add(..). If you'd like to add a suggestion chip for your Actions on Google response you'll need to add it via the conv object before adding it to your agents response as see below:
const {Suggestions} = require('actions-on-google');
const {Suggestion} = require("dialogflow-fulfillment");
// Response constants
const textResponseText = 'Hello';
const suggestionText = 'My Reply';
// generic responses
agent.add(textResponseText);
agent.add(new Suggestion(suggestionText););
// Actions on Google-specific responses
let conv = agent.conv();
conv.ask(textResponseText);
conv.ask(new Suggestions(suggestionText))
agent.add(conv);
I should also note that some platforms require a text, card or other responses for suggestion chips to work.
Please note that if you're planning on only using the Actions on Google integration you should use the Actions on Google library directly: https://github.com/actions-on-google/actions-on-google-nodejs
Thanks a lot for the reply.We've moved to using the actions on google SDK.
Most helpful comment
The Action on Google integration you're using (with the
convobject) is supported through a payload response. This means that the Actions on Google response is sent in lieu of any other response you've added withagent.add(..). If you'd like to add a suggestion chip for your Actions on Google response you'll need to add it via theconvobject before adding it to your agents response as see below:I should also note that some platforms require a text, card or other responses for suggestion chips to work.
Please note that if you're planning on only using the Actions on Google integration you should use the Actions on Google library directly: https://github.com/actions-on-google/actions-on-google-nodejs