@exotel-npm-dev/exotel-ai-assist 1.1.1 → 1.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.
- package/README.md +11 -9
- package/dist/controller/index.js +25 -6
- package/dist/index.js +25 -6
- package/dist/react/index.js +25 -6
- package/dist/types/index.d.ts +7 -0
- package/dist/utils/index.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -171,6 +171,7 @@ const ctrl = new ExotelAIAssistController({
|
|
|
171
171
|
authToken: "your-auth-token",
|
|
172
172
|
call_sid: "CALL-SID-001",
|
|
173
173
|
accountId: "your-account-id",
|
|
174
|
+
env: "production", // defaults to PRODUCTION if omitted
|
|
174
175
|
});
|
|
175
176
|
|
|
176
177
|
ctrl.on("onReady", (ready) => {
|
|
@@ -221,15 +222,16 @@ Extends `EventEmitter`.
|
|
|
221
222
|
|
|
222
223
|
#### Constructor options (`ExotelAIAssistParams`)
|
|
223
224
|
|
|
224
|
-
| Field | Type
|
|
225
|
-
| ---------------------- |
|
|
226
|
-
| `authToken` | `string`
|
|
227
|
-
| `call_sid` | `string`
|
|
228
|
-
| `accountId` | `string`
|
|
229
|
-
| `
|
|
230
|
-
| `
|
|
231
|
-
| `
|
|
232
|
-
| `
|
|
225
|
+
| Field | Type | Required | Default | Description |
|
|
226
|
+
| ---------------------- | ------------- | -------- | -------------------------- | ------------------------------------------------------------------ |
|
|
227
|
+
| `authToken` | `string` | ✓ | — | Bearer token |
|
|
228
|
+
| `call_sid` | `string` | ✓ | — | Active call SID |
|
|
229
|
+
| `accountId` | `string` | ✓ | — | Exotel account identifier |
|
|
230
|
+
| `env` | `"production" or "uat" or "development"` | — | `production` | Target environment (`production`, `uat`, or `development`) |
|
|
231
|
+
| `wssBaseUrl` | `string` | — | Derived from `env` | Full override for the WebSocket URL (takes precedence over `env`) |
|
|
232
|
+
| `reconnectInterval` | `number` | — | `3000` | Base reconnect delay in ms |
|
|
233
|
+
| `maxReconnectAttempts` | `number` | — | `5` | Max retries before error |
|
|
234
|
+
| `[customParam]` | `string` | — | — | Extra query params forwarded to the server (max 3) |
|
|
233
235
|
|
|
234
236
|
#### Methods
|
|
235
237
|
|
package/dist/controller/index.js
CHANGED
|
@@ -1506,6 +1506,18 @@ function requireObject_hash() {
|
|
|
1506
1506
|
var object_hashExports = requireObject_hash();
|
|
1507
1507
|
var objectHash = /*@__PURE__*/getDefaultExportFromCjs(object_hashExports);
|
|
1508
1508
|
|
|
1509
|
+
var Environment;
|
|
1510
|
+
(function (Environment) {
|
|
1511
|
+
Environment["PRODUCTION"] = "production";
|
|
1512
|
+
Environment["UAT"] = "uat";
|
|
1513
|
+
Environment["DEVELOPMENT"] = "development";
|
|
1514
|
+
})(Environment || (Environment = {}));
|
|
1515
|
+
const WssBaseUrl = {
|
|
1516
|
+
[Environment.PRODUCTION]: "wss://ai-assist.in.exotel.com",
|
|
1517
|
+
[Environment.UAT]: "wss://oneassist-uat.in.exotel.com",
|
|
1518
|
+
[Environment.DEVELOPMENT]: "ws://localhost:8081"
|
|
1519
|
+
};
|
|
1520
|
+
|
|
1509
1521
|
class Utils {
|
|
1510
1522
|
/**
|
|
1511
1523
|
* Returns a deterministic SHA-1 hex digest for any plain object.
|
|
@@ -1537,10 +1549,16 @@ class Utils {
|
|
|
1537
1549
|
* @param accountId - The account ID to get the base WebSocket URL for.
|
|
1538
1550
|
* @returns The base WebSocket URL.
|
|
1539
1551
|
*/
|
|
1540
|
-
static getWssBaseUrl(accountId) {
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1552
|
+
static getWssBaseUrl(accountId, env) {
|
|
1553
|
+
if (env === Environment.DEVELOPMENT) {
|
|
1554
|
+
return `${WssBaseUrl[Environment.DEVELOPMENT]}/ai-assist/ws/v1/accounts/${accountId}/ai-assistants/conversation-events`;
|
|
1555
|
+
} else if (env === Environment.UAT) {
|
|
1556
|
+
return `${WssBaseUrl[Environment.UAT]}/ai-assist/ws/v1/accounts/${accountId}/ai-assistants/conversation-events`;
|
|
1557
|
+
} else if (env === Environment.PRODUCTION) {
|
|
1558
|
+
return `${WssBaseUrl[Environment.PRODUCTION]}/ai-assist/ws/v1/accounts/${accountId}/ai-assistants/conversation-events`;
|
|
1559
|
+
} else {
|
|
1560
|
+
return `${WssBaseUrl[Environment.PRODUCTION]}/ai-assist/ws/v1/accounts/${accountId}/ai-assistants/conversation-events`;
|
|
1561
|
+
}
|
|
1544
1562
|
}
|
|
1545
1563
|
/**
|
|
1546
1564
|
* Builds a WebSocket URL from the given parameters.
|
|
@@ -1548,17 +1566,18 @@ class Utils {
|
|
|
1548
1566
|
* @returns The WebSocket URL.
|
|
1549
1567
|
*/
|
|
1550
1568
|
static buildWsUrl(params) {
|
|
1569
|
+
var _a;
|
|
1551
1570
|
const {
|
|
1552
1571
|
wssBaseUrl
|
|
1553
1572
|
} = params;
|
|
1554
|
-
const resolved = wssBaseUrl !== null && wssBaseUrl !== void 0 ? wssBaseUrl : Utils.getWssBaseUrl(params.accountId);
|
|
1573
|
+
const resolved = wssBaseUrl !== null && wssBaseUrl !== void 0 ? wssBaseUrl : Utils.getWssBaseUrl(params.accountId, (_a = params === null || params === void 0 ? void 0 : params.env) !== null && _a !== void 0 ? _a : Environment.PRODUCTION);
|
|
1555
1574
|
const base = resolved.endsWith("/") ? resolved.slice(0, -1) : resolved;
|
|
1556
1575
|
const query = Utils.constructQueryParams(params);
|
|
1557
1576
|
return `${base}?${query}`;
|
|
1558
1577
|
}
|
|
1559
1578
|
static constructQueryParams(params) {
|
|
1560
1579
|
// Keys consumed by the library — never forwarded to the server.
|
|
1561
|
-
const INTERNAL_KEYS = new Set(["authToken", "accountId", "wssBaseUrl", "reconnectInterval", "maxReconnectAttempts"]);
|
|
1580
|
+
const INTERNAL_KEYS = new Set(["authToken", "accountId", "wssBaseUrl", "reconnectInterval", "maxReconnectAttempts", "env"]);
|
|
1562
1581
|
// Mandatory server params remapped to the names the API expects.
|
|
1563
1582
|
// accountId is embedded in the URL path — never sent as a query param.
|
|
1564
1583
|
const pairs = [];
|
package/dist/index.js
CHANGED
|
@@ -20924,6 +20924,18 @@ function requireObject_hash() {
|
|
|
20924
20924
|
var object_hashExports = requireObject_hash();
|
|
20925
20925
|
var objectHash = /*@__PURE__*/getDefaultExportFromCjs(object_hashExports);
|
|
20926
20926
|
|
|
20927
|
+
var Environment;
|
|
20928
|
+
(function (Environment) {
|
|
20929
|
+
Environment["PRODUCTION"] = "production";
|
|
20930
|
+
Environment["UAT"] = "uat";
|
|
20931
|
+
Environment["DEVELOPMENT"] = "development";
|
|
20932
|
+
})(Environment || (Environment = {}));
|
|
20933
|
+
const WssBaseUrl = {
|
|
20934
|
+
[Environment.PRODUCTION]: "wss://ai-assist.in.exotel.com",
|
|
20935
|
+
[Environment.UAT]: "wss://oneassist-uat.in.exotel.com",
|
|
20936
|
+
[Environment.DEVELOPMENT]: "ws://localhost:8081"
|
|
20937
|
+
};
|
|
20938
|
+
|
|
20927
20939
|
class Utils {
|
|
20928
20940
|
/**
|
|
20929
20941
|
* Returns a deterministic SHA-1 hex digest for any plain object.
|
|
@@ -20955,10 +20967,16 @@ class Utils {
|
|
|
20955
20967
|
* @param accountId - The account ID to get the base WebSocket URL for.
|
|
20956
20968
|
* @returns The base WebSocket URL.
|
|
20957
20969
|
*/
|
|
20958
|
-
static getWssBaseUrl(accountId) {
|
|
20959
|
-
|
|
20960
|
-
|
|
20961
|
-
|
|
20970
|
+
static getWssBaseUrl(accountId, env) {
|
|
20971
|
+
if (env === Environment.DEVELOPMENT) {
|
|
20972
|
+
return `${WssBaseUrl[Environment.DEVELOPMENT]}/ai-assist/ws/v1/accounts/${accountId}/ai-assistants/conversation-events`;
|
|
20973
|
+
} else if (env === Environment.UAT) {
|
|
20974
|
+
return `${WssBaseUrl[Environment.UAT]}/ai-assist/ws/v1/accounts/${accountId}/ai-assistants/conversation-events`;
|
|
20975
|
+
} else if (env === Environment.PRODUCTION) {
|
|
20976
|
+
return `${WssBaseUrl[Environment.PRODUCTION]}/ai-assist/ws/v1/accounts/${accountId}/ai-assistants/conversation-events`;
|
|
20977
|
+
} else {
|
|
20978
|
+
return `${WssBaseUrl[Environment.PRODUCTION]}/ai-assist/ws/v1/accounts/${accountId}/ai-assistants/conversation-events`;
|
|
20979
|
+
}
|
|
20962
20980
|
}
|
|
20963
20981
|
/**
|
|
20964
20982
|
* Builds a WebSocket URL from the given parameters.
|
|
@@ -20966,17 +20984,18 @@ class Utils {
|
|
|
20966
20984
|
* @returns The WebSocket URL.
|
|
20967
20985
|
*/
|
|
20968
20986
|
static buildWsUrl(params) {
|
|
20987
|
+
var _a;
|
|
20969
20988
|
const {
|
|
20970
20989
|
wssBaseUrl
|
|
20971
20990
|
} = params;
|
|
20972
|
-
const resolved = wssBaseUrl !== null && wssBaseUrl !== void 0 ? wssBaseUrl : Utils.getWssBaseUrl(params.accountId);
|
|
20991
|
+
const resolved = wssBaseUrl !== null && wssBaseUrl !== void 0 ? wssBaseUrl : Utils.getWssBaseUrl(params.accountId, (_a = params === null || params === void 0 ? void 0 : params.env) !== null && _a !== void 0 ? _a : Environment.PRODUCTION);
|
|
20973
20992
|
const base = resolved.endsWith("/") ? resolved.slice(0, -1) : resolved;
|
|
20974
20993
|
const query = Utils.constructQueryParams(params);
|
|
20975
20994
|
return `${base}?${query}`;
|
|
20976
20995
|
}
|
|
20977
20996
|
static constructQueryParams(params) {
|
|
20978
20997
|
// Keys consumed by the library — never forwarded to the server.
|
|
20979
|
-
const INTERNAL_KEYS = new Set(["authToken", "accountId", "wssBaseUrl", "reconnectInterval", "maxReconnectAttempts"]);
|
|
20998
|
+
const INTERNAL_KEYS = new Set(["authToken", "accountId", "wssBaseUrl", "reconnectInterval", "maxReconnectAttempts", "env"]);
|
|
20980
20999
|
// Mandatory server params remapped to the names the API expects.
|
|
20981
21000
|
// accountId is embedded in the URL path — never sent as a query param.
|
|
20982
21001
|
const pairs = [];
|
package/dist/react/index.js
CHANGED
|
@@ -6210,6 +6210,18 @@ function requireObject_hash() {
|
|
|
6210
6210
|
var object_hashExports = requireObject_hash();
|
|
6211
6211
|
var objectHash = /*@__PURE__*/getDefaultExportFromCjs(object_hashExports);
|
|
6212
6212
|
|
|
6213
|
+
var Environment;
|
|
6214
|
+
(function (Environment) {
|
|
6215
|
+
Environment["PRODUCTION"] = "production";
|
|
6216
|
+
Environment["UAT"] = "uat";
|
|
6217
|
+
Environment["DEVELOPMENT"] = "development";
|
|
6218
|
+
})(Environment || (Environment = {}));
|
|
6219
|
+
const WssBaseUrl = {
|
|
6220
|
+
[Environment.PRODUCTION]: "wss://ai-assist.in.exotel.com",
|
|
6221
|
+
[Environment.UAT]: "wss://oneassist-uat.in.exotel.com",
|
|
6222
|
+
[Environment.DEVELOPMENT]: "ws://localhost:8081"
|
|
6223
|
+
};
|
|
6224
|
+
|
|
6213
6225
|
class Utils {
|
|
6214
6226
|
/**
|
|
6215
6227
|
* Returns a deterministic SHA-1 hex digest for any plain object.
|
|
@@ -6241,10 +6253,16 @@ class Utils {
|
|
|
6241
6253
|
* @param accountId - The account ID to get the base WebSocket URL for.
|
|
6242
6254
|
* @returns The base WebSocket URL.
|
|
6243
6255
|
*/
|
|
6244
|
-
static getWssBaseUrl(accountId) {
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
6256
|
+
static getWssBaseUrl(accountId, env) {
|
|
6257
|
+
if (env === Environment.DEVELOPMENT) {
|
|
6258
|
+
return `${WssBaseUrl[Environment.DEVELOPMENT]}/ai-assist/ws/v1/accounts/${accountId}/ai-assistants/conversation-events`;
|
|
6259
|
+
} else if (env === Environment.UAT) {
|
|
6260
|
+
return `${WssBaseUrl[Environment.UAT]}/ai-assist/ws/v1/accounts/${accountId}/ai-assistants/conversation-events`;
|
|
6261
|
+
} else if (env === Environment.PRODUCTION) {
|
|
6262
|
+
return `${WssBaseUrl[Environment.PRODUCTION]}/ai-assist/ws/v1/accounts/${accountId}/ai-assistants/conversation-events`;
|
|
6263
|
+
} else {
|
|
6264
|
+
return `${WssBaseUrl[Environment.PRODUCTION]}/ai-assist/ws/v1/accounts/${accountId}/ai-assistants/conversation-events`;
|
|
6265
|
+
}
|
|
6248
6266
|
}
|
|
6249
6267
|
/**
|
|
6250
6268
|
* Builds a WebSocket URL from the given parameters.
|
|
@@ -6252,17 +6270,18 @@ class Utils {
|
|
|
6252
6270
|
* @returns The WebSocket URL.
|
|
6253
6271
|
*/
|
|
6254
6272
|
static buildWsUrl(params) {
|
|
6273
|
+
var _a;
|
|
6255
6274
|
const {
|
|
6256
6275
|
wssBaseUrl
|
|
6257
6276
|
} = params;
|
|
6258
|
-
const resolved = wssBaseUrl !== null && wssBaseUrl !== void 0 ? wssBaseUrl : Utils.getWssBaseUrl(params.accountId);
|
|
6277
|
+
const resolved = wssBaseUrl !== null && wssBaseUrl !== void 0 ? wssBaseUrl : Utils.getWssBaseUrl(params.accountId, (_a = params === null || params === void 0 ? void 0 : params.env) !== null && _a !== void 0 ? _a : Environment.PRODUCTION);
|
|
6259
6278
|
const base = resolved.endsWith("/") ? resolved.slice(0, -1) : resolved;
|
|
6260
6279
|
const query = Utils.constructQueryParams(params);
|
|
6261
6280
|
return `${base}?${query}`;
|
|
6262
6281
|
}
|
|
6263
6282
|
static constructQueryParams(params) {
|
|
6264
6283
|
// Keys consumed by the library — never forwarded to the server.
|
|
6265
|
-
const INTERNAL_KEYS = new Set(["authToken", "accountId", "wssBaseUrl", "reconnectInterval", "maxReconnectAttempts"]);
|
|
6284
|
+
const INTERNAL_KEYS = new Set(["authToken", "accountId", "wssBaseUrl", "reconnectInterval", "maxReconnectAttempts", "env"]);
|
|
6266
6285
|
// Mandatory server params remapped to the names the API expects.
|
|
6267
6286
|
// accountId is embedded in the URL path — never sent as a query param.
|
|
6268
6287
|
const pairs = [];
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
export declare enum Environment {
|
|
2
|
+
PRODUCTION = "production",
|
|
3
|
+
UAT = "uat",
|
|
4
|
+
DEVELOPMENT = "development"
|
|
5
|
+
}
|
|
6
|
+
export declare const WssBaseUrl: Record<Environment, string>;
|
|
1
7
|
export interface ExotelAIAssistParams {
|
|
2
8
|
authToken: string;
|
|
3
9
|
call_sid: string;
|
|
@@ -7,6 +13,7 @@ export interface ExotelAIAssistParams {
|
|
|
7
13
|
wssBaseUrl?: string;
|
|
8
14
|
reconnectInterval?: number;
|
|
9
15
|
maxReconnectAttempts?: number;
|
|
16
|
+
env?: Environment;
|
|
10
17
|
[key: string]: unknown;
|
|
11
18
|
}
|
|
12
19
|
/** A single AI-generated suggestion for the agent. */
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExotelAIAssistParams } from "../types";
|
|
1
|
+
import { Environment, ExotelAIAssistParams } from "../types";
|
|
2
2
|
export declare class Utils {
|
|
3
3
|
static MAX_EXTRA_QUERY_PARAMS: number;
|
|
4
4
|
/**
|
|
@@ -20,7 +20,7 @@ export declare class Utils {
|
|
|
20
20
|
* @param accountId - The account ID to get the base WebSocket URL for.
|
|
21
21
|
* @returns The base WebSocket URL.
|
|
22
22
|
*/
|
|
23
|
-
static getWssBaseUrl(accountId: string): string;
|
|
23
|
+
static getWssBaseUrl(accountId: string, env: Environment): string;
|
|
24
24
|
/**
|
|
25
25
|
* Builds a WebSocket URL from the given parameters.
|
|
26
26
|
* @param params - The parameters to build the WebSocket URL from.
|
package/package.json
CHANGED