@rehers/rehers-roleplay-sdk 2.1.1 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +43 -7
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @rehers/rehers-roleplay-sdk
2
2
 
3
- Lightweight vanilla JS SDK for embedding roleplay call sessions. Opens a modal (dialog mode) or mounts into a container (mount mode) — no framework dependencies.
3
+ Lightweight vanilla JS SDK for embedding roleplay call sessions and bulk contact import. Opens a modal (dialog mode), mounts into a container (mount mode), or launches a scenario picker (add-to-scenario mode) — no framework dependencies.
4
4
 
5
5
  ## Install
6
6
 
@@ -23,7 +23,7 @@ Or load via CDN:
23
23
  SeamlessRoleplay.init({
24
24
  publishableKey: 'pk_live_abc123',
25
25
  userId: 'user_789',
26
- userEmail: 'john@example.com', // optional
26
+ userEmail: 'john@example.com',
27
27
  trialUrl: 'https://seamless.ai/pricing', // optional — shown when user not found
28
28
  onReady: function() {
29
29
  console.log('SDK ready');
@@ -55,6 +55,19 @@ Or load via CDN:
55
55
  title: 'VP of Sales',
56
56
  });
57
57
 
58
+ // 3. Add contacts to a scenario in bulk
59
+ SeamlessRoleplay.addToScenario({
60
+ contacts: [
61
+ { name: 'Sarah Chen', company: 'Stripe', title: 'VP of Sales', domain: 'stripe.com', liUrl: 'https://linkedin.com/in/sarachen' },
62
+ { name: 'Mike Ross', company: 'Acme', title: 'CRO', domain: 'acme.com', liUrl: 'https://linkedin.com/in/mikeross' },
63
+ ],
64
+ onComplete: function(data) {
65
+ console.log('Added', data.addedCount, 'contacts to', data.scenarioName);
66
+ },
67
+ onClose: function() { console.log('Dialog closed'); },
68
+ onError: function(err) { console.error('Error:', err.code, err.message); },
69
+ });
70
+
58
71
  // Close and destroy
59
72
  SeamlessRoleplay.close();
60
73
  SeamlessRoleplay.destroy();
@@ -69,6 +82,7 @@ If the user doesn't have an active account, provide a `trialUrl` during init. Wh
69
82
  SeamlessRoleplay.init({
70
83
  publishableKey: 'pk_live_abc123',
71
84
  userId: 'unknown_user',
85
+ userEmail: 'unknown@example.com',
72
86
  trialUrl: 'https://seamless.ai/pricing',
73
87
  });
74
88
  ```
@@ -81,7 +95,7 @@ SeamlessRoleplay.init({
81
95
  |---|---|---|---|
82
96
  | `publishableKey` | `string` | Yes | Publishable API key |
83
97
  | `userId` | `string` | Yes | Your user's unique identifier |
84
- | `userEmail` | `string` | No | User email for account matching |
98
+ | `userEmail` | `string` | Yes | User email for secure account matching |
85
99
  | `userToken` | `string` | No | Signed JWT for identity verification |
86
100
  | `trialUrl` | `string` | No | URL shown when user not found |
87
101
  | `origin` | `string` | No | Override app origin (dev only) |
@@ -109,6 +123,23 @@ Opens the roleplay in a modal dialog overlay.
109
123
 
110
124
  Mounts the roleplay into a DOM element (full-page embed). Same `data` options as `open()`.
111
125
 
126
+ ### `SeamlessRoleplay.addToScenario(options)`
127
+
128
+ Opens a compact dialog for selecting a scenario and importing contacts in bulk.
129
+
130
+ | Field | Type | Required | Description |
131
+ |---|---|---|---|
132
+ | `contacts` | `array` | Yes | 1–25 contacts to import |
133
+ | `contacts[].name` | `string` | Yes | Full name |
134
+ | `contacts[].company` | `string` | Yes | Company name |
135
+ | `contacts[].title` | `string` | Yes | Job title |
136
+ | `contacts[].domain` | `string` | Yes | Company domain |
137
+ | `contacts[].liUrl` | `string` | No | LinkedIn profile URL |
138
+ | `contacts[].companyDescription` | `string` | No | Brief company description |
139
+ | `onComplete` | `function` | No | `({ scenarioId, scenarioName, addedCount, skippedCount })` |
140
+ | `onClose` | `function` | No | Called when dialog closes |
141
+ | `onError` | `function` | No | `({ code, message })` |
142
+
112
143
  ### `SeamlessRoleplay.close()`
113
144
 
114
145
  Closes the active dialog or unmounts.
@@ -124,10 +155,11 @@ SDK Backend
124
155
  ───────────────── ─────────────────
125
156
  POST /api/sdk/session
126
157
  X-Publishable-Key: pk_live_abc123
127
- Body: { userId, userEmail? }
158
+ Body: { userId, userEmail }
128
159
  1. Validate key + origin
129
- 2. Find/create user
130
- 3. Mint JWT (1hr TTL)
160
+ 2. Validate userId + userEmail combo
161
+ 3. Find/create user
162
+ 4. Mint JWT (1hr TTL)
131
163
  ←──── { sessionToken, expiresIn }
132
164
  OR { error: "USER_NOT_FOUND" }
133
165
 
@@ -135,10 +167,14 @@ Token stored in memory (not localStorage)
135
167
  Auto-refreshes at 80% of TTL
136
168
  ```
137
169
 
170
+ ## Error Handling
171
+
172
+ All public methods are wrapped in try/catch — the SDK will never throw an uncaught exception that could crash the host page. Errors are logged to `console.error` with a `[SeamlessRoleplay]` prefix and routed to the relevant `onError` callback when provided.
173
+
138
174
  ## TypeScript
139
175
 
140
176
  Full type declarations are included:
141
177
 
142
178
  ```ts
143
- import type { SeamlessRoleplaySDK, SeamlessRoleplayOpenData } from '@rehers/rehers-roleplay-sdk';
179
+ import type { SeamlessRoleplaySDK, SeamlessRoleplayOpenData, AddToScenarioOptions } from '@rehers/rehers-roleplay-sdk';
144
180
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rehers/rehers-roleplay-sdk",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "Seamless Roleplay SDK — embed roleplay call sessions via a modal + iframe",
5
5
  "main": "roleplay-sdk.js",
6
6
  "types": "index.d.ts",