const HelloWorldIntentHandler = {
canHandle(handlerInput) {
return handlerInput.requestEnvelope.request.type === 'CanFulfillIntentRequest'
},
handle(handlerInput) {
if(handlerInput.requestEnvelope.request.intent.name === 'Myname'){
return MynameHandler.handle(handlerInput);
}
const MynameHandler = {
handle(handlerInput) {
const speechText = 'ALex';
const repromtText = 'Please respond';
return handlerInput.responseBuilder
.speak(speechText)
.withCanFulfillIntent(
{
"canFulfill":"YES",
})
.getResponse();
}
};
{
"session":{
"new": true,
"sessionId":"SessionId.<My Session id>",
"application":{
"applicationId":"amzn1.ask.skill.<Application id>"
},
"attributes":{
"key": "string value"
},
"user":{
"userId":"amzn1.ask.account.<user id>
}
},
"request":{
"type":"CanFulfillIntentRequest",
"requestId":"EdwRequestId.<request id>",
"intent":{
"name":"Myname"
},
"locale":"en-US",
"timestamp":"2018-10-12T09:36:31Z"
},
"context":{
"AudioPlayer":{
"playerActivity":"IDLE"
},
"System":{
"application":{
"applicationId":"amzn1.ask.skill.<application id>"
},
"user":{
"userId":"amzn1.ask.account.<user id>"
},
"device":{
"supportedInterfaces":{
}
}
}
},
"version":"1.0"
}
I have been implementing CanfulFillIntentRequest
for many days, but no luck so far. I am using alexa-sdk-nodejs
v2. I am not able to build the response for CanfulFillIntent
. I tried implementing it in an exact way as stated in these documents.
https://developer.amazon.com/docs/custom-skills/understand-name-free-interaction-for-custom-skills.html
https://developer.amazon.com/docs/custom-skills/implement-canfulfillintentrequest-for-name-free-interaction.html.
This is my response handler .
return handlerInput.responseBuilder
.withCanFulfillIntent(
{
'canFulfill': 'MAYBE',
'slots':{
}
})
.getResponse();
}
const HelloWorldIntentHandler = {
canHandle(handlerInput) {
//return handlerInput.requestEnvelope.request.type === 'IntentRequest' || 'CanFulfillIntentRequest'
return handlerInput.requestEnvelope.request.type === 'CanFulfillIntentRequest'
// && handlerInput.requestEnvelope.request.intent.name === 'Myname' || 'HotelIntent';
},
handle(handlerInput) {
if(handlerInput.requestEnvelope.request.intent.name === 'Myname'){
return MynameHandler.handle(handlerInput);
}
};
When i run JSON code in manual JSON, It does not respond to the CanfulFillIntent
request and it gets redirected to error handler code.
The
withCanFulfillIntent()
response builder helper method is only available in ASK SDK for Node.js (Public Beta)Install public beta by
or use this in package.json
I tried your code with beta and got expected results: