小编ger*_*enq的帖子

如何在 ASP.Net Core 中使用 Google.Protobuf.WellknownTypes.Struct

我正在为我的 Google Dialogflow 代理实现一个 webhookreceiver 作为 ASP.Net Core Web 应用程序。为此,我使用 Google.Cloud.Dialogflow.V2(1.0.0-beta02) nuget 包。当 Dialogflow 匹配某个意图时,我希望我的 ASP Web 应用程序调用 TMDb API 来检索有关特定电影的信息。我想将此信息作为 google 卡片发送回 Dialogflow。为了将内容发送回 Dialogflow,我使用 WebhookResponse 类(由 Google.Cloud.Dialogflow.V2 提供)。现在我的问题在于如何匹配 Dialogflow 期望的模式,如下所示:

"messages": [
  {
    "buttons": [
      {
        "postback": "Card Link URL or text",
        "text": "Card Link Title"
      }
    ],
    "imageUrl": "http://urltoimage.com",
    "platform": "facebook",
    "subtitle": "Card Subtitle",
    "title": "Card Title",
    "type": 1
  }
]
Run Code Online (Sandbox Code Playgroud)

到目前为止我发现我需要上述 Json 作为 Webhook 响应的有效负载的一部分。(https://github.com/googleapis/google-cloud-dotnet/issues/2425#issuecomment-459885762

但使用Github评论中提供的方法很难匹配上述模式。我知道 Json 对象(一对大括号之间的所有内容)相当于这行代码

Value.ForStruct(new Struct { Fields = { ["expectUser"] …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core dialogflow-es

2
推荐指数
1
解决办法
2978
查看次数

标签 统计

asp.net-core ×1

c# ×1

dialogflow-es ×1