Dialogflow v2 API - 卡片未在模拟器中显示
Dialogflow v2 API - cards not shown in the simulator
我有一个用于实现的网络钩子。
下面是响应的代码
let result_obj = {
"fulfillmentText": "This is a text response",
"fulfillmentMessages": [
{
"text": {
"text": [
"this is test"
]
}
},
{
"card": {
"title": "card title",
"subtitle": "card text",
"imageUri": "https://assistant.google.com/static/images/molecule/Molecule-Formation-stop.png",
"buttons": [
{
"text": "button text",
"postback": "https://assistant.google.com/"
}
]
}
}
]
}
以下是 dialogflow GUI 的结果
以下是我从模拟器 运行 或 Android phone
上的 Google 助手应用程序得到的结果
模拟器和 phone 都没有显示卡片。我在这里遗漏了一些明显的东西吗?
要在 Google 智能助理上显示卡片等丰富的响应,您必须使用响应 JSON 的 有效负载 部分,这是一个示例:
{
"fulfillmentText": "This is a text response",
"fulfillmentMessages": [],
"source": "example.com",
"payload": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "This is a Basic Card:"
}
},
{
"basicCard": {
"title": "card title",
"image": {
"url": "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png",
"accessibilityText": "Google Logo"
},
"buttons": [
{
"title": "Button Title",
"openUrlAction": {
"url": "https://www.google.com"
}
}
],
"imageDisplayOptions": "WHITE"
}
}
]
}
}
},
"outputContexts": [],
"followupEventInput": {}
}
查看 this github 存储库以获取所有富媒体响应的 JSON 格式。
我有一个用于实现的网络钩子。 下面是响应的代码
let result_obj = {
"fulfillmentText": "This is a text response",
"fulfillmentMessages": [
{
"text": {
"text": [
"this is test"
]
}
},
{
"card": {
"title": "card title",
"subtitle": "card text",
"imageUri": "https://assistant.google.com/static/images/molecule/Molecule-Formation-stop.png",
"buttons": [
{
"text": "button text",
"postback": "https://assistant.google.com/"
}
]
}
}
]
}
以下是 dialogflow GUI 的结果
以下是我从模拟器 运行 或 Android phone
上的 Google 助手应用程序得到的结果模拟器和 phone 都没有显示卡片。我在这里遗漏了一些明显的东西吗?
要在 Google 智能助理上显示卡片等丰富的响应,您必须使用响应 JSON 的 有效负载 部分,这是一个示例:
{
"fulfillmentText": "This is a text response",
"fulfillmentMessages": [],
"source": "example.com",
"payload": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "This is a Basic Card:"
}
},
{
"basicCard": {
"title": "card title",
"image": {
"url": "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png",
"accessibilityText": "Google Logo"
},
"buttons": [
{
"title": "Button Title",
"openUrlAction": {
"url": "https://www.google.com"
}
}
],
"imageDisplayOptions": "WHITE"
}
}
]
}
}
},
"outputContexts": [],
"followupEventInput": {}
}
查看 this github 存储库以获取所有富媒体响应的 JSON 格式。