How allenai/alexafsm works
alexafsm is a Python library for modeling Alexa conversations as finite-state machines. The main turn flow accepts an Alexa request in Policy, builds or updates session attributes, triggers a state transition, and produces an Alexa-formatted Response. States define the conversation states and transition declarations; Policy assembles and executes the machine. The library also provides validation, graph/printing and recorded-dialog analysis tools, plus optional VoiceLabs tracking. The example skill and server are excluded because they live under tests. Edges reflect README statements or shown source; unsampled implementations and unshown transition dispatch details are not inferred.
Main entry points: policy.py Policy handler · response.py Alexa response · states.py State definitions · session_attributes.py Session attributes
Components 10
Conversation runtime
- Policy handler
alexafsm/policy.py - State definitions
alexafsm/states.py - Session attributes
alexafsm/session_attributes.py - Alexa response
alexafsm/response.py - Alexa intent names
alexafsm/amazon_intent.py
Inspection tools
- FSM tools
alexafsm/utils.py - JSON conversion
alexafsm/make_json_serializable.py
External services
- FSM engine
- VoiceLabs
Other components
- Alexa request
Connections 10
- Alexa request → Policy handler: sends request
README.md - Policy handler → State definitions: builds from
alexafsm/policy.py - State definitions → Session attributes: creates from request
alexafsm/states.py - Policy handler → FSM engine: configures transitions
alexafsm/policy.py - Policy handler → Alexa response: generates response
alexafsm/policy.py - Alexa response → Session attributes: serializes session
alexafsm/response.py - Policy handler → Alexa request: returns response
README.md - Policy handler → VoiceLabs: tracks intents
alexafsm/policy.py - FSM tools → Policy handler: validates and visualizes
alexafsm/utils.py - JSON conversion → Alexa response: encodes objects