[英]How to clear custom slot value programmatically in Alexa?
I have an Alexa skill which requires to programmatically override the values given by the user. 我有一项Alexa技能,该技能需要以编程方式覆盖用户提供的值。
I have tried nullifying the value and later pass it in as the "updated Intent". 我尝试过取消该值,然后将其作为“更新的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. 但是,输入的JSON显示先前的值。 Is there a solution to this?
有针对这个的解决方法吗?
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;
For the version V2 you should update the intent in this way (as far as I know) 对于版本V2,您应该以这种方式更新意图(据我所知)
handlerInput.responseBuilder
.addDelegateDirective(newIntent)
.getResponse();
newIntent
should be an object where you can set your new slot values, for example : newIntent
应该是可以设置新插槽值的对象,例如:
const resetIntent = (handlerInput) => {
const intent = {
name : 'myIntentName',
confirmationStatus: 'NONE',
slots : {
slotOne: {
name: 'slotOne',
confirmationStatus: 'NONE'
}
}
}
return handlerInput.responseBuilder
.addDelegateDirective(intent)
.getResponse();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.