Last active
September 6, 2018 11:19
-
-
Save nikhilym/dabb913fa8a8e0779dd126e2ba67da32 to your computer and use it in GitHub Desktop.
Adding ElicitSlotDirective through ASK Python SDK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Example directive, from https://developer.amazon.com/docs/custom-skills/dialog-interface-reference.html#elicitslot | |
from ask_sdk_model.dialog import ElicitSlotDirective | |
from ask_sdk_model import ( | |
Intent, IntentConfirmationStatus, Slot, SlotConfirmationStatus) | |
directive = ElicitSlotDirective( | |
slot_to_elicit="fromCity", | |
updated_intent=Intent( | |
name="planMyTrip", | |
confirmation_status=IntentConfirmationStatus.NONE, | |
slots={ | |
"toCity": Slot( | |
name="toCity", | |
confirmation_status=SlotConfirmationStatus.NONE), | |
"travelDate": Slot( | |
name="travelDate", | |
confirmation_status=SlotConfirmationStatus.NONE, | |
value="2017-04-21") | |
} | |
) | |
) | |
handler_input.response_builder.speak( | |
"200 dollors, do you want to pay?").ask( | |
"do you want to pay").add_directive(directive) | |
## Additionally, if there is a need to add resolutions in the updated intent, | |
## the user can add the following code | |
## Based on the example provided here : https://developer.amazon.com/blogs/alexa/post/5de2b24d-d932-4c6f-950d-d09d8ffdf4d4/entity-resolution-and-slot-validation | |
from ask_sdk_model.slu.entityresolution import ( | |
Resolutions,Resolution, ValueWrapper, Value, Status, StatusCode) | |
slots = { | |
"WeatherType": Slot( | |
name="WeatherType", | |
value="shower", | |
resolutions=Resolutions( | |
resolutions_per_authority=[ | |
Resolution( | |
authority="amzn1.er-authority.echo-sdk.<skill_id>.WEATHER_TYPE", | |
status=Status( | |
code=StatusCode.ER_SUCCESS_MATCH), | |
values=[ | |
ValueWrapper( | |
value=Value( | |
name="rain", | |
id="RAIN" | |
) | |
) | |
] | |
) | |
] | |
) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment