Chatbot Interaction with Forms & Sub-Forms

Forms can be added to other forms, create a tree with any level of depth… much like a DMV IVR. In this blog we go through the details of how to use Persona Sub-Forms in The Sedro Project.

Sub forms can be added in any other form, they simply run inline when the form gets to the sub-form input. This allows forms to be created for specific inputs and allow reuse.

Sub-Forms

The simplest is a form called in the processing flow of another form. In this case a Form to get the callers phone number is added to the persona

 <form name='_getphonenumber_' data-type='form'>
 <input name="phone number" data-type="input" data-seq="X:%any%:(lx_phone number):sz[large]"/>
 <label for="phone number" state='wake'>What is your phone number?</label> 
 <label for="phone number" state='incomplete'>Full phone number please, including area code</label>
 <label for="phone number" state='verify'>Is %phone number% correct?</label>
 <label for="phone number" state='complete'>got %phone number%</label>
 </form> 

Another Form is added to the Persona and set as Main Form, that includes an input of type ‘form’ that links to Sub-Form _getphonenumber_

 <form name='_getinfo_' data-type='form'>
       <input name="intro" data-type="content" />
       <label for="intro" state='wake'>We need a bit of information from you</label>
  
       <input name="home phone" data-type="form" data-formname="_getphonenumber_"/>           
       
       <input name="exit" data-type="content" />
       <label for="exit" state='wake'>Thank you for your information.</label>              
       <input name="bye" data-type="event" data-event='bye' />
 </form> 

Inline inclusion of a remote form works exactly the same but starts with a URL.

 <input name="test_form" data-type="form" data-formname='http://api.sedro.xyz/w/00_DEV_00/forms/testform.xml'/> 

Menu Sub-Forms

Menu’s with multiple option can also link to local or remote forms on the selection of an option. This allows your service to nest menu’s as is common in an IVR or ordering system. In this example we have 3 options, get phone number with the previous form, get the test form from remote (allowing personalization) or go back to the last form.

 <form name='_submenu_' data-type='menu'>
 <input name="intro" data-type="content"/>
 <label for="intro" state='wake'>Select an option from this list</label>
 
 <input name="select" data-type="menu"/>
 <label for="select" state='option' value='1' data-formname='_getphonenumber_'>1, Get Phone Number</label>
 <label for="select" state='option' value='2' data-formname='http://api.sedro.xyz/w/00_DEV_00/forms/testform.xml'>2, Test Form</label>
 <label for="select" state='option' value='3' data-formname='cancel'>Go back</label>
 <label for="select" state='incomplete'>Please select an option for the list</label>
 <label for="select" state='done'>You selected option %select% %select_txt%</label>
 </form> 

Accessing Form input values

Accessing values from the form can be done via input name of the form from the caller

 <label for="exit" state='wake'>Your Home Phone Number: %home phone%</label> 

Or before the form is reset you can access the value

 <label for="exit" state='wake'>Your Phone number: %current:_getphonenumber_/phone number%</label> 

If the form is reset you can access any of the inputs using the ‘current’ for the name of the instance, this will also work if only one has been saved, or will get the last one saved.

 <label for="exit" state='wake'>Your Phone number: %current:_getphonenumber_/phone number%</label> 

Accessing saved forms can be done using the form ID

 <label for="exit" state='wake'>Your Phone number: %9393:_getphonenumber_/phone number%</label> 

Accessing Database Values

Saving forms to the Data Base allows you to access the information during the session or beyond if you retain the information across chat sessions. This also allows for multiple copies of the same time of information, but each will need a distinct name.

 <label for="exit" state='wake'>Your Phone number: %db:my_number:phone number/phone number%</label> 

Complex User Interfaces

Sub-Forms can be used to develop complex and dynamic user interfaces for chat or voice allowing any level of control desired. Mixed with the ability of Sedro to answer questions on its own, you can quickly develop a functional and human like interface.

To Be Continued…

In the next blog on Forms we will focus on more complex events http://blog.sedro.xyz/2020/01/27/persona-form-events/

One Reply to “Chatbot Interaction with Forms & Sub-Forms”

Comments are closed.