如果没有,我想使用两张以上的卡片。如果没有,我想知道如何使用List (列表代码示例)。
绝对不是对话流代码!我需要ActionsOnGoogle代码。
const functions = require('firebase-functions');
const syncRequest = require('sync-request');
const express = require('express');
const {
conversation,
Simple,
Card,
Image,
Button,
List,
Table,
Carousel <-------------------------------(Carousel is not constructor ERROR)
} = require('@assistant/conversation');
const app = conversation({debug:true});
app.handle('callApi', (conv) => {
conv.add(new Card({
title: "hello1",
subtitle: "hi",
text: "blablablablablablablablablablablablablablablablablabla",
image: new Image({
url: "some url",
alt: "Some alternative text",
})
}), new Card({
title: "hello2",
subtitle: "ddddddddd",
text: "testtesttesttesttesttesttesttesttesttesttesttesttesttest",
image: new Image({
url: "some url",
alt: "Some alternative text",
})
}));----------------------------------------------------two Card doesn't it work
});
exports.ActionsOnGoogleFulfillment = functions.https.onRequest(app);
查找ActionsOnGoogleFulfillment文档和示例/示例代码链接。
发布于 2020-10-29 06:19:11
Carousel类型已经被集合类型所取代,它在大多数平台上都做同样的事情。然而,这个名字反映出,它不可能在任何地方都显示为旋转木马,但仍将表示一个类似卡片的布局。
对于列表和集合等视觉选择响应,定义响应分为两部分:
您将通过向会话添加一些内容来创建类型覆盖。所以看起来可能是这样的:
conv.session.typeOverrides = [{
name: 'prompt_option',
mode: 'TYPE_REPLACE',
synonym: {
entries: [
{
name: 'ITEM_1',
synonyms: ['Item 1', 'First item'],
display: {
title: 'Item #1',
description: 'Description of Item #1',
image: ASSISTANT_LOGO_IMAGE,
}
},
{
name: 'ITEM_2',
synonyms: ['Item 2', 'Second item'],
display: {
title: 'Item #2',
description: 'Description of Item #2',
image: ASSISTANT_LOGO_IMAGE,
}
},
{
name: 'ITEM_3',
synonyms: ['Item 3', 'Third item'],
display: {
title: 'Item #3',
description: 'Description of Item #3',
image: ASSISTANT_LOGO_IMAGE,
}
},
{
name: 'ITEM_4',
synonyms: ['Item 4', 'Fourth item'],
display: {
title: 'Item #4',
description: 'Description of Item #4',
image: ASSISTANT_LOGO_IMAGE,
}
},
]
}
}];
然后创建并添加Collection对象,引用您声明的类型中的键:
conv.add(new Collection({
title: 'Collection Title',
subtitle: 'Collection subtitle',
items: [
{
key: 'ITEM_1'
},
{
key: 'ITEM_2'
},
{
key: 'ITEM_3'
},
{
key: 'ITEM_4'
}
],
}));
});
相反,为列表执行此操作将是类似的。实体类型和可视化组件是相同的,但是定义列表的方式略有不同:
conv.add(new List({
title: 'List title',
subtitle: 'List subtitle',
items: [
{
key: 'ITEM_1'
},
{
key: 'ITEM_2'
},
{
key: 'ITEM_3'
},
{
key: 'ITEM_4'
}
],
}));
});
https://stackoverflow.com/questions/64591360
复制