Digital Assistants via Background Forms
Forms may also work in the background providing an invocation from the foreground (like Apple’s Siri or Amazon’s Alexa) . Or they may stay in the background, recording/retrieving information or performing actions based on the conversation content.
Background forms can be used to add simple note takers, personal assistance, inline censor/editor or for more complex tasks that leverage integration with your external servers.
Adding a Background Form
Background Rorms are added like the others but with type set to background. Try this example to see a Background Form with an invokation.
<form name='_invoke_' data-type='form' > <input name="listen" data-type="invoke" data-opt='wait' data-seq="X:woolley:%"/> <input name="intro" data-type="content" /> <label for="intro" state='wake'>This is Woolley!</label> <input name="background" data-type="event" data-event='background_reset' /> </form>
This form will listen in conversation and when the caller says ‘woolley’ will be invoked. It simply prints a message and completes by returning to the background. This method allows for background monitoring with actions on command as needed for a personal or task assistant.
Invoking a background form makes it active and starts it’s processing, this could take over the conversation from any existing form or do so when no forms are running. The invocation is done with an invoke input
<input name="listen" data-type="invoke" data-opt='wait' data-seq="X:woolley:%"/>
The data-seq= is used to specify the rule that must match for to invoke the form and is in the SEQ (Semantic Sequence) Language. In this example it matches current token case independent to the string “woolley”.
data-opt=’wait‘ is set to tell the system not to auto-run the invoke, it must first wait for data.
Returning to the background
Events are used to return to the background or background_reset depending if you want this form to be reset to initial state or not.
<input name="background" data-type="event" data-event='background_reset' />
Background and foreground forms may run together in the same Persona. This allows from more many different possibly unrelated tasks to take place in a conversation and allows for UX to be very complex.
Some SEQ examples
Not to go into the syntax here in any detail a few more examples are added so you can modify the invocation
hey:% X:woolley:% - "hey Wolley"
invoke:% X:woolley:% now:% - "invoke wolley now"
%any%:%action% X:woolley:% - "run wolley!" OR "I hate WOLLEY!"
These are simple, but should get you started matching content… full documentation is forthcoming
To Be Continued…
In the next blog on Forms we will focus on Rest API integration via Forms http://blog.sedro.xyz/2020/01/29/persona-forms-restapi-integration/