@sendoracloud/sdk-react-native 0.18.7 → 0.18.8
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 +46 -0
- package/dist/index.d.cts +36 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +46 -0
- package/package.json +1 -1
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) {
|
|
@@ -2199,6 +2206,45 @@ var SendoraSDK = class {
|
|
|
2199
2206
|
}
|
|
2200
2207
|
};
|
|
2201
2208
|
}
|
|
2209
|
+
/**
|
|
2210
|
+
* Chatbot namespace — RAG-backed AI chat over the org's knowledge
|
|
2211
|
+
* base. Mirrors backend `/chatbot/message` SDK route + web SDK's
|
|
2212
|
+
* `Chatbot` class.
|
|
2213
|
+
*
|
|
2214
|
+
* `sendMessage({ chatbotId, message })` returns the bot's reply
|
|
2215
|
+
* plus citations (KB article IDs the answer was grounded in) and
|
|
2216
|
+
* mode (`ai` when AI is enabled for the org, `canned` when the
|
|
2217
|
+
* fallback fires). Pass a stable `sessionId` to preserve multi-turn
|
|
2218
|
+
* context across calls; SDK auto-generates one per app session if
|
|
2219
|
+
* omitted.
|
|
2220
|
+
*/
|
|
2221
|
+
get chatbot() {
|
|
2222
|
+
const self = this;
|
|
2223
|
+
return {
|
|
2224
|
+
sendMessage: async (input) => {
|
|
2225
|
+
if (!self.config) throw new Error("[sendoracloud] init() must complete before chatbot.sendMessage().");
|
|
2226
|
+
const body = {
|
|
2227
|
+
chatbotId: input.chatbotId,
|
|
2228
|
+
sessionId: input.sessionId ?? self.chatbotSessionId(),
|
|
2229
|
+
message: input.message,
|
|
2230
|
+
userId: input.userId ?? self.userId ?? void 0
|
|
2231
|
+
};
|
|
2232
|
+
const res = await post(
|
|
2233
|
+
{ apiUrl: self.config.apiUrl, publicKey: self.config.publicKey, debug: self.debug },
|
|
2234
|
+
"/chatbot/message",
|
|
2235
|
+
body
|
|
2236
|
+
);
|
|
2237
|
+
if (!res || !res.ok) throw new Error(`[sendoracloud] chatbot.sendMessage failed (${res?.status ?? "network"})`);
|
|
2238
|
+
const parsed = await res.json();
|
|
2239
|
+
if (!parsed.success || !parsed.data) throw new Error("[sendoracloud] chatbot.sendMessage: bad response");
|
|
2240
|
+
return parsed.data;
|
|
2241
|
+
}
|
|
2242
|
+
};
|
|
2243
|
+
}
|
|
2244
|
+
chatbotSessionId() {
|
|
2245
|
+
if (!this._chatbotSessionId) this._chatbotSessionId = `chat_${uuid().replace(/-/g, "").slice(0, 24)}`;
|
|
2246
|
+
return this._chatbotSessionId;
|
|
2247
|
+
}
|
|
2202
2248
|
/**
|
|
2203
2249
|
* Clear identity + rotate the anonymous id. Call on logout. Awaits
|
|
2204
2250
|
* 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) {
|
|
@@ -2161,6 +2168,45 @@ var SendoraSDK = class {
|
|
|
2161
2168
|
}
|
|
2162
2169
|
};
|
|
2163
2170
|
}
|
|
2171
|
+
/**
|
|
2172
|
+
* Chatbot namespace — RAG-backed AI chat over the org's knowledge
|
|
2173
|
+
* base. Mirrors backend `/chatbot/message` SDK route + web SDK's
|
|
2174
|
+
* `Chatbot` class.
|
|
2175
|
+
*
|
|
2176
|
+
* `sendMessage({ chatbotId, message })` returns the bot's reply
|
|
2177
|
+
* plus citations (KB article IDs the answer was grounded in) and
|
|
2178
|
+
* mode (`ai` when AI is enabled for the org, `canned` when the
|
|
2179
|
+
* fallback fires). Pass a stable `sessionId` to preserve multi-turn
|
|
2180
|
+
* context across calls; SDK auto-generates one per app session if
|
|
2181
|
+
* omitted.
|
|
2182
|
+
*/
|
|
2183
|
+
get chatbot() {
|
|
2184
|
+
const self = this;
|
|
2185
|
+
return {
|
|
2186
|
+
sendMessage: async (input) => {
|
|
2187
|
+
if (!self.config) throw new Error("[sendoracloud] init() must complete before chatbot.sendMessage().");
|
|
2188
|
+
const body = {
|
|
2189
|
+
chatbotId: input.chatbotId,
|
|
2190
|
+
sessionId: input.sessionId ?? self.chatbotSessionId(),
|
|
2191
|
+
message: input.message,
|
|
2192
|
+
userId: input.userId ?? self.userId ?? void 0
|
|
2193
|
+
};
|
|
2194
|
+
const res = await post(
|
|
2195
|
+
{ apiUrl: self.config.apiUrl, publicKey: self.config.publicKey, debug: self.debug },
|
|
2196
|
+
"/chatbot/message",
|
|
2197
|
+
body
|
|
2198
|
+
);
|
|
2199
|
+
if (!res || !res.ok) throw new Error(`[sendoracloud] chatbot.sendMessage failed (${res?.status ?? "network"})`);
|
|
2200
|
+
const parsed = await res.json();
|
|
2201
|
+
if (!parsed.success || !parsed.data) throw new Error("[sendoracloud] chatbot.sendMessage: bad response");
|
|
2202
|
+
return parsed.data;
|
|
2203
|
+
}
|
|
2204
|
+
};
|
|
2205
|
+
}
|
|
2206
|
+
chatbotSessionId() {
|
|
2207
|
+
if (!this._chatbotSessionId) this._chatbotSessionId = `chat_${uuid().replace(/-/g, "").slice(0, 24)}`;
|
|
2208
|
+
return this._chatbotSessionId;
|
|
2209
|
+
}
|
|
2164
2210
|
/**
|
|
2165
2211
|
* Clear identity + rotate the anonymous id. Call on logout. Awaits
|
|
2166
2212
|
* 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.
|
|
3
|
+
"version": "0.18.8",
|
|
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",
|