我已经成功地实现了Google Assistant在开发者预览版中的通知,但是在此功能发布后,它们停止了工作。
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' } }
我正在使用对话流作为意图,但找不到在哪里进行"有效的可更新意图">
我发现必须将通知触发的意图添加到隐式调用中。为此,请转到对话流控制台,主菜单 -> 集成 -> Google Assistant 集成设置,并将您的意图(在我的情况下get_location(添加到隐式调用中。这解决了问题