代码之家  ›  专栏  ›  技术社区  ›  Dmytro Rostopira

无法向Google Assistant发送通知(目标意图不是有效的可更新意图。)

  •  0
  • Dmytro Rostopira  · 技术社区  · 6 年前

    当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' } }
    

    我正在使用Dialogflow for intents,但找不到创建“有效的可更新意图”的位置

    1 回复  |  直到 6 年前
        1
  •  0
  •   Dmytro Rostopira    6 年前

    我发现由通知触发的意图必须添加到隐式调用中。 要执行此操作,请转到Dialogflow控制台主菜单->集成->Google Assistant集成设置并将您的意图(在我的示例中是get\u location)添加到隐式调用中。 这解决了问题