question

newuser-6cad64d3-778a-47ae-8222-8447990a7043 avatar image

upsell is not working

I am trying to upsell here is the code of upsell

const HintIntentHandler = {

canHandle(handlerInput) {

return handlerInput.requestEnvelope.request.type === 'IntentRequest'

&& handlerInput.requestEnvelope.request.intent.name === 'HintIntent';

},

handle(handlerInput) {

const locale = handlerInput.requestEnvelope.request.locale;

const ms = handlerInput.serviceClientFactory.getMonetizationServiceClient();


// Determine if the customer has purchased the hint_pack

return ms.getInSkillProducts(locale).then(function(res) {

var product = res.inSkillProducts.filter(record => record.referenceName === 'hint_pack');

if (isEntitled(product)) {

const sessionAttributes = handlerInput.attributesManager.getSessionAttributes();

const index = sessionAttributes.currentHintIndex;


// Read all hints the customer has asked for thus far

let speechText = "Okay, here are your hints: ";

let i = 0;

while (i <= index) {

speechText += sessionAttributes.currentRiddle.hints[i] + ", ";

i++;

}

speechText += ". Here is your question again: "

+ sessionAttributes.currentRiddle.question;


// Update the current hint index, maximum of 3 hints per riddle

sessionAttributes.currentHintIndex = index === 2 ? 2 : (index + 1);

handlerInput.attributesManager.setSessionAttributes(sessionAttributes);


return handlerInput.responseBuilder

.speak(speechText)

.reprompt(sessionAttributes.currentRiddle.question)

.withSimpleCard('Level Up Riddles', speechText)

.getResponse();

} else {

return handlerInput.responseBuilder

.addDirective({

'type': 'Connections.SendRequest',

'name': 'Upsell',

'payload': {

'InSkillProduct': {

'productId': product[0].productId

},

'upsellMessage': upsellMessage

},

'token': 'correlationToken'

})

.getResponse();

}

});

}

};


const BuyIntentHandler = {

canHandle(handlerInput) {

return handlerInput.requestEnvelope.request.type === 'IntentRequest' &&

handlerInput.requestEnvelope.request.intent.name === 'BuyIntent';

},

handle(handlerInput) {

// Inform the user about what products are available for purchase

const locale = handlerInput.requestEnvelope.request.locale;

const ms = handlerInput.serviceClientFactory.getMonetizationServiceClient();


return ms.getInSkillProducts(locale).then(function(res) {

let product = res.inSkillProducts.filter(record => record.referenceName === "hint_pack");


return handlerInput.responseBuilder

.addDirective({

'type': 'Connections.SendRequest',

'name': 'Buy',

'payload': {

'InSkillProduct': {

'productId': product[0].productId

}

},

'token': 'correlationToken'

})

.getResponse();

});

}

};


and here is json

"request": {

"type": "Connections.Response",

"requestId": "amzn1.echo-api.request.da42e38b-4cfe-4ab3-8500-ddc7d93246fb",

"timestamp": "2019-09-18T14:48:59Z",

"locale": "en-US",

"status": {

"code": "200",

"message": "OK"

},

"name": "Upsell",

"payload": {

"purchaseResult": "ERROR",

"productId": "amzn1.adg.product.214ce17e-f466-4b08-9afa-215954c297ac",

"message": "Upsell was not presented."

},

"token": "correlationToken"

}

}

i dont know why i am getting error

alexa skills kitskillnode_jspurchasing
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Anand@Amazon avatar image
Anand@Amazon answered

Hey there,

Thanks for reaching out to us.

It would be helpful if you share your skill id with us.

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

newuser-41c5c561-3c1c-4d23-a734-1c484c09c378 avatar image
newuser-41c5c561-3c1c-4d23-a734-1c484c09c378 answered

Hi there - I've just experienced this error message, and for me the fix was simply shortening the content of the upsell message. I think there's an unwritten time or word limit in there somewhere. I don't know what the limit is, but I've now got just a couple of sentences and it works fine.

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

newuser-7827b813-6889-418c-b966-e2c2a582ce35 avatar image
newuser-7827b813-6889-418c-b966-e2c2a582ce35 answered

Hi.
I have exactly the same error.
Reducing the upsellMessage didn't work for now.

Still looking for a correct answer

(skillId : amzn1.ask.skill.d003bdcd-7182-4306-b349-fb4e76e1dcea)

1 comment
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

I didn't change anything and the error is now:

> Upsell was blocked due to lack of purchase permission
Looks like Amazon did something for Upsell in France.

0 Likes 0 ·