Documentation Index
Fetch the complete documentation index at: https://docs.nusomi.com/llms.txt
Use this file to discover all available pages before exploring further.
Salesforce is one of the most common Nusomi recording surfaces — it’s where the work that “should have been an API call” actually happens. This recipe covers a typical lead-routing workflow.
Setup
Enable browser capture on *.salesforce.com and any custom Lightning communities:
# nusomi.workflow.yaml
workflow: salesforce_lead_route
capture:
browser:
domains:
- "*.salesforce.com"
- "*.force.com"
- "*.lightning.force.com"
record_screenshots: true
The DOM is the source of truth for Salesforce — Lightning’s component IDs are stable enough for exact replay, but the screenshots help training and human review.
Recording a workflow
The operator opens a lead, runs through scoring, assigns the territory, and submits. As they work, Nusomi captures every click, field edit, and validation error.
import { Nusomi } from "@nusomi/sdk";
const nusomi = new Nusomi({ apiKey: process.env.NUSOMI_API_KEY });
// The desktop / browser extension picks up the workflow trigger automatically
// when the operator opens a lead URL matching the configured rule.
// Or, drive it explicitly:
const session = await nusomi.sessions.create({
workflow: "salesforce_lead_route",
metadata: {
lead_id: "00Q5g000003ABCD",
routing_strategy: "territory_v2",
},
});
await session.start();
// ... operator works ...
await session.tag("territory_assigned", { territory: "EMEA-North" });
// ... operator submits ...
await session.tag("submitted_for_approval");
await session.stop();
Replaying for the next lead
When the next lead matches the same shape, Nusomi can replay the path:
// Find a recent successful session for the same routing strategy
const [exemplar] = await nusomi.sessions.list({
workflow: "salesforce_lead_route",
outcome: "success",
metadata: { routing_strategy: "territory_v2" },
limit: 1,
});
// Guided replay against the new lead
const replay = await nusomi.replay.guided(exemplar.id, {
sandbox: "live",
metadata: { lead_id: "00Q5g000003WXYZ" },
});
await replay.run();
Guided replay handles the cases exact replay can’t: a new validation rule, a renamed picklist value, a Lightning component that moved.
Recovery after a validation error
Salesforce loves to throw inline validation errors at submit. When that happens:
nusomi.events.on("validation_error", async (ev) => {
if (ev.session.workflow !== "salesforce_lead_route") return;
const recovery = await nusomi.recovery.from(ev.session_id, {
mode: "guided",
max_attempts: 2,
});
await recovery.run();
});
Recovery resumes at the frame just before the validation error, with the form’s prior state restored.
Training from successful runs
Once you have a few hundred recorded runs, export them as a training set:
await nusomi.exports.create({
workflow: "salesforce_lead_route",
filter: { outcome: "success", since: "60d" },
format: "webdataset",
destination: {
kind: "s3",
bucket: "acme-training",
prefix: "salesforce/lead_route/v1/",
},
tag: "salesforce_lead_route@v1",
});
The dataset contains a frame for every action the operator took, paired with the action itself. Hand it to your model training pipeline.
Tips
- Mask PII at the field level. Salesforce contact records contain names, phone numbers, and emails. Either turn on the workspace
email and phone_intl patterns or right-click-redact the sensitive fields.
- Tag intent, not implementation. Tag
territory_assigned instead of clicked-button-7. Tags are how the memory graph clusters runs.
- Keep one workflow slug per intent. “Lead routing” is a workflow. “Lead routing for EMEA” is metadata, not a separate workflow.