2

在 Web 或应用程序中启用时,相关技能要求一项权限(出站通知)。但是,当实施技能启用事件时,它不会要求用户给予通知权限。技能启用本身有效,但默认情况下权限为否。如何让alexa在通过语音启用时请求权限?

Alexa 可以通过语音提示他们启用出站通知吗?

技能.json

{
"manifest": {
    "publishingInformation": {
        "locales": {
            "en-US": {
                "summary": "test skill summary",
                "examplePhrases": [
                    "Alexa, launch test skill",
                    "Alexa, open test skill",
                    "Alexa, start test skill"
                ],
                "keywords": [
                    "test skill"
                ],
                "name": "test skill",
                "description": "test skill Description",
                "smallIconUri": "",
                "largeIconUri": "",
                "updatesDescription": ""
            }
        },
        "isAvailableWorldwide": true,
        "testingInstructions": "n/a",
        "category": "EVENT_FINDERS",
        "distributionCountries": [],
        "automaticDistribution": {
            "isActive": false
        }
    },
    "apis": {
        "custom": {
            "endpoint": {
                "uri": "arn:aws:lambda:us-east-1:"
            },
            "interfaces": []
        }
    },
    "manifestVersion": "1.0",
    "privacyAndCompliance": {
        "allowsPurchases": false,
        "locales": {
            "en-US": {
                "privacyPolicyUrl": "",
                "termsOfUseUrl": ""
            }
        },
        "isExportCompliant": true,
        "containsAds": false,
        "isChildDirected": false,
        "usesPersonalInfo": false
    },
    "events": {
        "endpoint": {
            "uri": "arn:aws:lambda:us-east-1:"
        },
        "publications": [
            {
                "eventName": "AMAZON.MessageAlert.Activated"
            },
            {
                "eventName": "AMAZON.MediaContent.Available"
            }
        ],
        "regions": {
            "NA": {
                "endpoint": {
                    "uri": "arn:aws:lambda:us-east-1:",
                    "sslCertificateType": "Trusted"
                }
            }
        },
        "subscriptions": [
            {
                "eventName": "SKILL_PROACTIVE_SUBSCRIPTION_CHANGED"
            },
            {
                "eventName": "SKILL_ENABLED"
            },
            {
                "eventName": "SKILL_DISABLED"
            },
            {
                "eventName": "SKILL_PERMISSION_ACCEPTED"
            },
            {
                "eventName": "SKILL_PERMISSION_CHANGED"
            },
            {
                "eventName": "SKILL_ACCOUNT_LINKED"
            }
        ]
    },
    "permissions": [
        {
            "name": "alexa::devices:all:notifications:write"
        }
    ]
}

}

感谢您的帮助

4

2 回答 2

2

可能有不同的方式,但一旦你掌握了这项技能,我相信你需要发送一张请求权限卡。据我了解,这个想法是确保亚马逊作为第三方权限授予者参与其中。这将在用户手机上的 Alexa 应用程序中弹出一个权限请求。这一增加的安全层只是确保客户准确地看到他们授予的权限。

你可以用你的技能用几种不同的方式做到这一点。您可以检查用户第一次连接的时间,并在持久的客户数据层中跟踪第一次连接。或者,您可以在使用该部分技能时检查用户是否具有权限。如果他们没有回应,告诉客户您向他们发送了一张卡片以授予权限。

以下是有关许可卡的更多信息: https ://developer.amazon.com/en-US/docs/alexa/custom-skills/request-customer-contact-information-for-use-in-your-skill.html#请求客户同意的权限卡

于 2020-09-20T14:04:31.040 回答
1

要通过 lambda 运行提醒,其他权限可能是相同的格式。

const CreateReminderIntent = {

  canHandle(handlerInput) {
    const { request } = handlerInput.requestEnvelope;
    return request.type === 'IntentRequest' && request.intent.name === 'CreateReminderIntent';
  },

  async handle(handlerInput) {
    const { requestEnvelope, serviceClientFactory, responseBuilder } = handlerInput;
    const consentToken = requestEnvelope.context.System.user.permissions
      && requestEnvelope.context.System.user.permissions.consentToken;
    if (!consentToken) {
      return handlerInput.responseBuilder
        .addDirective({
          type: "Connections.SendRequest",
          name: "AskFor",
          payload: {
            "@type": "AskForPermissionsConsentRequest",
            "@version": "1",
            "permissionScope": "alexa::alerts:reminders:skill:readwrite"
          },
          token: "<string>"
        })
        .getResponse();
    }

    try {

      const speechText = "Great! I've scheduled a reminder for you";

      const ReminderManagementServiceClient = serviceClientFactory.getReminderManagementServiceClient();
      const reminderPayload = {
        "trigger": {
          "type": "SCHEDULED_RELATIVE",
          "offsetInSeconds": "10",
          "timeZoneId": "Europe/London"
        },
        "alertInfo": {
          "spokenInfo": {
            "content": [{
              "locale": "en-GB",
              "text": "Wash the dog"
            }]
          }
        },
        "pushNotification": {
          "status": "ENABLED"
        }
      };

      await ReminderManagementServiceClient.createReminder(reminderPayload);
      return responseBuilder
        .speak(speechText)
        .getResponse();

    } catch (error) {
      console.error(error);
      return responseBuilder
        .speak('Uh Oh. Looks like something went wrong.')
        .getResponse();
    }
  }
};

于 2020-09-21T22:00:12.983 回答