[英]how to use the Permission helper intent from dialogflow in wehhook c#
我是 dialogflow 的新手,正在尝试使用权限处理程序来使用 .NET 核心 webapi 请求位置权限。 我在 dialogflow 控制台中创建了意图、实体和事件(google.assistent.permission)。 现在我想从我的 webapi 发送请求以发送访问位置的请求。
有人可以提供代码示例如何从我的 webhook 发送访问位置请求吗?
您需要将帮助程序意图 DialogFlow JSON作为有效负载的一部分包括在内:
WebhookResponse response;
Struct payload;
response.Payload = payload;
或者,它可以作为负载类型为1的履行消息添加。
可以从 JSON 解析有效负载结构:
response.Payload = Struct.Parser.ParseJson(@"{
""google"": {
""expectUserResponse"": true,
""systemIntent"": {
""intent"": ""actions.intent.PLACE"",
""data"": {
""@type"": ""type.googleapis.com/google.actions.v2.PlaceValueSpec"",
""dialogSpec"": {
""extension"": {
""@type"": ""type.googleapis.com/google.actions.v2.PlaceValueSpec.PlaceDialogSpec"",
""permissionContext"": ""To find a location"",
""requestPrompt"": ""Where would you like to go?""
}
}
}
}
}
}");
或者使用 Protobuf API 创建(由于跳过解析步骤和类型安全,速度稍快,但非常丑陋):
response.Payload = new Struct
{
Fields =
{
["google"] = Value.ForStruct(new Struct
{
Fields =
{
["expectUserResponse"] = Value.ForBool(true),
["systemIntent"] = Value.ForStruct(new Struct
{
// ... and so on
})
}
})
}
};
请记住,在有效负载中包含任何消息(这是调用帮助程序所必需的)将覆盖您之前添加的任何其他消息并忽略之后添加的任何消息(它们仍然是返回对象的一部分,但被 DialogFlow 删除)。 这意味着:如果您想要任何其他丰富的响应,目前还需要手动将其添加到有效负载中。 到那时,您还不如从头开始创建整个 JSON 响应。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.