Search code examples
javascriptalexa-skills-kitalexa-slot

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.

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?


Solution

  • 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;