Stateless Rating: How-To Guide
There are many situations in which you’ll want to provide prospective customers with quick pricing estimates on some potential new business; for example, you may have a retail site that allows your audience to enter some basic information and compare pricing across several product variants. In these scenarios, you can employ the Stateless Rating pattern, which allows you to leverage your production rating logic to obtain prices, while minimizing Socotra API calls and eliminating the requirement to create draft policies for pricing.
This guide references a demo implementation on GitHub.
The Big Picture
The flow of a simple Stateless Rating implementation looks like this:
You construct a PolicyCreateRequest object for each variant that requires a price estimate.
You send one or more of the
PolicyCreateRequestobjects in an array to the Lambda API.
The Lambda plugin receives the array of
The Lambda plugin passes
PolicyCreateRequestobjects to the
PolicyResponse Generator, a component that yields a valid PolicyResponse which closely mimics the response that the production Socotra system would provide when actually creating a policy.
The Lambda plugin passes the
PolicyResponseand any other necessary
RatingPluginDatato your production rating plugin.
The Lambda plugin returns pricing data from the rater. In our demo implementation, we have the Lambda plugin return each
PolicyResponsedecorated with pricing data, instead of simply forwarding the pricing plugin response.
The Lambda API response contains the pricing data returned from the Lambda plugin.
You manipulate and format the Socotra API response for comparative pricing presentation.
Note how this pattern fulfills the solution requirements:
Socotra API calls are limited to the Lambda endpoint exclusively.
No actual draft policies are created in order to obtain pricing, reducing round-trip time and keeping your tenant free of unnecessary drafts.
Your production rater calculates pricing, helping to ensure that pricing estimates are in line with results obtained in the stateful quote lifecycle, without having to maintain rating logic in multiple places.
This solution requires the creation of a
PolicyResponse Generator script, a Lambda plugin, and possible updates to your rater plugin. These steps are detailed below, and illustrated in our demo implementation repository.
Create a Policy Response Generator
The Stateless Rating pattern requires an effective
PolicyResponse Generator script that yields
PolicyResponse objects with the following properties:
They conform well enough to the
PolicyResponseschema so that they can be provided directly to your rater plugin’s
They have all the attributes required by your rater’s pricing logic.
If your rater makes use of any data in other than
data.policy, such as
data.policyExposurePerils, you must ensure that your
PolicyResponse Generator provides those as well. You might also have to update your rater’s logic to ensure that stateless rating requests do not result in data requests for nonexistent data such as mock locator IDs.
You can use the demo implementation repository’s BuildSocotraPolicy.js as the basis for your own
PolicyResponse Generator. See the README for more details on running tests and modifying the component to suit your needs.
Examine Rater Responses
Make sure that the
PolicyResponse data from the
PolicyResponse Generator is sufficient for your rater to create pricing results that match or closely approximate results that you would obtain from a stateful policy quote. You may need to iterate on the response generator and your rater to realize this objective. If you have to update your rater, Socotra recommends that you have a solid testing foundation in place to mitigate the chances of introducing any regressions.
Create a Lambda Plugin
The Lambda plugin serves as the entry point for this pattern and glues the components together. You must import (
PolicyResponse Generator and your rater plugin’s
getPerilRates function, and ensure that the calls to these components are performed in response to a specific
operation. See the lambda.js example in the demo repository.
After deploying these components, you are ready to begin making stateless rating requests to the Socotra API via the Lambda endpoint.
If your rating algorithm is not a full replication of the normal rating process, you should be careful to note the approximate nature of results in any contexts in which such a disclaimer may be warranted.
You can augment this approach to avoid re-collecting the same data when a quoted potential policy is instantiated – for instance, if a prospective customer wishes to proceed with some quoted variant from your stateless rating result set. The general solution is to retain and reuse the policy creation request data in the subsequent policy creation request; such data can be stored in Auxiliary Data, along with some identifier to associate with a given prospective customer.