问题
I have an Alexa skill which requires to programmatically override the values given by the user.
I have tried nullifying the value and later pass it in as the "updated Intent".
this.event.request.intent.userPrompt.value = null;
var updatedIntent = this.event.request.intent;
this.emit(':elicitSlot', 'userPrompt',"Say something","Say something", updatedIntent);
However, the input JSON shows previous value. Is there a solution to this?
回答1:
there is
delete this.event.request.intent.slots.<slotname>.value;
var updatedIntent = this event.request.intent;
this.emit(':elicitSlot', <slotname>,"Say something","Say something", updatedIntent);
if you have a slot with a custom slot type you also have to
delete this.event.request.intent.slots.<slotname>.resolutions;
回答2:
For the version V2 you should update the intent in this way (as far as I know)
handlerInput.responseBuilder
.addDelegateDirective(newIntent)
.getResponse();
newIntent
should be an object where you can set your new slot values, for example :
const resetIntent = (handlerInput) => {
const intent = {
name : 'myIntentName',
confirmationStatus: 'NONE',
slots : {
slotOne: {
name: 'slotOne',
confirmationStatus: 'NONE'
}
}
}
return handlerInput.responseBuilder
.addDelegateDirective(intent)
.getResponse();
}
来源:https://stackoverflow.com/questions/48090335/how-to-clear-custom-slot-value-programmatically-in-alexa