|
  
Building a Rule-Based Script
Open DecisionScript to the default screen. In the Tree Window,
highlight the Root node and type the following formula in
the Definition Window:
Root:={
Welcome;
Best Plan;
if(askyesno)
Order;
else
Thank You;
}
Type the following text in the Form Window:
Jupiter Cellular's <%Best
Plan%> is just right for you.
Would you like to sign up now?
Highlight the Welcome node in the Tree window and type Welcome:=say in the Definition Window.
Then type the following text in the Form Window:
Welcome to Jupiter Cellular.
By answering the following questions, we can determine which of
our
wireless service plans best meets your cellular phone needs.
Highlight the Best Plan node in the Tree Window and
type the following formula in the Definition Window:
Best Plan:=firsttrue(
Security Plan,
Everyday Plan,
Deluxe Plan,
Office Mate Plan,
Office Deluxe Plan
)
In the Tree Window, each plan is displayed as a child of Best
Plan.
To define each of the plans, select the corresponding node in
the Tree Window and type the attributes, or rules, in the
Definition Window. For the Security Plan, the rules can be
defined as follows:
Security
Plan:=!Business&&Minutes<30&&!Deluxe Features
Literally, this means that the Security Plan is for people who
do not want to use the service for business (!Business), and plan to use their
cellular phones for less than 30 minutes each month (Minutes<30), and do not need the
deluxe features (!Deluxe Features).
The Not operator (!) is used to negate an expression, while
the And operator (&&) is used to join rules. Other
operators you can use include the Or operator (||) and comparison
operators (<, <=, >, >=, !=).
Each rule that is used to define the Security Plan
becomes a branch of the Security Plan node.
For the script to work, each rule must be defined to ask the
Web site visitor a question or to combine other rules that ask
questions. To ask yes or no questions, the function askyesno is used.
To define the Business node, highlight the node in the
Tree Window and type the following formula in the Definition
Window:
Business:=askyesno
Now, type the following text into the Form Window.
Do you plan to use your cellular
phone for business calls?
To ask for a number, the function asknumber
is used.
To define the Minutes node, highlight the node in the
Tree Window and type the following formula in the Definition
Window:
Minutes:=asknumber
Now, type the following text in the Form Window.
Approximately how many minutes of
calls do you expect to make each month?
To define the last rule, highlight the Deluxe Features
node in the Tree Window and type the following formula in the
Definition Window:
Deluxe Features:=Call
Forwarding||Call Waiting
Call Forwarding and Call Waiting now become
branches of Deluxe Features that must be defined. To
define them, highlight each node in the Tree Window, type the askyesno formula in the Definition
Window, and ask if the service is needed by typing a question in
the Form Window.
The complete script displayed in horizontal tree format looks
like this:
As in the Decision Tree script, a customer who wants to
sign-up for a service plan right away is directed to another page
in your Web site via a redirect. Customers who do not want to
sign-up are directed to the Thank You screen. The
definition for Thank You is a little more complex than a
regular say function because
there is no need for a Next button on the last screen.
Instead, you display Back and Done buttons.
To include the Back and Done buttons in your
script, highlight the Thank You node and type the
following in the Definition window:
Thank You:=say(
dialogtemplate,
null,
BTN_BACK+BTN_DONE
)
The codes BTN_BACK and BTN_DONE designate the Back and Done
buttons, respectively. This definition will make more sense if
you look at the online help listing for say
and dialog.
As you can see, using rule-based scripts has a distinct
advantage over decision trees in that they allow you to remove
services as they become obsolete, or easily modify them as their
features change. To make these changes, you don't need to
consider exactly where in the sequence of existing questions you
must insert new questions. In fact, you never explicitly define
the order in which any questions are asked. DecisionScript does
this for you. In addition, if you want to add a service that can
be defined in terms of questions that are already defined in your
script, adding the new service requires only one additional node
definition.
|