[英]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.