WebhookResponse可以发送基本卡吗? [英] Can WebhookResponse send a Basic Card?

查看:71
本文介绍了WebhookResponse可以发送基本卡吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制定一项操作,我想退回一张基本卡,其中包含来自完整网钩的信息。我可以毫无问题地返回纯文本,使用WebhookResponse类在发送数据之前准备数据。我确实也使用BasicCard类创建了基本卡。

I'm developing an action and I want to return a basic card with information from a fullfilment webhook. I can return plain text with no problem, using WebhookResponse class for preparing the data before sending it. I did also create the basic card using BasicCard class.

我注意到WebhookResponse创建的响应与Google 文档。我在徘徊是否错过了新版本?或者,如果使用此类根本无法做到这一点?
响应丰富是我想返回的那种响应,但我无法弄清楚WebhookResponse类在哪里锁定。

I noticed the response the WebhookResponse creates is diferent from the example responses available on google documentation. I was wandering if there's a new version I missed? Or if this isn't at all possible using this class? "Rich responses" are the kind of response I want to return, but I can't figure out where that locks in with the WebhookResponse class.

这是我正在使用的代码:

Here is the code I'm using:

webhookResp = new WebhookResponse
{
    FulfillmentText = @"Fullfilment Phrase. ",
    FulfillmentMessages = 
    { new Intent.Types.Message
        { SimpleResponses = new Intent.Types.Message.Types.SimpleResponses
            { SimpleResponses_ =
                { new Intent.Types.Message.Types.SimpleResponse
                    {
                        DisplayText = @"Text",
                        TextToSpeech = @"The speech",
                        Ssml = $"<speak>The speech</speak>"
                    }
                }
            }
        },
      new Intent.Types.Message
        { BasicCard = new Intent.Types.Message.Types.BasicCard
            {
                Title = @"Card Title",
                Subtitle = @"Card Subtitle",
                FormattedText = @"Card Information",
                Buttons =
                { new Button
                    {
                        Title = @"Url",
                        OpenUriAction = new OpenUriAction
                        {
                            Uri = "url"
                        }
                    }
                }
            }
        }
    },
    Source = "my-app"
};

助手收到的json:

{
  "fulfillmentText": "Fullfilment Phrase. ",
  "fulfillmentMessages": [
    {
      "messageCase": 7,
      "text": null,
      "image": null,
      "quickReplies": null,
      "card": null,
      "payload": null,
      "simpleResponses": {
        "simpleResponses_": [
          {
            "textToSpeech": "The speech",
            "ssml": "<speak>The speech</speak>",
            "displayText": "Text"
          }
        ]
      },
      "basicCard": null,
      "suggestions": null,
      "linkOutSuggestion": null,
      "listSelect": null,
      "carouselSelect": null,
      "browseCarouselCard": null,
      "tableCard": null,
      "mediaContent": null,
      "platform": 0
    },
    {
      "messageCase": 8,
      "text": null,
      "image": null,
      "quickReplies": null,
      "card": null,
      "payload": null,
      "simpleResponses": null,
      "basicCard": {
        "title": "Card Title",
        "subtitle": "Card Subtitle",
        "formattedText": "Card Information",
        "image": null,
        "buttons": [
          {
            "title": "Url",
            "openUriAction": {
              "uri": "url"
            }
          }
        ]
      },
      "suggestions": null,
      "linkOutSuggestion": null,
      "listSelect": null,
      "carouselSelect": null,
      "browseCarouselCard": null,
      "tableCard": null,
      "mediaContent": null,
      "platform": 0
    }
  ],
  "source": "my-app",
  "payload": null,
  "outputContexts": [],
  "followupEven
  "sessionEntityTypes": []
}

在此先感谢您的帮助。
如果需要更多信息,请说:)

Thank you in advance for trying to help. If any information more needed please say :)

巴黎

推荐答案

问题是 Google.Cloud.Dialogflow.V2 包将Dialogflow用作客户端-而不用于Dialogflow履行。因此 WebhookResponse 通常是根据服务器的响应为您创建的

The problem is that the Google.Cloud.Dialogflow.V2 package is to use Dialogflow as a client - not to use for Dialogflow fulfillment. So the WebhookResponse is usually created for you based on the response that comes from the server. You're not expected to create it yourself.

要从Webhook发送响应,您将需要生成JSON并将其作为Webhook的回复返回。

To send a response from your webhook, you will need to generate the JSON and return it as the reply from your webhook.

此外,Dialogflow引用的 BasicCard Card 不同由Google的Actions使用。 Dialogflow具有通用的卡。表示,但不会将其翻译成Google的卡片上的操作。

In addition, the BasicCard that Dialogflow refers to is not the same as the Card that is used by Actions on Google. Dialogflow has a generic "Card" that it represents, but it does not translate this into the Actions on Google "Card".

这篇关于WebhookResponse可以发送基本卡吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆