我在使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"};
}