alexa-games / litexa

Language and toolchain for writing Alexa skills.
https://litexa.com
Apache License 2.0
37 stars 7 forks source link

Documentation Feature: How are One shots handled #160

Open cheruvian opened 4 years ago

cheruvian commented 4 years ago

Feature Request

Document how litexa chooses which state to enter for one shot intents ie "Alexa tell SKILL_NAME to SOME_INTENT"

Given a litexa file something like

state1
  when SOME_INTENT
    say "state 1"

state 2
  when SOME_INTENT
    say "state 2"

Is this deterministic? How is this chosen? Do I get the opportunity to intercept and run something before it hits that state?

ayrc commented 4 years ago

One shot intents are equivalent to launching a skill (new skill session ID) with an intent. So, the one shot intent will enter your launch state. If you have intent handlers in your launch state, it will trigger those. If you do not and do not have an otherwise handler, then Litexa will report this as an unhandled intent error. In other words, treat the launch state behavior the same as any other state, and know that one shot intents get routed to the launch state.

cheruvian commented 4 years ago

Interesting this somewhat precludes having a welcome message, are there solutions here besides doing some custom variable tracking or duplication of all logic?

e.g.:

launch
  say "welcome message"
  -> waitForCommand

waitForCommand
  when "some intent"
    -> doSomeIntent
  when HelpIntent
    say "try saying some intent"
    -> waitForCommand

"Regular" Open Skill Name

user: open skill name
alexa: waitForCommand, "welcome message"

One Shot:

user: ask skill name to some intent 
alexa: "" (unhandled intent error results in no message)

It almost seems like Litexa should recognize non-when terminated launch states and flow through to the first state that ends with a when.

ayrc commented 4 years ago

This would require special treatment of the launch state that changes the expectations of state behavior. Each state defines its handlers; one-shot intents are simply intents received in the launch state (unless resetOnLaunch was false).