Skip to content

Recommend a product

Sometimes the customer doesn’t know which product they need. A product recommendation questionnaire asks for their trade and US state, then offers one or more products worth quoting. Starting one carries the answers over.

This page follows examples/product-recommendation.ts.

import { apiKey, createClient } from '@partner-sdk/core';
const client = createClient({ baseUrl: 'https://api.example.com', auth: apiKey(key) });
let r = await client.recommend();
r.recommendations; // [] — nothing to recommend yet
const { results } = await r.searchTrade('accountant');
r = await r.answer({ 'Primary trade': results[0].value, 'US state': 'Ohio' });
for (const rec of r.recommendations) {
console.log(rec.vertical, rec.title); // e.g. "usa", "business_owners_policy"
}

start() returns a quoting questionnaire, already seeded with the trade, state and cover.

const q = await r.recommendations[0].start();
q.questions; // the remaining questions for that product

From here, carry on as in the quick start, or pass the questionnaire to a session as initial:

const [rec] = r.recommendations;
const session = createSession({
client,
vertical: rec.vertical,
initial: rec.start(),
});