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.
1. Start a recommendation
Section titled “1. Start a recommendation”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 yet2. Answer trade and state
Section titled “2. Answer trade and state”const { results } = await r.searchTrade('accountant');r = await r.answer({ 'Primary trade': results[0].value, 'US state': 'Ohio' });3. Pick a recommendation
Section titled “3. Pick a recommendation”for (const rec of r.recommendations) { console.log(rec.vertical, rec.title); // e.g. "usa", "business_owners_policy"}4. Start quoting
Section titled “4. Start quoting”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 productFrom 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(),});