Comments (9)
Thanks for the update @abdiels . I will be closing this issue.
Just to answer your question on switching intents, so, as part of the v2 SDK design, a request handler can process more than one intent or in fact any condition that is checked under it's can_handle
function. So, rather than calling another handler's handle function, it is better (easier code structure) to create handlers that can handle all the cases. But, the as @timothyaaron mentioned, you can always call any other handler's handle
method, as a normal function call in your handle
method. All the SDK needs is to send a valid Response
back to the user. Hope this helps.
If you are having any other questions, please either reopen this issue or raise another one!!
from alexa-skills-kit-sdk-for-python.
The recommended way breaks dialog flow. You cannot pass the intentHandler to a "handle" function and then in that other intent have it delegate because the request & slots are of the wrong intent
from alexa-skills-kit-sdk-for-python.
I've seen this done (I'm thinking it was in one of the demo files) by just returning the handle
of the Handler you want to redirect to. See the last line of this exampleโฆ
class LaunchHandler(AbstractRequestHandler):
def can_handle(self, handler_input):
return is_request_type("LaunchRequest")(handler_input)
def handle(self, handler_input):
# wrote some launch code here
return handler_input.response_builder.response
class ResetHandler(AbstractRequestHandler):
def can_handle(self, handler_input):
return is_intent_name("ResetIntent")(handler_input)
def handle(self, handler_input):
handler_input.attributes_manager.session_attributes = {}
return LaunchHandler().handle(handler_input)
from alexa-skills-kit-sdk-for-python.
Of course, in this overly simplified example you could also just add or is_intent_name("ResetIntent")(handler_input)
to your LaunchHandler.can_handle
and handle the one-off inside your LaunchHandler.handle
code...
class LaunchHandler(AbstractRequestHandler):
def can_handle(self, handler_input):
return (
is_request_type("LaunchRequest")(handler_input) or
is_intent_name("ResetIntent")(handler_input)
)
def handle(self, handler_input):
if is_intent_name("ResetIntent")(handler_input):
handler_input.attributes_manager.session_attributes = {}
# wrote some launch code here
return handler_input.response_builder.response
from alexa-skills-kit-sdk-for-python.
Hey @abdiels , thanks for the link to the issue. As you can see, that feature was available in the v1
version of the SDK. However, in the v2
version of the Node SDK, this feature has not been added. Instead, you can call any handler's handle()
code directly as mentioned by @timothyaaron (Thanks for mentioning both approaches ๐ ) in his first comment.
Instead if you want multiple events to be handled by a single handler, you can use the can_handle
function to do all your validation as mentioned by @timothyaaron in his second comment.
Does that suffice your needs? Or you were looking for something else?
from alexa-skills-kit-sdk-for-python.
First, thank you all for replying. I have to try it out. I will tonight. I wonder what this does to the dialog status and things of that nature. If the dialog is IN_PROGRESS in one intent, I was not sure you can change to another,, but when it is COMPLETE, right now (without trying to change manually), my app seems to end regardless if the user says an utterance that should direct them to a different intent.
My use case is basically like this...on launch I do an API lookup and give the user options with numbers and I have an intent with 2 slots (In my mind they could be separate intents, but I have it as one now as I have had this kind of issue). Once those slots are filled (I asked for the other in the intent handler), I want to give the user a choice say you can "study" or you can be "quizzed". To me those should be two separate intents, but once I fill out both slots it did not switch to either or them regardless of what the user say. I could be going about this the wrong way, but I thought that instead of allowing the dialog to be completed, I could direct the user to either of those intents. I hope this makes sense. Any advice would be appreciated and I will try the approach suggested by @timothyaaron
from alexa-skills-kit-sdk-for-python.
Hey @abdiels , any update? Did you get around the problem?
from alexa-skills-kit-sdk-for-python.
Thank you for following up. I have been meaning to reply, but I had not since I did not really get it to work the way suggested; however, I have learned that the approach I was using was not correct. So I believe this can be closed.
Just to try an understand further the suggesting is to call the method than handles the particular intent we want to switch to...I thought that was not allowed since the intent passed into the input handler is already address to the intent where I am sitting on.
Again, that is more of a curiosity satisfaction questions as my original issue was basically lack of knowledge more than really needed the requested feature.
from alexa-skills-kit-sdk-for-python.
Hey @westlakem , as mentioned by @tianrenz on the issue you created on NodeJS SDK, the emitWithState
feature in the V1 NodeJS SDK world forwarded the same request to a different function, and will not change the intent/slot information in the request. That is similar to the approach mentioned above, on how to get that working in the current SDK design.
Let's move this discussion to the issue logged on the NodeJS SDK, since all the SDK's follow the same design approach and in case there is a feature request agnostic to the language, we can work on it through the details provided there. In case you have any other questions, please log a new issue so that we can track it in an efficient manner. Thanks.
from alexa-skills-kit-sdk-for-python.
Related Issues (20)
- ask_sdk_model.services.service_exception.ServiceException: The authentication token is invalid or doesn't have access to make this HOT 11
- Sb Conflicting each other HOT 5
- `ModuleNotFoundError:` No module named 'asn1crypto'`` when importing skill adapter from flask HOT 3
- 'NoneType' object has no attribute 'system' HOT 2
- Link how to create a new security profile should be updated HOT 1
- Golang SDK - Alexa Skills kit HOT 2
- User with almost all scopes types receives unauthorized_client error HOT 2
- UserAgentManager missing from 1.15 PyPI distro HOT 3
- Alexa HOT 1
- Fail to import local modules HOT 6
- I have a intent for the alexa skill which has two slots, one of them is fulfilled while invoking the skill. I want the second slot to store the value uttered by the user at a later point of time. Is there a way to do so using python HOT 1
- Cannot import the SpokenInfo class (ask_sdk_model.services.reminder_management) HOT 2
- Receiving unauthorized_client error trying to list all skills HOT 3
- SpeakDirective doesn't create correct audio src directive HOT 1
- Outdated version of cryptography? HOT 5
- Invalid signatures with django-ask-sdk since ask-sdk-webservice-support v1.3.3 HOT 4
- ENDPOINT_TIMEOUT is not handled properly in Incorrect handling of SessionEndedRequest.
- AskForPermissionsConsentCard not showing the option to activate requested permission HOT 2
- documentation error - local_debug.py
- Bug report : Sending a voice forward consent start connection directive returns error "ask_sdk_core/response_helper.py directive.object_type has no attribute 'object_type'"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alexa-skills-kit-sdk-for-python.