从用python为dialog编写的自定义webhook创建卡响应

2024-05-16 15:18:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我用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/"
          }
        ]
      }
    }
  ]
}

这是我试图以卡片形式显示内容的代码这正是dialogflow aslo期望的响应格式 https://dialogflow.com/docs/fulfillment


Tags: texthttps文本com机器titlemy部署
1条回答
网友
1楼 · 发布于 2024-05-16 15:18:03
    {   
"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"
}   
}   
]   
}   
}   
}   
}   

这对我有用我以前不是作为有效载荷发送的

相关问题 更多 >