Dialogflow Webhook C# 集成

Dialogflow Webhook C# integration

什么是 Dialogflow webhook 格式?我想在 MVC 控制器中捕获数据,然后在维护上下文的同时响应 webhook。如何使用 Dialogflow v2 客户端库在 C# 中执行此操作?我没有找到任何可以遵循这种语言的示例,并且不确定如何捕获数据。

您可以阅读更多关于 Dialogflow webhook 格式的信息 here. Regarding the Dialoglow v2 client library, it is specifically stating,您不需要使用它并且可以在 JSON 中回答而不是使用 JObject

如果您想使用 Protobuf 来降低开销并节省一些流量,您将不得不使用前面 link 中描述的惯用云库中的实用程序。

"Dialogflow V2 client library" 适用于正在编写向 Dialogflow 发送 请求的客户端的人员。 Dialogflow 将此称为 "Detect Intent Request",因为您要向 Dialogflow 发送文本字符串(或音频流),它将确定并处理 Intent。

如果您有兴趣构建一个在 Intent 匹配时调用的 Fulfillment webhook,那么您想要查看不同的 Dialogflow Fulfillment API。目前尚无支持 C# 的库,但您可以解析 return 和 JSON。 V1 和 V2 的 JSON 略有不同(主要是在所用字段的名称上,但偶尔也会在值应该是什么上)。

您可以在 Dialogflow 中看到 fields for the JSON as well as several examples of the request and response formats. There was also an article on Medium recently posted by a Google Developer Relations member discussing using C# for fulfillment