[英]Why is there no Carousel in @assistant/conversation
If not, I want to use more than two cards.如果没有,我想使用两张以上的卡。 If not, I want to know how to use List (list code example).
如果没有,我想知道如何使用 List(列表代码示例)。
Absolutely not Dialogflow code!绝对不是 Dialogflow 代码! I need the ActionsOnGoogle code.
我需要 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);
Looking for ActionsOnGoogleFulfillment document and example/sample code link.寻找 ActionsOnGoogleFulfillment 文档和示例/示例代码链接。
The Carousel type has been replaced by the Collection type, which does the same thing on most platforms. Carousel 类型已被Collection类型取代,后者在大多数平台上执行相同的操作。 The name reflects, however, that it may not display as a carousel everywhere, but will still represent a card-like layout.
然而,该名称反映了它可能不会在任何地方显示为轮播,但仍将代表卡片式布局。
For Visual Selection Responses such as Lists and Collections, defining the response is done in two parts:对于列表和集合等视觉选择响应,定义响应分两部分完成:
You'll create Type Overrides by adding something to the session.您将通过向会话添加内容来创建类型覆盖。 So it might look something like this:
所以它可能看起来像这样:
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,
}
},
]
}
}];
You would then create and add the Collection object, referencing the keys from the type you are declaring:然后,您将创建并添加 Collection 对象,从您声明的类型中引用键:
conv.add(new Collection({
title: 'Collection Title',
subtitle: 'Collection subtitle',
items: [
{
key: 'ITEM_1'
},
{
key: 'ITEM_2'
},
{
key: 'ITEM_3'
},
{
key: 'ITEM_4'
}
],
}));
});
doing this for a List instead would be similar.为 List 执行此操作将类似。 The entity type and visual components would be the same, but you'd define the list slightly differently:
实体类型和可视化组件是相同的,但您对列表的定义略有不同:
conv.add(new List({
title: 'List title',
subtitle: 'List subtitle',
items: [
{
key: 'ITEM_1'
},
{
key: 'ITEM_2'
},
{
key: 'ITEM_3'
},
{
key: 'ITEM_4'
}
],
}));
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.