Skip to main content
A rater’s inputs are facts that a person answers. The application that collects the answers is the host: a form, a conversation or an agent. The host reads the rater’s input contract to learn what to ask, and when. In this tutorial you take a renters rater with bare inputs and state its questions. Finish Write your first rater first.

What you build

You make five changes to the inputs of one rater:
  1. Give two inputs a question, help text and a section.
  2. Add two follow-up inputs that a host asks only after a true answer.
  3. Name the items of a list.
  4. Mark the coverage limit as a choice with a default.
  5. Mark an input that the host fills, and suggest an answer from it.
Then you export the rater, read each change in its input contract, and rate a request that leaves the follow-ups out. The rates, rules and source citations are synthetic.

Start from a plain rater

Create a folder for the starting rater:
Save this rater as plain/rater.rsl.
plain/rater.rsl
The rater prices a renters policy from five inputs: the county, the year of construction, a home business, the contents limit and a list of scheduled valuables.
The input contract of this rater states the type of each input:
A host that reads this field knows its type and lacks the words to ask for it. Copy the rater to a second folder. Edit the copy in the steps that follow:

Give an input its question

In questions/rater.rsl, replace the year_built and home_business inputs with these lines:
  • ask is the question a person reads.
  • help is a longer text that the host shows with the question.
  • group names the section of the questionnaire.
  • format tells the host how to take the answer. Answer formats lists the names.
The annotations change what a host asks. The premium stays the same. Check the rater now, and again after each later step:

Add follow-up inputs

Some questions apply only after an earlier answer. A follow-up input states its condition after its type:
Add two follow-up inputs after home_business:
A host asks both questions after a true answer to home_business. unit names the unit of the amount. Each follow-up changes the premium. Add two constants to Constants:
Add two calculations to the premium step:
Then add both to the total:
A follow-up is absent where its condition is false. The two calculations show the two ways to read one:
  • equipment_premium reads the amount inside if self.home_business then …, where the amount is present.
  • visitor_premium reads the answer after self.home_business and, so an unasked question adds the same $0 as an answer of false.
An unasked question stays distinct from an answer of false: the rater states which one it counts as. not self.home_business or self.customers_visit counts an unasked question as true. A read of either follow-up outside its condition gets the check message E-FOLLOW-UP-READ.

Name the items of a list

A person adds valuables one at a time, and each later question names the item it is about. Replace the items input:
  • keyed by item_id makes item_id the key of each item.
  • called names an item in a question. {kind} is the item’s kind answer, and {#} is its place in the list.
  • The | separates alternatives, and a host takes the first one that it has every answer for.
  • complete is the question a host asks before it closes the list.
Replace the inputs of Item:
In a question, {this} stands for the name that called gives the item. A label on an enum member gives the words a person reads for that value. In Types, add one to instrument:
A host now asks “What kind of item is item 1?”, then “What is the musical instrument worth?”.

Mark what the person buys

The contents limit is something the person buys. The other inputs are facts about the home. Replace the contents_limit input:
  • choice marks the input as a choice. A host offers it as a coverage option and keeps it out of the questions.
  • ask is the text a host shows beside the option.
  • shape names the kind of choice. Choice shapes lists the names.
  • api_default is the value the rater uses when a request leaves the input out. Write it as a JSON literal in quotes.
A choice requires an api_default, so a request always has a value for it.

Let the host fill an answer

A host often has a source for an answer, such as a table of ZIP codes and counties. The rater names the source, and each host supplies a function of that name. Add a type for the ZIP code to Types:
Then replace the county input with these three inputs:
  • filled_by has the form source(input).field. The host gives the postal_code answer to its source zip_lookup and stores the county field of the result.
  • Leave ask off an input with filled_by. The host fills it and skips the question.
  • from self.zip_county suggests an answer for county. The person accepts the suggestion or picks another county.
The premium reads county alone, so the price rests on an answer the person gave or accepted.

Check and export the rater

Your file now matches the finished rater.
questions/rater.rsl
Check it, then package it into a bundle:
The bundle holds the input contract as program/input-schema.json.

Read the input contract

Rater.input_schema returns the same contract as a dictionary. It is the JSON Schema of one request, and each annotation is a key that starts with x-:
The follow-up carries its condition, and its type admits null:
The contract requires three answers. The follow-ups, the choice, the list and the inputs that only feed a suggestion are optional:
The choice carries its default and its shape:
x-round comes from the shape. For a limit that the rater leaves unsold, a host prices the next limit up. x-group comes from the shape as well: a limit sits in the liability part of a coverage screen. The list carries its key, its item name and its closing question:
The filled input names its source, and the suggested input names what the suggestion reads:
Input contract describes every key.

Rate with the follow-ups left out

This request answers the three required questions and leaves out everything else:
The rater reads both follow-ups as absent, and each calculation takes its else value of 0. It takes the default contents limit of $30,000 and rates an empty list. The premium is $275: the $120 base premium plus 30 × 4.50 × 1.15, rounded to whole dollars. Where the condition is false, the rater ignores a follow-up that the request gives:
Where the condition is true, the rater requires the follow-ups:
The refusal lists each follow-up that the request owes:
With both answers, the rater adds the business premiums:
Refusals describes the refusal that a rater returns.

Next steps

rslc examples get questions saves the finished rater of this tutorial to a folder.