Stateless Rating: How-To Guide

Introduction

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:

Stateless Rating Overview
  1. You construct a PolicyCreateRequest object for each variant that requires a price estimate.

  2. You send one or more of the PolicyCreateRequest objects in an array to the Lambda API.

  3. The Lambda plugin receives the array of PolicyCreateRequest objects.

  4. The Lambda plugin passes PolicyCreateRequest objects 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.

  5. The Lambda plugin passes the PolicyResponse and any other necessary RatingPluginData to your production rating plugin.

  6. The Lambda plugin returns pricing data from the rater. In our demo implementation, we have the Lambda plugin return each PolicyResponse decorated with pricing data, instead of simply forwarding the pricing plugin response.

  7. The Lambda API response contains the pricing data returned from the Lambda plugin.

  8. You manipulate and format the Socotra API response for comparative pricing presentation.

Note how this pattern fulfills the solution requirements:

  1. Socotra API calls are limited to the Lambda endpoint exclusively.

  2. No actual draft policies are created in order to obtain pricing, reducing round-trip time and keeping your tenant free of unnecessary drafts.

  3. 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.

Implementation

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:

  1. They conform well enough to the PolicyResponse schema so that they can be provided directly to your rater plugin’s data.policy input.

  2. They have all the attributes required by your rater’s pricing logic.

Note

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 (require) your 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.

Additional Considerations

  • 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.