n8n-nodes-ringee 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +255 -2
- package/dist/credentials/RingeeApi.credentials.d.ts +13 -0
- package/dist/credentials/RingeeApi.credentials.js +76 -0
- package/dist/credentials/RingeeApi.credentials.js.map +1 -0
- package/dist/credentials/ringee.dark.svg +1 -0
- package/dist/credentials/ringee.svg +1 -0
- package/dist/lib/api/capabilities.d.ts +4 -0
- package/dist/lib/api/capabilities.js +56 -0
- package/dist/lib/api/capabilities.js.map +1 -0
- package/dist/lib/api/client.d.ts +27 -0
- package/dist/lib/api/client.js +163 -0
- package/dist/lib/api/client.js.map +1 -0
- package/dist/lib/errors/index.d.ts +12 -0
- package/dist/lib/errors/index.js +172 -0
- package/dist/lib/errors/index.js.map +1 -0
- package/dist/lib/types/index.d.ts +233 -0
- package/dist/lib/types/index.js +114 -0
- package/dist/lib/types/index.js.map +1 -0
- package/dist/lib/utils/base-url.d.ts +9 -0
- package/dist/lib/utils/base-url.js +42 -0
- package/dist/lib/utils/base-url.js.map +1 -0
- package/dist/lib/utils/dedupe.d.ts +7 -0
- package/dist/lib/utils/dedupe.js +23 -0
- package/dist/lib/utils/dedupe.js.map +1 -0
- package/dist/lib/utils/idempotency.d.ts +10 -0
- package/dist/lib/utils/idempotency.js +17 -0
- package/dist/lib/utils/idempotency.js.map +1 -0
- package/dist/lib/utils/phone.d.ts +4 -0
- package/dist/lib/utils/phone.js +23 -0
- package/dist/lib/utils/phone.js.map +1 -0
- package/dist/lib/utils/webhook.d.ts +19 -0
- package/dist/lib/utils/webhook.js +56 -0
- package/dist/lib/utils/webhook.js.map +1 -0
- package/dist/nodes/Ringee/Ringee.node.d.ts +17 -0
- package/dist/nodes/Ringee/Ringee.node.js +78 -0
- package/dist/nodes/Ringee/Ringee.node.js.map +1 -0
- package/dist/nodes/Ringee/Ringee.node.json +19 -0
- package/dist/nodes/Ringee/methods/listSearch.d.ts +4 -0
- package/dist/nodes/Ringee/methods/listSearch.js +66 -0
- package/dist/nodes/Ringee/methods/listSearch.js.map +1 -0
- package/dist/nodes/Ringee/methods/resourceMapping.d.ts +2 -0
- package/dist/nodes/Ringee/methods/resourceMapping.js +26 -0
- package/dist/nodes/Ringee/methods/resourceMapping.js.map +1 -0
- package/dist/nodes/Ringee/resources/aiAgent/index.d.ts +2 -0
- package/dist/nodes/Ringee/resources/aiAgent/index.js +413 -0
- package/dist/nodes/Ringee/resources/aiAgent/index.js.map +1 -0
- package/dist/nodes/Ringee/resources/call/index.d.ts +2 -0
- package/dist/nodes/Ringee/resources/call/index.js +199 -0
- package/dist/nodes/Ringee/resources/call/index.js.map +1 -0
- package/dist/nodes/Ringee/resources/contact/index.d.ts +2 -0
- package/dist/nodes/Ringee/resources/contact/index.js +329 -0
- package/dist/nodes/Ringee/resources/contact/index.js.map +1 -0
- package/dist/nodes/Ringee/resources/index.d.ts +4 -0
- package/dist/nodes/Ringee/resources/index.js +26 -0
- package/dist/nodes/Ringee/resources/index.js.map +1 -0
- package/dist/nodes/Ringee/resources/phoneNumber/index.d.ts +2 -0
- package/dist/nodes/Ringee/resources/phoneNumber/index.js +114 -0
- package/dist/nodes/Ringee/resources/phoneNumber/index.js.map +1 -0
- package/dist/nodes/Ringee/resources/recording/index.d.ts +2 -0
- package/dist/nodes/Ringee/resources/recording/index.js +87 -0
- package/dist/nodes/Ringee/resources/recording/index.js.map +1 -0
- package/dist/nodes/Ringee/resources/transcript/index.d.ts +2 -0
- package/dist/nodes/Ringee/resources/transcript/index.js +112 -0
- package/dist/nodes/Ringee/resources/transcript/index.js.map +1 -0
- package/dist/nodes/Ringee/resources/types.d.ts +6 -0
- package/dist/nodes/Ringee/resources/types.js +3 -0
- package/dist/nodes/Ringee/resources/types.js.map +1 -0
- package/dist/nodes/Ringee/ringee.dark.svg +1 -0
- package/dist/nodes/Ringee/ringee.svg +1 -0
- package/dist/nodes/Ringee/shared/call-detail.d.ts +7 -0
- package/dist/nodes/Ringee/shared/call-detail.js +50 -0
- package/dist/nodes/Ringee/shared/call-detail.js.map +1 -0
- package/dist/nodes/Ringee/shared/execution.d.ts +5 -0
- package/dist/nodes/Ringee/shared/execution.js +28 -0
- package/dist/nodes/Ringee/shared/execution.js.map +1 -0
- package/dist/nodes/Ringee/shared/fields.d.ts +7 -0
- package/dist/nodes/Ringee/shared/fields.js +113 -0
- package/dist/nodes/Ringee/shared/fields.js.map +1 -0
- package/dist/nodes/RingeeTrigger/RingeeTrigger.node.d.ts +30 -0
- package/dist/nodes/RingeeTrigger/RingeeTrigger.node.js +224 -0
- package/dist/nodes/RingeeTrigger/RingeeTrigger.node.js.map +1 -0
- package/dist/nodes/RingeeTrigger/RingeeTrigger.node.json +19 -0
- package/dist/package.json +81 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +80 -5
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CREDENTIAL_NAME = void 0;
|
|
4
|
+
exports.ringeeRequest = ringeeRequest;
|
|
5
|
+
exports.ringeeRequestBinary = ringeeRequestBinary;
|
|
6
|
+
exports.ringeeRequestAllItems = ringeeRequestAllItems;
|
|
7
|
+
exports.shouldRetry = shouldRetry;
|
|
8
|
+
exports.isCapacityRefusal = isCapacityRefusal;
|
|
9
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
10
|
+
const errors_1 = require("../errors");
|
|
11
|
+
const base_url_1 = require("../utils/base-url");
|
|
12
|
+
exports.CREDENTIAL_NAME = 'ringeeApi';
|
|
13
|
+
const DEFAULT_TIMEOUT_MS = 30000;
|
|
14
|
+
const MAX_RETRIES = 2;
|
|
15
|
+
const MAX_RETRY_WAIT_SECONDS = 20;
|
|
16
|
+
const SAFE_TO_REPEAT = new Set(['GET']);
|
|
17
|
+
const NOT_PROCESSED = new Set([429]);
|
|
18
|
+
const TRANSIENT = new Set([502, 503, 504]);
|
|
19
|
+
async function ringeeRequest(ctx, request) {
|
|
20
|
+
const response = await send(ctx, request, 'json');
|
|
21
|
+
return response.body;
|
|
22
|
+
}
|
|
23
|
+
async function ringeeRequestBinary(ctx, request) {
|
|
24
|
+
const response = await send(ctx, request, 'arraybuffer');
|
|
25
|
+
const body = response.body;
|
|
26
|
+
const data = Buffer.isBuffer(body) ? body : Buffer.from(body);
|
|
27
|
+
return {
|
|
28
|
+
data,
|
|
29
|
+
contentType: headerValue(response.headers['content-type']),
|
|
30
|
+
contentDisposition: headerValue(response.headers['content-disposition']),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
async function ringeeRequestAllItems(ctx, request, options = { returnAll: true }) {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
const maxPageSize = (_a = options.pageSize) !== null && _a !== void 0 ? _a : 100;
|
|
36
|
+
const wanted = options.returnAll ? Infinity : Math.max(1, (_b = options.limit) !== null && _b !== void 0 ? _b : 50);
|
|
37
|
+
const pageSize = Math.min(maxPageSize, wanted);
|
|
38
|
+
const items = [];
|
|
39
|
+
let page = 1;
|
|
40
|
+
for (;;) {
|
|
41
|
+
const response = await ringeeRequest(ctx, {
|
|
42
|
+
...request,
|
|
43
|
+
qs: { ...request.qs, page, limit: pageSize },
|
|
44
|
+
});
|
|
45
|
+
const batch = Array.isArray(response === null || response === void 0 ? void 0 : response.data) ? response.data : [];
|
|
46
|
+
items.push(...batch);
|
|
47
|
+
const reachedTotal = typeof (response === null || response === void 0 ? void 0 : response.total) === 'number' && items.length >= response.total;
|
|
48
|
+
if (batch.length < pageSize || reachedTotal || items.length >= wanted)
|
|
49
|
+
break;
|
|
50
|
+
page += 1;
|
|
51
|
+
}
|
|
52
|
+
return items.slice(0, wanted === Infinity ? undefined : wanted);
|
|
53
|
+
}
|
|
54
|
+
async function send(ctx, request, encoding) {
|
|
55
|
+
var _a, _b;
|
|
56
|
+
const credentials = await ctx.getCredentials(exports.CREDENTIAL_NAME);
|
|
57
|
+
const parsed = (0, base_url_1.parseBaseUrl)(credentials.baseUrl);
|
|
58
|
+
if (!parsed.ok) {
|
|
59
|
+
throw new n8n_workflow_1.NodeOperationError(ctx.getNode(), parsed.message, {
|
|
60
|
+
itemIndex: request.itemIndex,
|
|
61
|
+
description: 'Fix the Base URL in your Ringee credential.',
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
const baseUrl = parsed.url;
|
|
65
|
+
const headers = {
|
|
66
|
+
Accept: encoding === 'json' ? 'application/json' : '*/*',
|
|
67
|
+
...request.headers,
|
|
68
|
+
};
|
|
69
|
+
if (request.idempotencyKey)
|
|
70
|
+
headers['Idempotency-Key'] = request.idempotencyKey;
|
|
71
|
+
const options = {
|
|
72
|
+
method: request.method,
|
|
73
|
+
url: `${baseUrl}/api${request.path}`,
|
|
74
|
+
headers,
|
|
75
|
+
qs: request.qs,
|
|
76
|
+
body: request.body,
|
|
77
|
+
json: encoding === 'json',
|
|
78
|
+
encoding: encoding === 'json' ? 'json' : 'arraybuffer',
|
|
79
|
+
returnFullResponse: true,
|
|
80
|
+
ignoreHttpStatusErrors: true,
|
|
81
|
+
disableFollowRedirect: true,
|
|
82
|
+
timeout: (_a = request.timeoutMs) !== null && _a !== void 0 ? _a : DEFAULT_TIMEOUT_MS,
|
|
83
|
+
};
|
|
84
|
+
for (let attempt = 0;; attempt++) {
|
|
85
|
+
let response;
|
|
86
|
+
let networkFailure;
|
|
87
|
+
try {
|
|
88
|
+
response = (await ctx.helpers.httpRequestWithAuthentication.call(ctx, exports.CREDENTIAL_NAME, options));
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
networkFailure = error;
|
|
92
|
+
}
|
|
93
|
+
if (response && response.statusCode >= 200 && response.statusCode < 300)
|
|
94
|
+
return response;
|
|
95
|
+
const status = response === null || response === void 0 ? void 0 : response.statusCode;
|
|
96
|
+
if (attempt < MAX_RETRIES &&
|
|
97
|
+
shouldRetry(request.method, status) &&
|
|
98
|
+
!isCapacityRefusal(status, response === null || response === void 0 ? void 0 : response.body)) {
|
|
99
|
+
await (0, n8n_workflow_1.sleep)(retryDelayMs(response, attempt));
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (!response) {
|
|
103
|
+
throw new n8n_workflow_1.NodeApiError(ctx.getNode(), networkFailure, {
|
|
104
|
+
itemIndex: request.itemIndex,
|
|
105
|
+
message: 'Could not reach Ringee',
|
|
106
|
+
description: `Check your connection and the Base URL in the credential (${baseUrl}). ${(_b = networkFailure === null || networkFailure === void 0 ? void 0 : networkFailure.message) !== null && _b !== void 0 ? _b : ''}`.trim(),
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
throw toApiError(ctx, request, response, encoding);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function shouldRetry(method, status) {
|
|
113
|
+
if (status === undefined)
|
|
114
|
+
return SAFE_TO_REPEAT.has(method);
|
|
115
|
+
if (NOT_PROCESSED.has(status))
|
|
116
|
+
return true;
|
|
117
|
+
return TRANSIENT.has(status) && SAFE_TO_REPEAT.has(method);
|
|
118
|
+
}
|
|
119
|
+
function isCapacityRefusal(status, body) {
|
|
120
|
+
if (status !== 429 || !body || typeof body !== 'object')
|
|
121
|
+
return false;
|
|
122
|
+
const code = body.code;
|
|
123
|
+
return code === 'dispatch_queue_full' || code === 'dispatch_deferred';
|
|
124
|
+
}
|
|
125
|
+
function retryDelayMs(response, attempt) {
|
|
126
|
+
const header = response ? headerValue(response.headers['retry-after']) : undefined;
|
|
127
|
+
const seconds = header !== undefined ? Number(header) : NaN;
|
|
128
|
+
if (Number.isFinite(seconds) && seconds >= 0) {
|
|
129
|
+
return Math.min(seconds, MAX_RETRY_WAIT_SECONDS) * 1000;
|
|
130
|
+
}
|
|
131
|
+
return Math.min(1000 * 2 ** attempt, MAX_RETRY_WAIT_SECONDS * 1000);
|
|
132
|
+
}
|
|
133
|
+
function toApiError(ctx, request, response, encoding) {
|
|
134
|
+
const body = encoding === 'arraybuffer' ? decodeErrorBody(response.body) : response.body;
|
|
135
|
+
const retryAfter = Number(headerValue(response.headers['retry-after']));
|
|
136
|
+
const described = (0, errors_1.describeRingeeFailure)({
|
|
137
|
+
status: response.statusCode,
|
|
138
|
+
body,
|
|
139
|
+
retryAfterSeconds: Number.isFinite(retryAfter) ? retryAfter : undefined,
|
|
140
|
+
subject: request.subject,
|
|
141
|
+
});
|
|
142
|
+
return new n8n_workflow_1.NodeApiError(ctx.getNode(), { statusCode: response.statusCode, body }, {
|
|
143
|
+
message: described.message,
|
|
144
|
+
description: described.description,
|
|
145
|
+
httpCode: String(response.statusCode),
|
|
146
|
+
itemIndex: request.itemIndex,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
function decodeErrorBody(body) {
|
|
150
|
+
try {
|
|
151
|
+
const text = Buffer.isBuffer(body)
|
|
152
|
+
? body.toString('utf8')
|
|
153
|
+
: Buffer.from(body).toString('utf8');
|
|
154
|
+
return JSON.parse(text);
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function headerValue(value) {
|
|
161
|
+
return Array.isArray(value) ? value[0] : value;
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../lib/api/client.ts"],"names":[],"mappings":";;;AAwDA,sCAMC;AAGD,kDAYC;AAWD,sDAwBC;AAuFD,kCAIC;AAQD,8CAIC;AA/MD,+CAAuE;AACvE,sCAAkD;AAClD,gDAAiD;AAKpC,QAAA,eAAe,GAAG,WAAW,CAAC;AAE3C,MAAM,kBAAkB,GAAG,KAAM,CAAC;AAClC,MAAM,WAAW,GAAG,CAAC,CAAC;AACtB,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,MAAM,cAAc,GAAwB,IAAI,GAAG,CAAC,CAAC,KA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|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface DescribedFailure {
|
|
2
|
+
message: string;
|
|
3
|
+
description: string;
|
|
4
|
+
retryable: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function messageOf(body: unknown): string;
|
|
7
|
+
export declare function describeRingeeFailure(input: {
|
|
8
|
+
status: number;
|
|
9
|
+
body: unknown;
|
|
10
|
+
retryAfterSeconds?: number;
|
|
11
|
+
subject?: string;
|
|
12
|
+
}): DescribedFailure;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.messageOf = messageOf;
|
|
4
|
+
exports.describeRingeeFailure = describeRingeeFailure;
|
|
5
|
+
const MISSING_ROUTE = /^Cannot (GET|POST|PUT|PATCH|DELETE) \//;
|
|
6
|
+
function messageOf(body) {
|
|
7
|
+
if (typeof body === 'string')
|
|
8
|
+
return body.trim();
|
|
9
|
+
if (!body || typeof body !== 'object')
|
|
10
|
+
return '';
|
|
11
|
+
const { message } = body;
|
|
12
|
+
if (Array.isArray(message))
|
|
13
|
+
return message.join('; ');
|
|
14
|
+
return typeof message === 'string' ? message.trim() : '';
|
|
15
|
+
}
|
|
16
|
+
function fieldsOf(body) {
|
|
17
|
+
if (!body || typeof body !== 'object')
|
|
18
|
+
return '';
|
|
19
|
+
const { fields } = body;
|
|
20
|
+
if (!fields || typeof fields !== 'object')
|
|
21
|
+
return '';
|
|
22
|
+
return Object.entries(fields)
|
|
23
|
+
.map(([name, problem]) => `'${name}': ${Array.isArray(problem) ? problem.join(', ') : problem}`)
|
|
24
|
+
.join('; ');
|
|
25
|
+
}
|
|
26
|
+
function describeRingeeFailure(input) {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
const { status, body, retryAfterSeconds } = input;
|
|
29
|
+
const server = messageOf(body);
|
|
30
|
+
const fields = fieldsOf(body);
|
|
31
|
+
if (status === 404 && MISSING_ROUTE.test(server)) {
|
|
32
|
+
return {
|
|
33
|
+
message: 'This Ringee server does not offer that operation yet',
|
|
34
|
+
description: 'Your Ringee installation is older than this node expects. Update it, or point the credential at Ringee Cloud (https://api.ringee.io). The operations each version supports are listed in docs/compatibility.md.',
|
|
35
|
+
retryable: false,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
switch (status) {
|
|
39
|
+
case 401:
|
|
40
|
+
return {
|
|
41
|
+
message: 'Ringee did not accept the API key',
|
|
42
|
+
description: 'Check that the API key in your Ringee credential is the current one and that the Custom Integration it belongs to is enabled. A key that was regenerated in Ringee stops working immediately.',
|
|
43
|
+
retryable: false,
|
|
44
|
+
};
|
|
45
|
+
case 403: {
|
|
46
|
+
if (/insufficient credits/i.test(server)) {
|
|
47
|
+
return {
|
|
48
|
+
message: 'Your Ringee workspace has no credits left',
|
|
49
|
+
description: 'Add credits in Ringee (Billing), then run the workflow again. Nothing was dialed.',
|
|
50
|
+
retryable: false,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (/do-not-call|dnc/i.test(server)) {
|
|
54
|
+
return {
|
|
55
|
+
message: 'That number is on your Do-Not-Call list',
|
|
56
|
+
description: `${server}. Ringee did not place the call. Remove the number from the list in Ringee if the person has agreed to be called.`,
|
|
57
|
+
retryable: false,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (/outbound calling is disabled/i.test(server)) {
|
|
61
|
+
return {
|
|
62
|
+
message: 'Outbound calling is turned off for this Ringee account',
|
|
63
|
+
description: 'Ask the Ringee account owner to enable calling, or contact support@ringee.io.',
|
|
64
|
+
retryable: false,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if (/ai voice agents? (require|are)|voice agents? .*(not|enrolled|organization)/i.test(server)) {
|
|
68
|
+
return {
|
|
69
|
+
message: 'AI voice agents are not enabled for this Ringee workspace',
|
|
70
|
+
description: `${server}. Use an API key from a workspace that has AI voice agents.`,
|
|
71
|
+
retryable: false,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
message: server || 'Ringee refused the request',
|
|
76
|
+
description: 'The API key does not have permission for this action in its workspace.',
|
|
77
|
+
retryable: false,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
case 404:
|
|
81
|
+
return {
|
|
82
|
+
message: `${capitalize((_a = input.subject) !== null && _a !== void 0 ? _a : 'resource')} not found`,
|
|
83
|
+
description: `Ringee has no ${(_b = input.subject) !== null && _b !== void 0 ? _b : 'resource'} with that ID in the workspace this API key belongs to. Check the ID, and that the credential points at the right workspace.`,
|
|
84
|
+
retryable: false,
|
|
85
|
+
};
|
|
86
|
+
case 409:
|
|
87
|
+
if ((body === null || body === void 0 ? void 0 : body.code) === 'idempotency_key_failed') {
|
|
88
|
+
return {
|
|
89
|
+
message: server || 'The first attempt with this Idempotency Key failed',
|
|
90
|
+
description: 'Nothing was dialed and nothing was charged. Retry On Fail sends the same key and will get this answer again. Run the workflow again as a new execution, or give the call a new Idempotency Key, to try again.',
|
|
91
|
+
retryable: false,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
if ((body === null || body === void 0 ? void 0 : body.code) === 'idempotency_key_cancelled' ||
|
|
95
|
+
(body === null || body === void 0 ? void 0 : body.code) === 'idempotency_key_expired') {
|
|
96
|
+
return {
|
|
97
|
+
message: server || 'The call under this Idempotency Key was never dialed',
|
|
98
|
+
description: 'It was cancelled, or waited too long for call capacity, before it was placed. Nothing was dialed and nothing was charged. Give the call a new Idempotency Key to place it again.',
|
|
99
|
+
retryable: false,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
if ((body === null || body === void 0 ? void 0 : body.code) === 'call_not_cancellable') {
|
|
103
|
+
return {
|
|
104
|
+
message: server || 'This call can no longer be cancelled',
|
|
105
|
+
description: 'Only a call that is still waiting for call capacity can be cancelled. One that is already dialing has to be hung up in Ringee.',
|
|
106
|
+
retryable: false,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
message: server || 'Ringee reported a conflict',
|
|
111
|
+
description: 'The request conflicts with something that already exists, such as a call started earlier under the same Idempotency Key.',
|
|
112
|
+
retryable: false,
|
|
113
|
+
};
|
|
114
|
+
case 429: {
|
|
115
|
+
const code = body === null || body === void 0 ? void 0 : body.code;
|
|
116
|
+
if (code === 'dispatch_queue_full' || code === 'dispatch_deferred') {
|
|
117
|
+
const retryMs = body === null || body === void 0 ? void 0 : body.retryAfterMs;
|
|
118
|
+
const seconds = retryAfterSeconds !== null && retryAfterSeconds !== void 0 ? retryAfterSeconds : (retryMs ? Math.ceil(retryMs / 1000) : undefined);
|
|
119
|
+
return {
|
|
120
|
+
message: code === 'dispatch_queue_full'
|
|
121
|
+
? 'Ringee has as many calls waiting for call capacity as it may'
|
|
122
|
+
: 'Ringee has no call capacity free right now',
|
|
123
|
+
description: `Nothing was queued and nothing was dialed.${seconds ? ` Try again in about ${seconds} seconds.` : ''} Send the same request again with the same Idempotency Key, after a Wait node, in smaller batches (see docs/queue-and-capacity.md).`,
|
|
124
|
+
retryable: true,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
const wait = retryAfterSeconds ? ` Try again in ${retryAfterSeconds} seconds.` : '';
|
|
128
|
+
return {
|
|
129
|
+
message: 'Ringee is limiting how fast this integration can call the API',
|
|
130
|
+
description: `Too many requests were sent in a short time.${wait} Use fewer, larger batches or add a Wait node between loops.`,
|
|
131
|
+
retryable: true,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
case 400:
|
|
135
|
+
case 422: {
|
|
136
|
+
const friendly = /is not a dialable phone number/i.test(server)
|
|
137
|
+
? `${server} Use the international format, for example +14155550123.`
|
|
138
|
+
: server;
|
|
139
|
+
return {
|
|
140
|
+
message: friendly || 'Ringee could not use the values that were sent',
|
|
141
|
+
description: fields
|
|
142
|
+
? `Check these fields: ${fields}.`
|
|
143
|
+
: 'Check the values in the node and run it again.',
|
|
144
|
+
retryable: false,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
default:
|
|
148
|
+
if (status >= 500) {
|
|
149
|
+
return {
|
|
150
|
+
message: 'Ringee could not complete the request',
|
|
151
|
+
description: `Ringee answered with HTTP ${status}${server ? `: ${server}` : ''}. This is usually temporary; try again shortly. If it continues, check https://ringee.io or contact support@ringee.io.`,
|
|
152
|
+
retryable: true,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
if (status >= 300 && status < 400) {
|
|
156
|
+
return {
|
|
157
|
+
message: 'Ringee answered with a redirect',
|
|
158
|
+
description: 'The node never follows redirects, so the API key is not sent anywhere else. Check that the Base URL in the credential is the exact API address, for example https://api.ringee.io.',
|
|
159
|
+
retryable: false,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
message: server || `Ringee answered with HTTP ${status}`,
|
|
164
|
+
description: 'The request was not accepted.',
|
|
165
|
+
retryable: false,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function capitalize(text) {
|
|
170
|
+
return text.charAt(0).toUpperCase() + text.slice(1);
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/errors/index.ts"],"names":[],"mappings":";;AAYA,8BAMC;AAmBD,sDA4KC;AAvMD,MAAM,aAAa,GAAG,wCAAwC,CAAC;AAE/D,SAAgB,SAAS,CAAC,IAAa;IACtC,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;IACjD,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IACjD,MAAM,EAAE,OAAO,EAAE,GAAG,IAAuB,CAAC;IAC5C,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAA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oL;oBACrL,SAAS,EAAE,KAAK;iBAChB,CAAC;YACH,CAAC;YACD,OAAO;gBACN,OAAO,EAAE,MAAM,IAAI,6BAA6B,MAAM,EAAE;gBACxD,WAAW,EAAE,+BAA+B;gBAC5C,SAAS,EAAE,KAAK;aAChB,CAAC;IACJ,CAAC;AACF,CAAC;AAED,SAAS,UAAU,CAAC,IAAY;IAC/B,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
export declare const AGENT_CALL_STATUSES: readonly ["queued", "created", "initiating", "ringing", "in_progress", "completed", "no_answer", "busy", "voicemail", "failed", "cancelled", "expired"];
|
|
2
|
+
export type AgentCallStatus = (typeof AGENT_CALL_STATUSES)[number];
|
|
3
|
+
export declare const AGENT_CALL_FINAL_STATUSES: readonly AgentCallStatus[];
|
|
4
|
+
export declare const AGENT_CALL_NOT_DIALED_STATUSES: readonly AgentCallStatus[];
|
|
5
|
+
export declare const AGENT_OUTCOMES: readonly ["meeting_booked", "callback_scheduled", "not_interested", "no_answer", "no_conversation", "wrong_number", "confirmed", "cannot_attend", "callback_requested", "appointment_booked", "unknown"];
|
|
6
|
+
export type AgentOutcome = (typeof AGENT_OUTCOMES)[number];
|
|
7
|
+
export declare const CALL_STATUSES: readonly ["pending", "ringing", "answered", "recording", "completed", "failed"];
|
|
8
|
+
export type CallStatus = (typeof CALL_STATUSES)[number];
|
|
9
|
+
export declare const CALL_OUTCOMES: readonly ["meeting_booked", "sale", "interested", "follow_up", "callback_scheduled", "not_interested", "no_answer", "no_conversation", "voicemail", "wrong_number", "gatekeeper"];
|
|
10
|
+
export type CallOutcome = (typeof CALL_OUTCOMES)[number];
|
|
11
|
+
export type AgentType = 'appointment_booking' | 'reminders_notifications' | 'receptionist';
|
|
12
|
+
export interface RingeeVariableDefinition {
|
|
13
|
+
key: string;
|
|
14
|
+
label: string;
|
|
15
|
+
required: boolean;
|
|
16
|
+
description?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface RingeeAgent {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
type: AgentType;
|
|
22
|
+
status: string;
|
|
23
|
+
voice: string | null;
|
|
24
|
+
callCount: number;
|
|
25
|
+
callerNumberId: string | null;
|
|
26
|
+
callsFrom: string | null;
|
|
27
|
+
createdAt: string;
|
|
28
|
+
updatedAt: string;
|
|
29
|
+
variables?: RingeeVariableDefinition[];
|
|
30
|
+
}
|
|
31
|
+
export interface RingeeCallerNumber {
|
|
32
|
+
id: string;
|
|
33
|
+
phoneNumber: string;
|
|
34
|
+
isoCountry: string | null;
|
|
35
|
+
kind: string;
|
|
36
|
+
}
|
|
37
|
+
export interface RingeePage<T> {
|
|
38
|
+
data: T[];
|
|
39
|
+
total: number;
|
|
40
|
+
page: number;
|
|
41
|
+
limit: number;
|
|
42
|
+
totalPages?: number;
|
|
43
|
+
}
|
|
44
|
+
export interface RingeeAgentList extends RingeePage<RingeeAgent> {
|
|
45
|
+
callerNumbers: RingeeCallerNumber[];
|
|
46
|
+
variablesByType: Record<string, RingeeVariableDefinition[]>;
|
|
47
|
+
}
|
|
48
|
+
export interface RingeeStartCallResponse {
|
|
49
|
+
id: string;
|
|
50
|
+
status: AgentCallStatus;
|
|
51
|
+
idempotent_replayed?: boolean;
|
|
52
|
+
queued_at?: string;
|
|
53
|
+
expires_at?: string;
|
|
54
|
+
}
|
|
55
|
+
export interface RingeeAgentCallResult {
|
|
56
|
+
call_id: string;
|
|
57
|
+
status: AgentCallStatus;
|
|
58
|
+
queued_at?: string;
|
|
59
|
+
expires_at?: string;
|
|
60
|
+
outcome: AgentOutcome | null;
|
|
61
|
+
summary: string | null;
|
|
62
|
+
sentiment: string | null;
|
|
63
|
+
extracted_data: Record<string, unknown>;
|
|
64
|
+
metadata: Record<string, unknown>;
|
|
65
|
+
appointment?: {
|
|
66
|
+
id: string;
|
|
67
|
+
start: string;
|
|
68
|
+
end: string;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export interface RingeeContact {
|
|
72
|
+
id: string;
|
|
73
|
+
name: string | null;
|
|
74
|
+
firstName: string | null;
|
|
75
|
+
lastName: string | null;
|
|
76
|
+
phoneNumber: string;
|
|
77
|
+
email: string | null;
|
|
78
|
+
company: string | null;
|
|
79
|
+
jobTitle: string | null;
|
|
80
|
+
state: string | null;
|
|
81
|
+
website: string | null;
|
|
82
|
+
revenue: string | null;
|
|
83
|
+
companySize: string | null;
|
|
84
|
+
source: string | null;
|
|
85
|
+
lastCallAt: string | null;
|
|
86
|
+
createdAt: string;
|
|
87
|
+
updatedAt: string;
|
|
88
|
+
}
|
|
89
|
+
export interface RingeeCallSummary {
|
|
90
|
+
id: string;
|
|
91
|
+
direction: 'inbound' | 'outbound';
|
|
92
|
+
status: CallStatus;
|
|
93
|
+
source: string | null;
|
|
94
|
+
fromNumber: string;
|
|
95
|
+
toNumber: string;
|
|
96
|
+
contactId: string | null;
|
|
97
|
+
startedAt: string | null;
|
|
98
|
+
answeredAt: string | null;
|
|
99
|
+
endedAt: string | null;
|
|
100
|
+
createdAt: string;
|
|
101
|
+
durationSeconds: number | null;
|
|
102
|
+
outcome: CallOutcome | null;
|
|
103
|
+
outcomeNote: string | null;
|
|
104
|
+
dispositionName: string | null;
|
|
105
|
+
}
|
|
106
|
+
export interface RingeeTranscriptSegment {
|
|
107
|
+
text: string;
|
|
108
|
+
speaker?: number;
|
|
109
|
+
track?: string;
|
|
110
|
+
startMs?: number;
|
|
111
|
+
endMs?: number;
|
|
112
|
+
}
|
|
113
|
+
export interface RingeeCallDetail {
|
|
114
|
+
callId: string;
|
|
115
|
+
fromNumber: string;
|
|
116
|
+
toNumber: string;
|
|
117
|
+
status: string;
|
|
118
|
+
direction: string;
|
|
119
|
+
source?: string;
|
|
120
|
+
startedAt?: string;
|
|
121
|
+
answeredAt?: string;
|
|
122
|
+
endedAt?: string;
|
|
123
|
+
createdAt?: string;
|
|
124
|
+
durationSeconds?: number;
|
|
125
|
+
outcome?: string;
|
|
126
|
+
outcomeNote?: string;
|
|
127
|
+
disposition?: {
|
|
128
|
+
id: string;
|
|
129
|
+
name: string | null;
|
|
130
|
+
};
|
|
131
|
+
contact?: {
|
|
132
|
+
id: string;
|
|
133
|
+
phoneNumber?: string;
|
|
134
|
+
fullName?: string;
|
|
135
|
+
email?: string;
|
|
136
|
+
};
|
|
137
|
+
recording?: {
|
|
138
|
+
recordingId?: string;
|
|
139
|
+
url?: string;
|
|
140
|
+
status?: string;
|
|
141
|
+
format?: string;
|
|
142
|
+
durationSec?: number;
|
|
143
|
+
};
|
|
144
|
+
transcription?: {
|
|
145
|
+
source?: string;
|
|
146
|
+
status?: string;
|
|
147
|
+
language?: string;
|
|
148
|
+
confidence?: number;
|
|
149
|
+
completedAt?: string;
|
|
150
|
+
text?: string;
|
|
151
|
+
segments?: RingeeTranscriptSegment[];
|
|
152
|
+
};
|
|
153
|
+
voiceAgentCall?: {
|
|
154
|
+
id: string;
|
|
155
|
+
agent?: {
|
|
156
|
+
id: string;
|
|
157
|
+
name: string;
|
|
158
|
+
};
|
|
159
|
+
status?: string;
|
|
160
|
+
outcome?: string;
|
|
161
|
+
summary?: string;
|
|
162
|
+
sentiment?: string;
|
|
163
|
+
extractedData?: Record<string, unknown>;
|
|
164
|
+
variables?: Record<string, unknown>;
|
|
165
|
+
metadata?: Record<string, unknown>;
|
|
166
|
+
};
|
|
167
|
+
meetings?: Array<Record<string, unknown>>;
|
|
168
|
+
callbacks?: Array<Record<string, unknown>>;
|
|
169
|
+
campaignAttempts?: Array<Record<string, unknown>>;
|
|
170
|
+
}
|
|
171
|
+
export declare const RINGEE_EVENTS: readonly [{
|
|
172
|
+
readonly value: "call.completed";
|
|
173
|
+
readonly name: "Call Completed";
|
|
174
|
+
readonly description: "A call has ended, human or AI. The outcome and AI analysis may arrive later";
|
|
175
|
+
}, {
|
|
176
|
+
readonly value: "call.outcome.updated";
|
|
177
|
+
readonly name: "Call Outcome Updated";
|
|
178
|
+
readonly description: "An outcome was recorded, including an AI voice agent’s post-call result with summary, sentiment and extracted data";
|
|
179
|
+
}, {
|
|
180
|
+
readonly value: "call.failed";
|
|
181
|
+
readonly name: "Call Failed";
|
|
182
|
+
readonly description: "A call could not be connected";
|
|
183
|
+
}, {
|
|
184
|
+
readonly value: "call.missed";
|
|
185
|
+
readonly name: "Call Missed";
|
|
186
|
+
readonly description: "An inbound call was not answered";
|
|
187
|
+
}, {
|
|
188
|
+
readonly value: "recording.ready";
|
|
189
|
+
readonly name: "Recording Ready";
|
|
190
|
+
readonly description: "The recording of a call has been processed";
|
|
191
|
+
}, {
|
|
192
|
+
readonly value: "meeting.created";
|
|
193
|
+
readonly name: "Meeting Created";
|
|
194
|
+
readonly description: "A meeting was booked, by a person or by an AI voice agent";
|
|
195
|
+
}, {
|
|
196
|
+
readonly value: "callback.created";
|
|
197
|
+
readonly name: "Callback Created";
|
|
198
|
+
readonly description: "A callback was scheduled, by a person or by an AI voice agent";
|
|
199
|
+
}, {
|
|
200
|
+
readonly value: "note.created";
|
|
201
|
+
readonly name: "Note Created";
|
|
202
|
+
readonly description: "A note was added to a contact";
|
|
203
|
+
}, {
|
|
204
|
+
readonly value: "dnc.created";
|
|
205
|
+
readonly name: "Do-Not-Call Entry Created";
|
|
206
|
+
readonly description: "A number was added to the Do-Not-Call list";
|
|
207
|
+
}];
|
|
208
|
+
export type RingeeEventName = (typeof RINGEE_EVENTS)[number]['value'];
|
|
209
|
+
export declare const RINGEE_TEST_EVENT = "test.ping";
|
|
210
|
+
export interface RingeeWebhookEnvelope {
|
|
211
|
+
event: string;
|
|
212
|
+
eventId: string;
|
|
213
|
+
occurredAt: string;
|
|
214
|
+
workspaceId?: string;
|
|
215
|
+
integrationId?: string;
|
|
216
|
+
data: Record<string, unknown> & {
|
|
217
|
+
callId?: string;
|
|
218
|
+
agentCallId?: string;
|
|
219
|
+
externalId?: string;
|
|
220
|
+
agent?: {
|
|
221
|
+
id: string;
|
|
222
|
+
name: string;
|
|
223
|
+
};
|
|
224
|
+
call?: RingeeCallDetail;
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
export interface RingeeErrorBody {
|
|
228
|
+
statusCode?: number;
|
|
229
|
+
message?: string | string[];
|
|
230
|
+
error?: string;
|
|
231
|
+
code?: string;
|
|
232
|
+
fields?: Record<string, string | string[]>;
|
|
233
|
+
}
|