Visual Studio C#中对话框流的Webhook响应问题

时间:2019-04-02 14:55:58

标签: c# visual-studio dialogflow webhooks fulfillment

我在使Webhook响应正常工作时遇到问题。在Dialogflow中,出现以下错误:

  

Webhook呼叫失败。错误:无法解析webhook JSON响应:   找不到字段:消息中的内容   google.cloud.dialogflow.v2.WebhookResponse

我的Visual Studio API控制器包含以下Webhook响应代码:

public dynamic Post([System.Web.Http.FromBody]WebhookRequest value)
    {
      var dialogflowResponse = new WebhookResponse
        {
            FulfillmentText = "Hello",
            FulfillmentMessages =
            {
                new Intent.Types.Message
                {
                    SimpleResponses = new Intent.Types.Message.Types.SimpleResponses
                    {
                        SimpleResponses_=
                        {
                            new Intent.Types.Message.Types.SimpleResponse
                            {
                                DisplayText = "Hello",
                                TextToSpeech = "Hi",

                            }
                        }
                    }
                }
            },

        };

        var jsonResponse = dialogflowResponse.ToString();

        return new Microsoft.AspNetCore.Mvc.ContentResult { Content = jsonResponse, ContentType = "application/json"}; 
    }

0 个答案:

没有答案