首页 文章

从用python编写的自定义webhook创建卡片响应以进行对话框流程

提问于
浏览
2

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

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

1 回答

  • 0
    {   
    "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"
    }   
    }   
    ]   
    }   
    }   
    }   
    }
    

    这对我有用,我以前没有把它作为有效载荷发送

相关问题