简体   繁体   中英

Can I use an Alexa skill as a condition to exit a while loop?

I am trying to build a device that keeps multiple motors running in default mode unless a user instructs Alexa to make them move otherwise. The pseudocode looks something like this:

intentInvoked = checkIfIntentInvoked()
while intentInvoked not True:
     intentInvoked = checkIfIntentInvoked()    
     #motors run in default mode

I want to know if there's a way to implement the checkIfIntentInvoked() function. I have read the documentation and it pretty much says that as long as the user triggers the intent invocation, it automatically maps to the intent programmed in Python (I am using flask-ask).

You can store the state of your application in some storage with web access (via api for example).

Then when you invoke your intent, just write the code that changes the application state.

In your application responsible for motor rotation, instead of checking if the intent has been invoked, just read the application state.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM