问题
I need to send (more than 2 responses) simple responses back to user during the invocation for particular intent. But it is restricted to 2 simple response as mentioned in actions on google documentation.
Is there any other way to send multiple responses?
回答1:
The short answer is no, you can't send back more than one SimpleResponse at a time.
There are, however, ways to work with this depending on your needs and making sure you are respecting good Visual UI design.
You can concatenate many of the items you're sending back into a single spoken paragraph.
So if you have list items like:
- Red
- Green
- Blue
You can concatenate them into a single string and might send back a single SimpleResponse with "The colors I have selected for you are red, green, and blue."
But be careful if you have a very long list. So if you have a list of 20 or so colors, you would not want to say "The colors I have selected are red, green, blue, yellow, brown, black, white, purple, lavender, peach, mauve, scarlet, gold, ruby, silver, teal, grey, orange, bronze, and pearl." In cases like this...
With lots of items, and particularly where you are expecting the user to be on a visual display device, you can say just a few of the items (say, the 3 most likely) and show a text blurb with even fewer and then use a List or Carousel to display a more complete set. This might look something like
conv.ask(new SimpleResponse({ speech: 'The colors I have selected for you include red, green, blue, and 17 more', text: 'Here are the colors I have selected for you.' }); conv.ask(new List({ items:{ red: {title: "red"}, green: {title: "green"}, blue: {title: "blue"}, // You get the idea pearl: {title: "pearl"} } };
If you are using just voice, consider ways to narrow that list down further. For example, you might report "I have 20 colors for you. Are you looking for something more reddish or more bluish?" and continuing to narrow it down.
As a final alternative, you might want to read just a short list of what is available, but indicate how many other choices they have and let them "audibly scroll" through the list. This isn't great, since it requires a lot of additional work on your part and your user, but it is a good option in some cases.
回答2:
I think you can pass multiple responses from your webhook in this way. basically once your webhook get a request from the dialogflow you will do the process and pass the fulfillmentText back as the response. so there you can convert your json object to string and pass it back. from the frontend application you can convert it back to json or what ever format you want and use it however you want.
A simple example form nodejs (webhook). the approach should be same for all languages
router.post('/web-hook', function(req, res, next) {
//do your process here
res.json({
'fulfillmentText': JSON.stringify([{response:"response 1"},{response:"response 2"},{response:"response 3"}])
});
})
来源:https://stackoverflow.com/questions/51587884/is-their-any-way-to-send-multiple-simple-response-in-dialogflow