Parsers may not be able to complete a command from a single message. When that happens, they need to store a fragment and prompt for completion.
Prompts happen one field at a time, without any knowledge of other fields that may yet need to be filled (knowing would be impossible, since the required fields may depend on defined ones).
The completion model is based on the programming model of the AWS Lex service, which uses a slotToElicit
parameter
to indicate that a slot (field) still needs to be filled.
- User pings
Bot
Listener
sendsMessage
- Lex
Parser
handlesMessage
Parser
sends message to Lex runtime- Response has
slotToElicit
set
- Response has
Parser
creates a completionCommand
(completion:create
)
- Completion
Controller
handlesCommand
Controller
creates and savesFragment
Controller
sends aMessage
prompting user for the next field
Listener
responds to user with completion code- User responds with value
Listener
sendsMessage
- Completion
Parser
handlesMessage
Parser
extracts nextvalue
Parser
loadsFragment
Parser
forwards(Fragment, value)
to originalParser
- Lex Parser completes
Fragment
Parser
sends nextvalue
to Lex runtimeParser
merges (next) response slots with (prev) fragment dataParser
executes completeCommand