Scenario 2: Set a default value for
departureCity and create a custom prompt to confirm that slot value
If your skill needs many slot values, it may frustrate users to answer many slot elicitations. In that case, your skill can set default values — but it should notify users of the values it assumes! For example, if the Flight Booker skill is only available to New York travelers, it may set “New York” as its default departure city, but it should inform its users via a slot confirmation:
this.emit(':confirmSlot', slotToConfirm, speechOutput, repromptSpeech, updatedIntent);
where the default slot value is set in
updatedIntent and mentioned in
How to access values
departureCity value and confirmation status like this:
How to set default values
Set the a default value for
departureCity by copying the existing intent and editing the value:
const updatedIntent = this.event.request.intent; updatedIntent.slots.departureCity.value = 'new york';
If the user does not provide a
departureCity, set the default value to
'new york' and confirm the slot. The skill should create conversations similar to those linked here.
You can move on when your code passes the following tests:
If the dialog is not completed and the
departureCityvalue HAS NOT been collected, update the intent so that the departure city is
'new york'and confirm the slot. The prompt must mention New York.
If dialog is not completed, there IS a
departureCityvalue, and its confirmation status is denied, then elicit that slot again.
You will need to write the
else if conditions for both of these.