从用 Python 为 DialogFlow 编写的自定义 Webhook 创建卡片响应



>我用 python3 编写了一个 webhook 并在我自己的机器中部署了 FulfillmentText 中提供的文本正确显示,但未显示带有卡片的丰富响应。 如何使用基本卡片显示我的响应?

{
"fulfillmentText": "My train is in Hyderabad",
"fulfillmentMessages": [
{
"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/"
}
]
}
}
]
}

这是我的代码,试图以卡片的形式显示内容,这正是对话流和司陆所期望的响应格式 https://dialogflow.com/docs/fulfillment

{   
"payload": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{   
"simpleResponse": {
"textToSpeech": ""
}   
},  
{   
"basicCard": {
"title": "Train",
"image": {
"url": "https://8e39b052.ngrok.io/train.jpg",
"accessibilityText": "Train Image"
},  
"buttons": [
{   
"title": "WhereIsMyTrain",
"openUrlAction": {
"url": "https://whereismytrain.in/"
}   
}   
],  
"imageDisplayOptions": "WHITE"
}   
}   
]   
}   
}   
}   
}   

这对我有用,我之前没有将其作为有效载荷发送

最新更新