diff --git a/README.rst b/README.rst index 38ac343..715f3d7 100644 --- a/README.rst +++ b/README.rst @@ -245,6 +245,8 @@ Preview * `Alexa Presentation Language `__ +* `Name-free Interactions `_ + Got Feedback? ------------- diff --git a/ask-sdk-core/ask_sdk_core/response_helper.py b/ask-sdk-core/ask_sdk_core/response_helper.py index 8d51f46..b355d0f 100644 --- a/ask-sdk-core/ask_sdk_core/response_helper.py +++ b/ask-sdk-core/ask_sdk_core/response_helper.py @@ -26,6 +26,7 @@ from typing import Union from ask_sdk_model import Directive from ask_sdk_model.ui import Card + from ask_sdk_model.canfulfill import CanFulfillIntent PLAIN_TEXT_TYPE = "PlainText" @@ -47,7 +48,8 @@ def __init__(self): """ self.response = Response( output_speech=None, card=None, reprompt=None, - directives=None, should_end_session=None) + directives=None, should_end_session=None, + can_fulfill_intent=None) def speak(self, speech): # type: (str) -> 'ResponseFactory' @@ -136,6 +138,22 @@ def set_should_end_session(self, should_end_session): self.response.should_end_session = should_end_session return self + def set_can_fulfill_intent(self, can_fulfill_intent): + # type: (CanFulfillIntent) -> 'ResponseFactory' + """Sets CanFulfill intent to the response. + + For more information on CanFulfillIntent, check the name-free + interaction doc here: https://developer.amazon.com/docs/custom-skills/understand-name-free-interaction-for-custom-skills.html + + :param can_fulfill_intent: CanFulfill Intent sent back in response. + :type can_fulfill_intent: CanFulfillIntent + :return: response factory with partial response being built and + access from self.response. + :rtype: ResponseFactory + """ + self.response.can_fulfill_intent = can_fulfill_intent + return self + def __trim_outputspeech(self, speech_output=None): # type: (Union[str, None]) -> str """Trims the output speech if it already has the diff --git a/ask-sdk-core/tests/unit/test_response_helper.py b/ask-sdk-core/tests/unit/test_response_helper.py index 6e16869..7623c93 100644 --- a/ask-sdk-core/tests/unit/test_response_helper.py +++ b/ask-sdk-core/tests/unit/test_response_helper.py @@ -23,6 +23,9 @@ from ask_sdk_model.interfaces.display import TextContent from ask_sdk_model.interfaces.display import PlainText from ask_sdk_model.interfaces.display import RichText +from ask_sdk_model.canfulfill import ( + CanFulfillIntent, CanFulfillIntentValues, CanFulfillSlot, + CanFulfillSlotValues, CanUnderstandSlotValues) from ask_sdk_core.response_helper import ( ResponseFactory, get_text_content, get_plain_text_content, @@ -131,6 +134,23 @@ def test_trim_outputspeech(self): speech=speech_output4).response.output_speech.ssml == "Hello World", ( "The trim_outputspeech method fails to trim the outputspeech") + def test_set_can_fulfill_intent(self): + intent = CanFulfillIntent( + can_fulfill=CanFulfillIntentValues.MAYBE, + slots={ + "testSlot": CanFulfillSlot( + can_understand=CanUnderstandSlotValues.YES, + can_fulfill=CanFulfillSlotValues.YES + ) + } + ) + response_factory = self.response_factory.set_can_fulfill_intent( + can_fulfill_intent=intent) + + assert response_factory.response.can_fulfill_intent == intent, ( + "The set_can_fulfill_intent method of ResponseFactory fails to " + "set can_fulfill_intent value") + class TestTextHelper(unittest.TestCase): def test_build_primary_text_default(self): diff --git a/docs/en/SDK_SUPPORTED_ALEXA_CAPABILITIES.rst b/docs/en/SDK_SUPPORTED_ALEXA_CAPABILITIES.rst index 67e47d0..4352ff8 100644 --- a/docs/en/SDK_SUPPORTED_ALEXA_CAPABILITIES.rst +++ b/docs/en/SDK_SUPPORTED_ALEXA_CAPABILITIES.rst @@ -50,3 +50,5 @@ Preview * `Connections `__ * `Alexa Presentation Language `__ + +* `Name-free Interactions `_ diff --git a/docs/en/models/ask_sdk_model.canfulfill.rst b/docs/en/models/ask_sdk_model.canfulfill.rst new file mode 100644 index 0000000..77f7769 --- /dev/null +++ b/docs/en/models/ask_sdk_model.canfulfill.rst @@ -0,0 +1,57 @@ +ask_sdk_model.canfulfill package +================================ + +Submodules +---------- + +.. note:: + + Canonical imports have been added in the ``__init__.py`` of the package. + This helps in importing the class directly from the package, than + through the module. + + For eg: if ``package a`` has ``module b`` with + ``class C``, you can do ``from a import C`` instead of + ``from a.b import C``. + +ask\_sdk\_model.canfulfill.can\_fulfill\_intent module +------------------------------------------------------ + +.. automodule:: ask_sdk_model.canfulfill.can_fulfill_intent + :members: + :show-inheritance: + +ask\_sdk\_model.canfulfill.can\_fulfill\_intent\_request module +--------------------------------------------------------------- + +.. automodule:: ask_sdk_model.canfulfill.can_fulfill_intent_request + :members: + :show-inheritance: + +ask\_sdk\_model.canfulfill.can\_fulfill\_intent\_values module +-------------------------------------------------------------- + +.. automodule:: ask_sdk_model.canfulfill.can_fulfill_intent_values + :members: + :show-inheritance: + +ask\_sdk\_model.canfulfill.can\_fulfill\_slot module +---------------------------------------------------- + +.. automodule:: ask_sdk_model.canfulfill.can_fulfill_slot + :members: + :show-inheritance: + +ask\_sdk\_model.canfulfill.can\_fulfill\_slot\_values module +------------------------------------------------------------ + +.. automodule:: ask_sdk_model.canfulfill.can_fulfill_slot_values + :members: + :show-inheritance: + +ask\_sdk\_model.canfulfill.can\_understand\_slot\_values module +--------------------------------------------------------------- + +.. automodule:: ask_sdk_model.canfulfill.can_understand_slot_values + :members: + :show-inheritance: diff --git a/docs/en/models/ask_sdk_model.rst b/docs/en/models/ask_sdk_model.rst index 8383669..5e85398 100644 --- a/docs/en/models/ask_sdk_model.rst +++ b/docs/en/models/ask_sdk_model.rst @@ -13,6 +13,7 @@ Subpackages .. toctree:: :maxdepth: 1 + ask_sdk_model.canfulfill ask_sdk_model.dialog ask_sdk_model.events ask_sdk_model.interfaces