In this piece of code, the applicationId of the context is priority rather than the one in the event:
if (event.context) {
requestAppId = event.context.System.application.applicationId;
userId = event.context.System.user.userId;
} else if (event.session) {
requestAppId = event.session.application.applicationId;
userId = event.session.user.userId;
}
And that's fine in long audio cases. However, right now the alexa service is returning this context in a skill with no long-form audio:
"context": {
"System": {
"application": {
"applicationId": "applicationId"
},
"user": {
"userId": "userId",
"permissions": {
"consentToken": "consentToken"
},
"accessToken": "accessToken"
},
"device": {
"deviceId": "deviceId",
"supportedInterfaces": {}
},
"apiEndpoint": "apiEndpoint"
}
}
The result is that requestAppId = 'applicationId'
I ran into this problem also. After debugging some more, I found that this only happens when you send a request from the developer console. It works from a device.
Based on the values in the json output you pasted, it looks like this is coming from the Skill simulator.
Service Simulator does not currently support testing audio player directives, dialog model, customer permissions and customer account linking.
You'll need to test audio player directives on a device.
@bclement-amazon Do you know if service simulator will support testing these features in the future? The reason is that testing in the simulator is simply more convenient.
As a skill developer myself, I completely agree with you - it's far more convenient!
Unfortunately, I don't know if/when these features would be supported. I know they are working to expand the feature set as Display.RenderTemplate directives now show up in the simulator!
@bclement-amazon I wasn't really testing audio or any other templates, it was a simple skill but since the context property is present in the JSON input, the SDK is taking the value in context.System.application.applicationId. So, probably the SDK logic is fine but the Alexa Voice Service should return the right applicationId in that path.
It's ok if the device is returning the right value, but we developers definitely need the service simulator for testing.
exports.handler = function(event, context, callback) {
// fix broken skill simulator json
event.context.System.application.applicationId = event.session.application.applicationId;
event.context.System.user.userId = event.session.user.userId;
var app = Alexa.handler(event, context);
I have added the two lines before the Alexa.handler function to use the skill simulator. Hopefully, the problem will be fixed soon
Hi everyone.
I've get applicationId matching error; _The applicationIds don't match: applicationId and amzn1.ask.skill.*_
Let's discover the source.
in _alexa-sdk/lib/index.js_
if (handlerAppId && (requestAppId !== handlerAppId)) {
console.log(`The applicationIds don\'t match: ${requestAppId} and ${handlerAppId}`);
It means that, _requestAppId_ variable is undefined. (If you couldn't figure out why, check the error message I've got again.) Continue discovering;
// Long-form audio enabled skills use event.context
if (event.context) {
requestAppId = event.context.System.application.applicationId;
userId = event.context.System.user.userId;
} else if (event.session) {
requestAppId = event.session.application.applicationId;
userId = event.session.user.userId;
}
Here is where _requestAppId_ defined. It smells like there is a problem here. Why my requests generates event.context? It's not a audio skill. It should get the parameter from event.session instead of context. I've edited the SDK to avoid from error temporarily but I'm sure that it should be a better solution. I see that everyone did the same.
Most helpful comment
I have added the two lines before the Alexa.handler function to use the skill simulator. Hopefully, the problem will be fixed soon