无法向 Google 助理发送通知(目标意图不是有效的可更新意图。)
Cannot send notification to Google Assistant (Target intent is not a valid updatable intent.)
我在 Google Assistant 的 Developer Preview 中成功实现了通知,但在发布此功能后它们就停止工作了。
jwtClient.authorize(function (err, tokens) {
let db = fbApp.database("https://[REDACTED].firebaseio.com/").ref();
//...
if (uid == undefined) {
res.status(404).send("Not found");
return
}
console.log(`Sending notification to ${uid}`)
let notif = {
userNotification: {
title: "this is test intent"
},
target: {
userId: uid,
intent: 'get_location'
}
}
requestLib.post('https://actions.googleapis.com/v2/conversations:send', {
'auth': {
'bearer': tokens.access_token
},
'json': true,
'body': { 'customPushMessage': notif, 'isInSandbox': true }
}, function(err,httpResponse,body) {
console.log(body);
res.status(httpResponse.statusCode).send(httpResponse.statusMessage);
});
});
响应为 400:请求正文如下
{ error:
{ code: 400,
message: 'Target intent get_location is not a valid updatable intent. Please check that the intent has been configured for updates.',
status: 'INVALID_ARGUMENT' } }
我正在使用 Dialogflow 进行 intent,但找不到在哪里创建 "valid updatable intent"
我发现必须将通知触发的意图添加到隐式调用中。
为此,转到 Dialogflow 控制台,主菜单 -> 集成 -> Google Assistant 集成设置,并将你的意图(在我的例子中是 get_location)添加到隐式调用。
这解决了问题
我在 Google Assistant 的 Developer Preview 中成功实现了通知,但在发布此功能后它们就停止工作了。
jwtClient.authorize(function (err, tokens) {
let db = fbApp.database("https://[REDACTED].firebaseio.com/").ref();
//...
if (uid == undefined) {
res.status(404).send("Not found");
return
}
console.log(`Sending notification to ${uid}`)
let notif = {
userNotification: {
title: "this is test intent"
},
target: {
userId: uid,
intent: 'get_location'
}
}
requestLib.post('https://actions.googleapis.com/v2/conversations:send', {
'auth': {
'bearer': tokens.access_token
},
'json': true,
'body': { 'customPushMessage': notif, 'isInSandbox': true }
}, function(err,httpResponse,body) {
console.log(body);
res.status(httpResponse.statusCode).send(httpResponse.statusMessage);
});
});
响应为 400:请求正文如下
{ error:
{ code: 400,
message: 'Target intent get_location is not a valid updatable intent. Please check that the intent has been configured for updates.',
status: 'INVALID_ARGUMENT' } }
我正在使用 Dialogflow 进行 intent,但找不到在哪里创建 "valid updatable intent"
我发现必须将通知触发的意图添加到隐式调用中。 为此,转到 Dialogflow 控制台,主菜单 -> 集成 -> Google Assistant 集成设置,并将你的意图(在我的例子中是 get_location)添加到隐式调用。 这解决了问题