@sendoracloud/sdk-react-native 0.18.7 → 0.18.9

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.
package/dist/index.cjs CHANGED
@@ -1646,6 +1646,13 @@ var SendoraSDK = class {
1646
1646
  this.debug = false;
1647
1647
  this.sessionId = "";
1648
1648
  this.autoTrackCleanup = null;
1649
+ /**
1650
+ * Lazy-allocated stable session id for chatbot conversations.
1651
+ * Survives only the JS lifetime — chatbot multi-turn context lives
1652
+ * server-side keyed on this id, so an app restart starts a fresh
1653
+ * thread (matches web SDK's `chatbot.sessionId` cache).
1654
+ */
1655
+ this._chatbotSessionId = null;
1649
1656
  }
1650
1657
  /** Initialize the SDK. Must be awaited at app startup before identify/track. */
1651
1658
  async init(config) {
@@ -1823,7 +1830,7 @@ var SendoraSDK = class {
1823
1830
  throw new Error("[sendoracloud] push token metadata exceeds 4KB.");
1824
1831
  }
1825
1832
  }
1826
- const data = await post(
1833
+ const res = await post(
1827
1834
  { apiUrl: this.config.apiUrl, publicKey: this.config.publicKey, debug: this.debug },
1828
1835
  "/api/v1/push/tokens",
1829
1836
  {
@@ -1836,6 +1843,11 @@ var SendoraSDK = class {
1836
1843
  metadata: reg.metadata ?? {}
1837
1844
  }
1838
1845
  );
1846
+ if (!res || !res.ok) {
1847
+ throw new Error(`[sendoracloud] push token registration failed (HTTP ${res?.status ?? "network"}).`);
1848
+ }
1849
+ const parsed = await res.json();
1850
+ const data = parsed?.data;
1839
1851
  if (!data?.tokenId) {
1840
1852
  throw new Error("[sendoracloud] push token registered but server returned no tokenId \u2014 upgrade backend to >= s58.16.");
1841
1853
  }
@@ -2199,6 +2211,45 @@ var SendoraSDK = class {
2199
2211
  }
2200
2212
  };
2201
2213
  }
2214
+ /**
2215
+ * Chatbot namespace — RAG-backed AI chat over the org's knowledge
2216
+ * base. Mirrors backend `/chatbot/message` SDK route + web SDK's
2217
+ * `Chatbot` class.
2218
+ *
2219
+ * `sendMessage({ chatbotId, message })` returns the bot's reply
2220
+ * plus citations (KB article IDs the answer was grounded in) and
2221
+ * mode (`ai` when AI is enabled for the org, `canned` when the
2222
+ * fallback fires). Pass a stable `sessionId` to preserve multi-turn
2223
+ * context across calls; SDK auto-generates one per app session if
2224
+ * omitted.
2225
+ */
2226
+ get chatbot() {
2227
+ const self = this;
2228
+ return {
2229
+ sendMessage: async (input) => {
2230
+ if (!self.config) throw new Error("[sendoracloud] init() must complete before chatbot.sendMessage().");
2231
+ const body = {
2232
+ chatbotId: input.chatbotId,
2233
+ sessionId: input.sessionId ?? self.chatbotSessionId(),
2234
+ message: input.message,
2235
+ userId: input.userId ?? self.userId ?? void 0
2236
+ };
2237
+ const res = await post(
2238
+ { apiUrl: self.config.apiUrl, publicKey: self.config.publicKey, debug: self.debug },
2239
+ "/chatbot/message",
2240
+ body
2241
+ );
2242
+ if (!res || !res.ok) throw new Error(`[sendoracloud] chatbot.sendMessage failed (${res?.status ?? "network"})`);
2243
+ const parsed = await res.json();
2244
+ if (!parsed.success || !parsed.data) throw new Error("[sendoracloud] chatbot.sendMessage: bad response");
2245
+ return parsed.data;
2246
+ }
2247
+ };
2248
+ }
2249
+ chatbotSessionId() {
2250
+ if (!this._chatbotSessionId) this._chatbotSessionId = `chat_${uuid().replace(/-/g, "").slice(0, 24)}`;
2251
+ return this._chatbotSessionId;
2252
+ }
2202
2253
  /**
2203
2254
  * Clear identity + rotate the anonymous id. Call on logout. Awaits
2204
2255
  * the AsyncStorage writes so a caller who kills the app immediately
package/dist/index.d.cts CHANGED
@@ -1075,6 +1075,42 @@ declare class SendoraSDK {
1075
1075
  reason: string;
1076
1076
  }>>;
1077
1077
  };
1078
+ /**
1079
+ * Chatbot namespace — RAG-backed AI chat over the org's knowledge
1080
+ * base. Mirrors backend `/chatbot/message` SDK route + web SDK's
1081
+ * `Chatbot` class.
1082
+ *
1083
+ * `sendMessage({ chatbotId, message })` returns the bot's reply
1084
+ * plus citations (KB article IDs the answer was grounded in) and
1085
+ * mode (`ai` when AI is enabled for the org, `canned` when the
1086
+ * fallback fires). Pass a stable `sessionId` to preserve multi-turn
1087
+ * context across calls; SDK auto-generates one per app session if
1088
+ * omitted.
1089
+ */
1090
+ get chatbot(): {
1091
+ sendMessage: (input: {
1092
+ chatbotId: string;
1093
+ message: string;
1094
+ sessionId?: string;
1095
+ userId?: string;
1096
+ }) => Promise<{
1097
+ reply: string;
1098
+ mode: "ai" | "canned" | string;
1099
+ citations: Array<{
1100
+ id: string;
1101
+ title: string;
1102
+ slug?: string;
1103
+ }> | null;
1104
+ }>;
1105
+ };
1106
+ /**
1107
+ * Lazy-allocated stable session id for chatbot conversations.
1108
+ * Survives only the JS lifetime — chatbot multi-turn context lives
1109
+ * server-side keyed on this id, so an app restart starts a fresh
1110
+ * thread (matches web SDK's `chatbot.sessionId` cache).
1111
+ */
1112
+ private _chatbotSessionId;
1113
+ private chatbotSessionId;
1078
1114
  /**
1079
1115
  * Clear identity + rotate the anonymous id. Call on logout. Awaits
1080
1116
  * the AsyncStorage writes so a caller who kills the app immediately
package/dist/index.d.ts CHANGED
@@ -1075,6 +1075,42 @@ declare class SendoraSDK {
1075
1075
  reason: string;
1076
1076
  }>>;
1077
1077
  };
1078
+ /**
1079
+ * Chatbot namespace — RAG-backed AI chat over the org's knowledge
1080
+ * base. Mirrors backend `/chatbot/message` SDK route + web SDK's
1081
+ * `Chatbot` class.
1082
+ *
1083
+ * `sendMessage({ chatbotId, message })` returns the bot's reply
1084
+ * plus citations (KB article IDs the answer was grounded in) and
1085
+ * mode (`ai` when AI is enabled for the org, `canned` when the
1086
+ * fallback fires). Pass a stable `sessionId` to preserve multi-turn
1087
+ * context across calls; SDK auto-generates one per app session if
1088
+ * omitted.
1089
+ */
1090
+ get chatbot(): {
1091
+ sendMessage: (input: {
1092
+ chatbotId: string;
1093
+ message: string;
1094
+ sessionId?: string;
1095
+ userId?: string;
1096
+ }) => Promise<{
1097
+ reply: string;
1098
+ mode: "ai" | "canned" | string;
1099
+ citations: Array<{
1100
+ id: string;
1101
+ title: string;
1102
+ slug?: string;
1103
+ }> | null;
1104
+ }>;
1105
+ };
1106
+ /**
1107
+ * Lazy-allocated stable session id for chatbot conversations.
1108
+ * Survives only the JS lifetime — chatbot multi-turn context lives
1109
+ * server-side keyed on this id, so an app restart starts a fresh
1110
+ * thread (matches web SDK's `chatbot.sessionId` cache).
1111
+ */
1112
+ private _chatbotSessionId;
1113
+ private chatbotSessionId;
1078
1114
  /**
1079
1115
  * Clear identity + rotate the anonymous id. Call on logout. Awaits
1080
1116
  * the AsyncStorage writes so a caller who kills the app immediately
package/dist/index.js CHANGED
@@ -1608,6 +1608,13 @@ var SendoraSDK = class {
1608
1608
  this.debug = false;
1609
1609
  this.sessionId = "";
1610
1610
  this.autoTrackCleanup = null;
1611
+ /**
1612
+ * Lazy-allocated stable session id for chatbot conversations.
1613
+ * Survives only the JS lifetime — chatbot multi-turn context lives
1614
+ * server-side keyed on this id, so an app restart starts a fresh
1615
+ * thread (matches web SDK's `chatbot.sessionId` cache).
1616
+ */
1617
+ this._chatbotSessionId = null;
1611
1618
  }
1612
1619
  /** Initialize the SDK. Must be awaited at app startup before identify/track. */
1613
1620
  async init(config) {
@@ -1785,7 +1792,7 @@ var SendoraSDK = class {
1785
1792
  throw new Error("[sendoracloud] push token metadata exceeds 4KB.");
1786
1793
  }
1787
1794
  }
1788
- const data = await post(
1795
+ const res = await post(
1789
1796
  { apiUrl: this.config.apiUrl, publicKey: this.config.publicKey, debug: this.debug },
1790
1797
  "/api/v1/push/tokens",
1791
1798
  {
@@ -1798,6 +1805,11 @@ var SendoraSDK = class {
1798
1805
  metadata: reg.metadata ?? {}
1799
1806
  }
1800
1807
  );
1808
+ if (!res || !res.ok) {
1809
+ throw new Error(`[sendoracloud] push token registration failed (HTTP ${res?.status ?? "network"}).`);
1810
+ }
1811
+ const parsed = await res.json();
1812
+ const data = parsed?.data;
1801
1813
  if (!data?.tokenId) {
1802
1814
  throw new Error("[sendoracloud] push token registered but server returned no tokenId \u2014 upgrade backend to >= s58.16.");
1803
1815
  }
@@ -2161,6 +2173,45 @@ var SendoraSDK = class {
2161
2173
  }
2162
2174
  };
2163
2175
  }
2176
+ /**
2177
+ * Chatbot namespace — RAG-backed AI chat over the org's knowledge
2178
+ * base. Mirrors backend `/chatbot/message` SDK route + web SDK's
2179
+ * `Chatbot` class.
2180
+ *
2181
+ * `sendMessage({ chatbotId, message })` returns the bot's reply
2182
+ * plus citations (KB article IDs the answer was grounded in) and
2183
+ * mode (`ai` when AI is enabled for the org, `canned` when the
2184
+ * fallback fires). Pass a stable `sessionId` to preserve multi-turn
2185
+ * context across calls; SDK auto-generates one per app session if
2186
+ * omitted.
2187
+ */
2188
+ get chatbot() {
2189
+ const self = this;
2190
+ return {
2191
+ sendMessage: async (input) => {
2192
+ if (!self.config) throw new Error("[sendoracloud] init() must complete before chatbot.sendMessage().");
2193
+ const body = {
2194
+ chatbotId: input.chatbotId,
2195
+ sessionId: input.sessionId ?? self.chatbotSessionId(),
2196
+ message: input.message,
2197
+ userId: input.userId ?? self.userId ?? void 0
2198
+ };
2199
+ const res = await post(
2200
+ { apiUrl: self.config.apiUrl, publicKey: self.config.publicKey, debug: self.debug },
2201
+ "/chatbot/message",
2202
+ body
2203
+ );
2204
+ if (!res || !res.ok) throw new Error(`[sendoracloud] chatbot.sendMessage failed (${res?.status ?? "network"})`);
2205
+ const parsed = await res.json();
2206
+ if (!parsed.success || !parsed.data) throw new Error("[sendoracloud] chatbot.sendMessage: bad response");
2207
+ return parsed.data;
2208
+ }
2209
+ };
2210
+ }
2211
+ chatbotSessionId() {
2212
+ if (!this._chatbotSessionId) this._chatbotSessionId = `chat_${uuid().replace(/-/g, "").slice(0, 24)}`;
2213
+ return this._chatbotSessionId;
2214
+ }
2164
2215
  /**
2165
2216
  * Clear identity + rotate the anonymous id. Call on logout. Awaits
2166
2217
  * the AsyncStorage writes so a caller who kills the app immediately
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sendoracloud/sdk-react-native",
3
- "version": "0.18.7",
3
+ "version": "0.18.9",
4
4
  "description": "Sendora Cloud React Native + Expo SDK — analytics, identity, push-token registration, auth, deep links (Branch / Firebase Dynamic Links parity). Auth + analytics + deep links work in Expo Go; push token registration requires a Dev Client (EAS Build or `npx expo prebuild`).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",