Scripting Advanced Logic in A2J Author
This exercise will teach you how to script five conditions or advanced logic statements in an A2J Guided Interview. This exercise does not contain an A2J Template or HotDocs Template component. It is meant to focus on the interview only.
The five conditions that we will be scripting will be contained in a simple A2J Guided Interview. The conditions are:
-
Testing a user’s date of birth to see if they are over 18 years old.
-
Creating multiple conditions in 1 question to set values to variables and branch the end user to different subsequent questions based on their answer to an income question
-
Branching an end user to a specific question if they only have 1 person in their household.
-
Testing the variable User Gender to determine if a question about pregnancy should be asked.
-
Setting a value to a variable based on whether the user has 1 or multiple children.
The final A2J Guided Interview will look like this:
This Sample Exercise should be used by authors who have completed a basic A2J Author training. Training videos can be found on our A2J Author YouTube Channel (www.youtube.com/a2jauthor)
-
Log into your www.a2jauthor.org account. If you aren’t sure how to create an account, check out this resource.
-
Once logged in, go to the “Author” tab and click it.
-
Then click “Run A2J Author”.
-
A2J Author will open on the “Interviews” Tab. Under “Create a new interview” double click on “Blank Interview”. This will open up a blank A2J Guided Interview.
-
Go to the “About” Tab and rename the title of the interview to Sample Exercise: Scripting Advanced Logic
-
You will need to create several variables to be used in the A2J Guided Interview. Go to the Variables Tab and create the following variables. The variable type will be next to the variable name in parenthesis.
-
Child or children TE (text)
-
Client birthdate DA (date)
-
Client legal issue TE (text)
-
Income NU (number)
-
Income too high TF (true/false)
-
Number child NU (number)
-
People in household NU (number)
-
Pregnant TF (true/false)
-
-
Go to the “Steps” tab. By default a blank A2J Guided Interview comes with 4 steps. Rename them as follows:
-
Step 0: Welcome
-
Step 1: Your Information
-
Step 2: Do You Qualify
-
Step 3: Exit
-
-
Now let’s start creating the questions we’ll build our interview out of. Go to the “Pages” Tab. By default, an A2J Guided Interview comes pre-populated with 4 questions - 3 in Step 0 and 1 in Step 1. Also, Steps only appear on the Pages Tab when they have questions inside them. So when you first go to the Pages Tab, all you’ll see is Step 0 and Step 1. As we add questions to the other Step, it’ll appear. We will need a total of 9 questions for this Sample Exercise.
-
Create 5 new questions by clicking the “New Page” icon 5 times. All the new questions should appear in Step 0.
-
-
Double click on 1-Introduction. Change the page name to 1-Welcome. Create a 4th field. There should already be three fields to collect the user’s first, middle, and last names.
-
The 4th field should be Gender. The label should be Gender: and the Variable should be User Gender.
-
-
Double click on 3-Gender. Change the Step to Step 1. Change the page name to 2-DOB (Condition AFTER). In the notes field, type in “AGE function converts date of birth to age in years. This condition says if the user is less than 18 years old, then exit them.”
-
Question text: What is your date of birth?
-
Scroll down to the fields section. Create one field.
-
Type: Date MM/DD/YYYY
-
Label: Birthdate
-
Variable: Client DOB DA
-
Make sure the box next to “Required” is checked (because we wouldn’t want a user to skip a qualifying question).
-
-
-
Before we can script the logic that branches an end user who is younger than 18 years out of the interview, we need to create the question the disqualified user will land on which explains what is happening to them. Double click on one of the newly created questions.
-
Move it to Step 3.
-
Rename it O-Do Not Qualify and Exit
-
Question text: Sorry, but you do not qualify to use this program. Please hit the “Exit” button to close this program.
-
Scroll down to the Buttons section. Rename the button label to Exit. Set the Destination to [Exit - User does not qualify]. This will trigger a new field where you can set a redirect URL for the end user. Enter www.a2jauthor.org or whatever website you’d like. If you didn’t include a URL, a message would appear when the user clicked the “Exit” button telling them to close their browser.
-
-
Go back to 2-DOB (Condition AFTER) and double click to reopen it. Scroll down to the Advanced Logic section. In the AFTER logic box, type:
IF AGE([Client DOB DA])<18
GOTO “O-Do Not Qualify and Exit”
END IF
-
Double click on 1-Question 1. Move it to Step 2. Rename it 1-Income (Multiple Conditions)
-
Notes: #1 sets [Income too high TF] variable for later use and determines if income is too high, then exits user. # 2 Determines if income is in a middle, gray area, then directs the user to an extra question to find out how many people are in their household.
-
Question text: %%[Client first name TE]%%, what was your household income for the last tax year?
-
(The %%[Client first name TE]%% part is called a variable macro. It calls out the value of the variable inside the double percent signs. In this case, it will display the client’s first name as they have entered it when asking this question).
-
-
Learn more prompt (the thought the end user avatar has): What counts as household income?
-
Help: You should include any money earned or benefits received by any person living in your house.
-
Create 1 field. Type: Number Dollar; no label (A2J Author will automatically insert a $ symbol); Variable: Income NU; check the “Required” box and check the “Show Calculator” box.
-
-
Before we can create the logic for 1-Income, we need to create the question that the end user will be branched to if their income is too high to automatically qualify for our assistance, but not too high to automatically exclude them. In our scenario, users who make over $35,000 a year are over our income threshold. Users who make between $34,999 and $25,001 are asked a follow up question. Anyone making under $25,000 automatically qualifies for our assistance.
-
Double click on one of the new questions. Move it to Step 2. Rename it 1b-Income.
-
Now close that question and reopen 1-Income (Multiple Conditions).
-
Scroll down to the Advanced Logic section and type the following into the AFTER box:
-
IF [Income NU] >35000
SET [Income too high TF] TO TRUE
GOTO “0-Do Not Qualify and Exit”
ELSE
SET [Income too high TF] TO FALSE
END IF
IF [Income NU] <35000 and [Income NU] >25000
GOTO “1b-Income”
END IF
-
Reopen “1b-Income”.
-
Notes: Question only appears in the user’s branch if their income is in the middle gray area between $34,999 and $25,001. If in this gray area and the user has more than one person in their household, they will be allowed to continue as they fit our income requirements. If they are a single person household in that income range, they will be moved out of the interview for not qualifying.
-
Question text: How many people live in your household?
-
Create 1 field. Type: Number (Pick from list); no label; Variable: People in household NU; check the “Required” box; Min value: 1; Max value: 10 (We are limiting the number of possible people in a household to 10 here arbitrarily. This would normally be set by the organization’s internal requirements.)
-
Advanced Logic: (This will test how many people are in the end user’s household and if only 1, send them to the Do Not Qualify question.). Type exactly as follows:
-
IF [People in household NU] = 1
GOTO “0-Do Not Qualify and Exit”
END IF
-
Double click on another new page. Move it to Step 2. Rename it 2-Pregnant (Condition BEFORE). We’ll come back to this one soon.
-
Double click on another new page. Move it to Step 2. Rename it 3-Children (Set Variable). We’ll come back to this one soon.
-
Go back to 2-Pregnant (Condition BEFORE) and reopen it.
-
Notes: Question is only asked if the user is female.
-
Question text: Are you currently pregnant?
-
No fields.
-
Create 2 buttons.
-
Button 1: Label: Yes; Variable Name: Pregnant TF; Default value: True
-
Button 2: Label: No; Variable Name: Pregnant TF; Default value: False
-
-
BEFORE logic:
-
IF [User Gender] = “Male”
GOTO “3-Children (Set Variable)”
END IF
-
Open 3-Children (Set Variable).
-
Question text (for purposes of this Sample Exercise, we’re assuming the user has children. In a real interview, you should have a question before that asks IF the user has children and only displaying this question if they answer yes.): How many children do you have?
-
Create 1 field. Type: Number (Pick from list); no label; Variable: Number child NU; check “Required” box; Min value: 1; Max value: 10
-
Scroll down to the AFTER Logic section. This is where we will create a condition to set a new variable [Child or children TE] to the correct word based on how many children the user says they have. You can then use [Child or children TE] later in the interview in a macro to call out the correct word.
-
IF [Number child NY] >1
SET [Child or children TE] TO “children”
ELSE
SET [Child or children TE] TO “child”
END IF
-
Double click on the final new page. Move it to Step 3. Rename it 1-Success.
-
Question text: Congratulations you’ve finished your Sample Exercise on Scripting Logic Statements!
-
-
To complete this Sample A2J Guided Interview, we need to connect all the questions now. To connect questions, you set the Destination on each question to the next one in the line. Double click on each question in the following list and make sure it’s connected to the next question listed as follows:
-
1-Welcome to 1-Name
-
1-Name to 2-DOB (Condition AFTER)
-
2-DOB (Condition AFTER) to 1-Income (Multiple Conditions)
-
1-Income (Multiple Conditions) to 2-Pregnant (Condition BEFORE)
-
2-Pregnant (Condition BEFORE) to 3-Children (Set Variable)
-
3-Children (Set Variable) to 1-Success
-
-
Now it’s time to test your interview to ensure it flows as it is supposed to. Either click the Preview Tab or open 1-Welcome and then click the Preview button within that question. It’s best to preview your interview with the Variables/Script window open. To open it, when in Preview mode, click the “Variables/Script” button in the bottom left hand corner of the interview. This will open a panel where you can see the values that are being assigned to different variables, the path the interview is following, and the logic statements being evaluated real time. You can re-enter editing mode by clicking “Edit this” to edit the question you are currently viewing or “Resume Edit” to edit the question you entered Preview mode from.
Congratulations on successfully completing this Sample Exercise. If you have any questions or comments, feel free to reach out to our A2J Author Project Manager Jessica Frank at Jessica@cali.org.