我已经看到了大多数关于如何通过webhooks返回丰富内容的示例,只涉及基本的响应和Card。
https://github.com/dialogflow/fulfillment-webhook-nodejs/blob/master/functions/index.js
在dialogflow webhook V2响应中需要什么结构才能返回List或Carousel?
发布于 2018-08-09 08:08:11
如果您想将carousel和list与Dialogflow结合起来,您将需要导入actions-on-google
模块,因为并非所有的富响应都由Dialogflow单独支持。你可以在Actions on Google Rich Responses reference docs上看到。还有一个Fulfillment-Actions on Google sample
const { WebhookClient } = require('dialogflow-fulfillment');
const { Carousel } = require('actions-on-google');
conv.ask(new Carousel({
items: {
// Add the first item to the carousel
[SELECTION_KEY_ONE]: {
synonyms: [
'synonym of title 1',
'synonym of title 2',
'synonym of title 3',
],
title: 'Title of First Carousel Item',
description: 'This is a description of a carousel item.',
image: new Image({
url: IMG_URL_AOG,
alt: 'Image alternate text',
}),
},
// Add the second item to the carousel
[SELECTION_KEY_GOOGLE_HOME]: {
synonyms: [
'Google Home Assistant',
'Assistant on the Google Home',
],
title: 'Google Home',
description: 'Google Home is a voice-activated speaker powered by ' +
'the Google Assistant.',
image: new Image({
url: IMG_URL_GOOGLE_HOME,
alt: 'Google Home',
}),
},
// Add third item to the carousel
[SELECTION_KEY_GOOGLE_PIXEL]: {
synonyms: [
'Google Pixel XL',
'Pixel',
'Pixel XL',
],
title: 'Google Pixel',
description: 'Pixel. Phone by Google.',
image: new Image({
url: IMG_URL_GOOGLE_PIXEL,
alt: 'Google Pixel',
}),
},
},
}));
https://stackoverflow.com/questions/49074953
复制相似问题