为什么我在 Google 上的操作上收到 404 'App [my-project-id] was not found. The app preview may have expired.' 尝试推送通知?

Why am I getting a 404 'App [my-project-id] was not found. The app preview may have expired.' trying push notifications on my Actions on Google?

我正在关注 official instructions 如何将推送通知发送给允许的用户。

我能够按照所有说明进行操作,直到出现此代码 appMap.set('finish.push.setup', 函数(应用程序)) {

 if (app.isPermissionGranted()) {
    const intent = app.getArgument('UPDATE_INTENT');
    const userID = app.getArgument('UPDATES_USER_ID');
    // code to save intent and userID in your db
    app.tell("Ok, I'll start alerting you");
  } else {
    app.tell("Ok, I won't alert you");
  }
}

app.getArgument('UPDATE_INTENT') return undefined 并检查 JSON 看起来它根本不包含意图,但我只有一个意图配置更新所以我在代码中硬编码了它的名字。 我得到了一个用户 ID,我也在代码中对其进行了硬编码。

然后我按照说明获取服务帐户密钥,并将 JSON 密钥保存在本地。

然后讨厌的问题开始了。 我使用 npm install googleapis request --save 安装了所需的软件包并复制了代码

const google = require('googleapis');
const key = require(PATH_TO_KEY);

let jwtClient = new google.auth.JWT(
  key.client_email, null, key.private_key,
  ['https://www.googleapis.com/auth/actions.fulfillment.conversation'],
  null
);

jwtClient.authorize(function (err, tokens) {
  // code to retrieve target userId and intent
  let notif = {
    userNotification: {
      title: '',
    },
    target: {
      userId: '',
      intent: ''
    }
  }

  request.post('https://actions.googleapis.com/v2/conversations:send', {
    'auth': {
      'bearer': tokens.access_token
     },
    'json': true,
    'body': { 'customPushMessage': notif }
  }, function(err,httpResponse,body) {
     console.log(httpResponse.statusCode + ': ' + httpResponse.statusMessage)
  });
});

我编辑了它,设置了我的密钥的正确路径,并用固定值编辑了通知 属性(在操作中配置的相同标题,由 dialogflow 编辑的用户 ID return 和我的意图)。

然后我注意到代码缺少 const request = require('request'); 和行

let jwtClient = new google.auth.JWT(

报错所以改成

let jwtClient = new google.google.auth.JWT(

我添加了一个 console.log('body', body); 只是为了获取更多数据,我得到了

body { error:
   { code: 404,
     message: 'App [my-project-id] was not found. The app preview may have expired.',
     status: 'NOT_FOUND' } }

我是不是做错了什么,或者文档中还有其他错误,我仍然需要找出来?

尝试在目标对象处添加 locale

   let notif = {
    userNotification: {
      title: '',
    },
    target: {
      userId: '',
      intent: '',
      locale: ''
    }
  }

对于语言环境,请遵循 IETF BCP-47 语言代码 here

默认Google操作使用en-US语言,我发现你使用的是不同的语言代码,所以系统回复说找不到你的应用程序的我们版本。