Reputation: 51
I am looking for some example code like it exists for nodejs described in this article:
i tried to call the other intent without success
def handle(self, handler_input):
#some code
return handler_input.response_builder.add_directive(DelegateDirective(updated_intent= {"name":"OrderIntent", "confirmationStatus": "None", "slots" : {}}))
Upvotes: 4
Views: 993
Reputation: 513
I know this question was asked quite awhile ago. I figured posting an answer may be helpful to others looking for python based Alexa questions.
After a lot of testing, going through the api docs, and trying to figure this problem out myself, I have figured out the following to get this to work. My personal problem was that I found a solution here that allowed for the current function to call the handle function of another intent; however, this would not spawn the required mandatory slot dialog that I needed.
My solution is the following:
from ask_sdk_model.dialog import delegate_directive
from ask_sdk_model.intent import Intent
def handle(self, handler_input):
speak_output = "We're going to another intent"
return handler_input.response_builder.speak(speak_output).add_directive(delegate_directive.DelegateDirective(updated_intent=Intent(name="<insert_intent_name>"))).response
Simply change the <insert_intent_name>
in the above snippet to whatever intent you're trying to call. When calling it like this, it will make sure to also keep all portions of intent model in tact. I.E. if you have required slots, they'll be treated just like they were initially when the original intent first fired.
Note: During testing I kept running into an error stating:
[ERROR] AttributeError: 'ResponseFactory' object has no attribute deserialized_types'
. I found this was because I didn't add .response
to the end of the return statement.
It should allow for YesIntent and NoIntent transitions based on set attributes in the originating intent.
Upvotes: 3