@lorikeetai/node-sdk 0.3.0 → 0.4.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/CHANGELOG.md +47 -0
- package/README.md +29 -16
- package/index.d.mts +8 -5
- package/index.d.ts +8 -5
- package/index.d.ts.map +1 -1
- package/index.js +13 -7
- package/index.js.map +1 -1
- package/index.mjs +7 -4
- package/index.mjs.map +1 -1
- package/lib/poll-until.d.ts +20 -0
- package/lib/poll-until.d.ts.map +1 -0
- package/lib/poll-until.js +20 -0
- package/lib/poll-until.js.map +1 -0
- package/lib/poll-until.mjs +16 -0
- package/lib/poll-until.mjs.map +1 -0
- package/package.json +2 -1
- package/resources/conversation/chat.d.ts +73 -17
- package/resources/conversation/chat.d.ts.map +1 -1
- package/resources/conversation/chat.js +51 -0
- package/resources/conversation/chat.js.map +1 -1
- package/resources/conversation/chat.mjs +51 -0
- package/resources/conversation/chat.mjs.map +1 -1
- package/resources/conversation/conversation.d.ts +2 -2
- package/resources/conversation/conversation.d.ts.map +1 -1
- package/resources/conversation/conversation.js.map +1 -1
- package/resources/conversation/conversation.mjs +1 -1
- package/resources/conversation/conversation.mjs.map +1 -1
- package/resources/conversation/email.d.ts +117 -3
- package/resources/conversation/email.d.ts.map +1 -1
- package/resources/conversation/email.js +6 -0
- package/resources/conversation/email.js.map +1 -1
- package/resources/conversation/email.mjs +6 -0
- package/resources/conversation/email.mjs.map +1 -1
- package/resources/conversation/index.d.ts +1 -1
- package/resources/conversation/index.d.ts.map +1 -1
- package/resources/conversation/index.js.map +1 -1
- package/resources/conversation/index.mjs +1 -1
- package/resources/conversation/index.mjs.map +1 -1
- package/resources/customer.d.ts +34 -3
- package/resources/customer.d.ts.map +1 -1
- package/resources/customer.js +3 -0
- package/resources/customer.js.map +1 -1
- package/resources/customer.mjs +3 -0
- package/resources/customer.mjs.map +1 -1
- package/resources/index.d.ts +2 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +3 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -0
- package/resources/index.mjs.map +1 -1
- package/resources/workflow.d.ts +7 -0
- package/resources/workflow.d.ts.map +1 -0
- package/resources/workflow.js +18 -0
- package/resources/workflow.js.map +1 -0
- package/resources/workflow.mjs +14 -0
- package/resources/workflow.mjs.map +1 -0
- package/src/index.ts +27 -21
- package/src/lib/poll-until.ts +38 -0
- package/src/resources/conversation/chat.ts +94 -17
- package/src/resources/conversation/conversation.ts +13 -1
- package/src/resources/conversation/email.ts +154 -3
- package/src/resources/conversation/index.ts +9 -1
- package/src/resources/customer.ts +44 -2
- package/src/resources/index.ts +2 -0
- package/src/resources/workflow.ts +17 -0
- package/src/version.ts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Workflow = void 0;
|
|
5
|
+
const resource_1 = require("../resource.js");
|
|
6
|
+
class Workflow extends resource_1.APIResource {
|
|
7
|
+
update(options) {
|
|
8
|
+
return this._client.post('/v1/workflow', { ...options, headers: { Accept: '*/*', ...options?.headers } });
|
|
9
|
+
}
|
|
10
|
+
get(id, options) {
|
|
11
|
+
return this._client.get(`/v1/workflow/${id}`, {
|
|
12
|
+
...options,
|
|
13
|
+
headers: { Accept: '*/*', ...options?.headers },
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.Workflow = Workflow;
|
|
18
|
+
//# sourceMappingURL=workflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.js","sourceRoot":"","sources":["../src/resources/workflow.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,6CAA0C;AAG1C,MAAa,QAAS,SAAQ,sBAAW;IACvC,MAAM,CAAC,OAA6B;QAClC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;IAC5G,CAAC;IAED,GAAG,CAAC,EAAU,EAAE,OAA6B;QAC3C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,EAAE,EAAE;YAC5C,GAAG,OAAO;YACV,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE;SAChD,CAAC,CAAC;IACL,CAAC;CACF;AAXD,4BAWC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
import { APIResource } from "../resource.mjs";
|
|
3
|
+
export class Workflow extends APIResource {
|
|
4
|
+
update(options) {
|
|
5
|
+
return this._client.post('/v1/workflow', { ...options, headers: { Accept: '*/*', ...options?.headers } });
|
|
6
|
+
}
|
|
7
|
+
get(id, options) {
|
|
8
|
+
return this._client.get(`/v1/workflow/${id}`, {
|
|
9
|
+
...options,
|
|
10
|
+
headers: { Accept: '*/*', ...options?.headers },
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=workflow.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.mjs","sourceRoot":"","sources":["../src/resources/workflow.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;AAGtB,MAAM,OAAO,QAAS,SAAQ,WAAW;IACvC,MAAM,CAAC,OAA6B;QAClC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;IAC5G,CAAC;IAED,GAAG,CAAC,EAAU,EAAE,OAA6B;QAC3C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,EAAE,EAAE;YAC5C,GAAG,OAAO;YACV,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE;SAChD,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/src/index.ts
CHANGED
|
@@ -9,11 +9,14 @@ import {
|
|
|
9
9
|
Customer,
|
|
10
10
|
CustomerCreateParams,
|
|
11
11
|
CustomerCreateResponse,
|
|
12
|
+
CustomerGetResponse,
|
|
12
13
|
CustomerTokenParams,
|
|
13
14
|
CustomerTokenResponse,
|
|
14
15
|
} from './resources/customer';
|
|
15
16
|
import { Ingest, IngestTestParams } from './resources/ingest';
|
|
17
|
+
import { Workflow } from './resources/workflow';
|
|
16
18
|
import { Conversation } from './resources/conversation/conversation';
|
|
19
|
+
import { generateSignature } from './lib/generate-signature';
|
|
17
20
|
|
|
18
21
|
export interface ClientOptions {
|
|
19
22
|
/**
|
|
@@ -145,6 +148,7 @@ export class Lorikeet extends Core.APIClient {
|
|
|
145
148
|
|
|
146
149
|
conversation: API.Conversation = new API.Conversation(this);
|
|
147
150
|
customer: API.Customer = new API.Customer(this);
|
|
151
|
+
workflow: API.Workflow = new API.Workflow(this);
|
|
148
152
|
ingest: API.Ingest = new API.Ingest(this);
|
|
149
153
|
|
|
150
154
|
protected override defaultQuery(): Core.DefaultQuery | undefined {
|
|
@@ -197,30 +201,10 @@ export class Lorikeet extends Core.APIClient {
|
|
|
197
201
|
static fileFromPath = Uploads.fileFromPath;
|
|
198
202
|
}
|
|
199
203
|
|
|
200
|
-
export {
|
|
201
|
-
LorikeetError,
|
|
202
|
-
APIError,
|
|
203
|
-
APIConnectionError,
|
|
204
|
-
APIConnectionTimeoutError,
|
|
205
|
-
APIUserAbortError,
|
|
206
|
-
NotFoundError,
|
|
207
|
-
ConflictError,
|
|
208
|
-
RateLimitError,
|
|
209
|
-
BadRequestError,
|
|
210
|
-
AuthenticationError,
|
|
211
|
-
InternalServerError,
|
|
212
|
-
PermissionDeniedError,
|
|
213
|
-
UnprocessableEntityError,
|
|
214
|
-
} from './error';
|
|
215
|
-
|
|
216
|
-
export import toFile = Uploads.toFile;
|
|
217
|
-
export import fileFromPath = Uploads.fileFromPath;
|
|
218
|
-
import { generateSignature } from './lib/generate-signature';
|
|
219
|
-
|
|
220
204
|
Lorikeet.Conversation = Conversation;
|
|
221
205
|
Lorikeet.Customer = Customer;
|
|
206
|
+
Lorikeet.Workflow = Workflow;
|
|
222
207
|
Lorikeet.Ingest = Ingest;
|
|
223
|
-
|
|
224
208
|
export declare namespace Lorikeet {
|
|
225
209
|
export type RequestOptions = Core.RequestOptions;
|
|
226
210
|
|
|
@@ -229,12 +213,34 @@ export declare namespace Lorikeet {
|
|
|
229
213
|
export {
|
|
230
214
|
Customer as Customer,
|
|
231
215
|
type CustomerCreateResponse as CustomerCreateResponse,
|
|
216
|
+
type CustomerGetResponse as CustomerGetResponse,
|
|
232
217
|
type CustomerTokenResponse as CustomerTokenResponse,
|
|
233
218
|
type CustomerCreateParams as CustomerCreateParams,
|
|
234
219
|
type CustomerTokenParams as CustomerTokenParams,
|
|
235
220
|
};
|
|
236
221
|
|
|
222
|
+
export { Workflow as Workflow };
|
|
223
|
+
|
|
237
224
|
export { Ingest as Ingest, type IngestTestParams as IngestTestParams };
|
|
238
225
|
}
|
|
239
226
|
|
|
227
|
+
export { toFile, fileFromPath } from './uploads';
|
|
228
|
+
export {
|
|
229
|
+
LorikeetError,
|
|
230
|
+
APIError,
|
|
231
|
+
APIConnectionError,
|
|
232
|
+
APIConnectionTimeoutError,
|
|
233
|
+
APIUserAbortError,
|
|
234
|
+
NotFoundError,
|
|
235
|
+
ConflictError,
|
|
236
|
+
RateLimitError,
|
|
237
|
+
BadRequestError,
|
|
238
|
+
AuthenticationError,
|
|
239
|
+
InternalServerError,
|
|
240
|
+
PermissionDeniedError,
|
|
241
|
+
UnprocessableEntityError,
|
|
242
|
+
} from './error';
|
|
243
|
+
|
|
244
|
+
export { generateSignature } from "./lib/generate-signature";
|
|
245
|
+
|
|
240
246
|
export default Lorikeet;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
interface PollUntilOptions<TData> {
|
|
2
|
+
/**
|
|
3
|
+
* The maximum time to wait for the condition to be met (ms).
|
|
4
|
+
*/
|
|
5
|
+
timeout?: number;
|
|
6
|
+
/**
|
|
7
|
+
* The interval between each poll (ms).
|
|
8
|
+
*/
|
|
9
|
+
interval?: number;
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param result The result of the polling function.
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
condition: (result: TData) => boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Utility function to poll an endpoint. */
|
|
19
|
+
export const pollUntil = async <T>(
|
|
20
|
+
fn: () => Promise<T>,
|
|
21
|
+
{ condition = (result) => !!result, interval = 3000, timeout = 30000 }: PollUntilOptions<T>,
|
|
22
|
+
): Promise<T> => {
|
|
23
|
+
const startTime = Date.now();
|
|
24
|
+
|
|
25
|
+
if (interval < 1000) {
|
|
26
|
+
throw new Error(`Polling interval must be at least 1000ms`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
while (Date.now() - startTime < timeout) {
|
|
30
|
+
const result = await fn();
|
|
31
|
+
if (condition(result)) {
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
throw new Error(`Polling timed out`);
|
|
38
|
+
};
|
|
@@ -2,36 +2,99 @@
|
|
|
2
2
|
|
|
3
3
|
import { APIResource } from '../../resource';
|
|
4
4
|
import * as Core from '../../core';
|
|
5
|
+
import { pollUntil } from "../../lib/poll-until";
|
|
5
6
|
|
|
6
7
|
export class Chat extends APIResource {
|
|
8
|
+
/**
|
|
9
|
+
* __chat.generate__
|
|
10
|
+
*
|
|
11
|
+
* Generate a chat message for a conversation. This endpoint will return immediately, polling will be required to get the response.
|
|
12
|
+
*
|
|
13
|
+
* The `latestMessageType` field in the response can be used to determine if the response is ready.
|
|
14
|
+
*
|
|
15
|
+
* If the `latestMessageType` is `BOT_RESPONSE`, the response is ready.
|
|
16
|
+
* For a more ergonomic way to poll, use the `message` method.
|
|
17
|
+
*
|
|
18
|
+
* ** WARNING ** This endpoint is not idempotent. If you call it multiple times, you will generate multiple messages.
|
|
19
|
+
*
|
|
20
|
+
* @see {@link Chat.message}
|
|
21
|
+
*/
|
|
7
22
|
generate(body: ChatGenerateParams, options?: Core.RequestOptions): Core.APIPromise<ChatGenerateResponse> {
|
|
8
23
|
return this._client.post('/v1/conversation/chat/message', { body, ...options });
|
|
9
24
|
}
|
|
10
25
|
|
|
26
|
+
/**
|
|
27
|
+
* __chat.get__
|
|
28
|
+
*
|
|
29
|
+
* Returns a chat message for a conversation. This endpoint will return the latest state of the conversation.
|
|
30
|
+
*/
|
|
11
31
|
get(query: ChatGetParams, options?: Core.RequestOptions): Core.APIPromise<ChatGetResponse> {
|
|
12
32
|
return this._client.get('/v1/conversation/chat/message', { query, ...options });
|
|
13
33
|
}
|
|
14
34
|
|
|
35
|
+
/**
|
|
36
|
+
* __chat.start__
|
|
37
|
+
*
|
|
38
|
+
* Start a chat conversation. This endpoint will return immediately.
|
|
39
|
+
*
|
|
40
|
+
* The `conversationId` field in the response can be used to generate messages.
|
|
41
|
+
*
|
|
42
|
+
* ** WARNING ** This endpoint is not idempotent. If you call it multiple times, you will generate multiple conversations.
|
|
43
|
+
*/
|
|
15
44
|
start(body: ChatStartParams, options?: Core.RequestOptions): Core.APIPromise<ChatStartResponse> {
|
|
16
45
|
return this._client.post('/v1/conversation/chat/create', { body, ...options });
|
|
17
46
|
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Returns a chat message for a conversation. This endpoint will poll until a response is ready.
|
|
50
|
+
*
|
|
51
|
+
* When it return the response is the latest message type that is of type `BOT_RESPONSE`.
|
|
52
|
+
*
|
|
53
|
+
* @see {@link Chat.poll}
|
|
54
|
+
*/
|
|
55
|
+
message(body: ChatGenerateParams, options?: Core.RequestOptions): Core.APIPromise<ChatGetResponse> {
|
|
56
|
+
return this.generate(body, options).then((response) =>
|
|
57
|
+
this.poll({ conversationId: response.conversationId }, options),
|
|
58
|
+
) as Core.APIPromise<ChatGetResponse>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* __chat.get__
|
|
63
|
+
*
|
|
64
|
+
* Polls until it returns a BOT chat message for a conversation.
|
|
65
|
+
*/
|
|
66
|
+
poll(query: ChatGetParams, options?: Core.RequestOptions): Core.APIPromise<ChatGetResponse> {
|
|
67
|
+
return pollUntil<ChatGetResponse>(
|
|
68
|
+
() => this._client.get('/v1/conversation/chat/message', { query, ...options }),
|
|
69
|
+
{
|
|
70
|
+
timeout: 180_000,
|
|
71
|
+
interval: 5_000,
|
|
72
|
+
condition: (conversation) => conversation.latestMessageType === 'BOT_RESPONSE',
|
|
73
|
+
},
|
|
74
|
+
) as Core.APIPromise<ChatGetResponse>;
|
|
75
|
+
}
|
|
18
76
|
}
|
|
19
77
|
|
|
20
78
|
export interface ChatGenerateResponse {
|
|
21
79
|
/**
|
|
22
80
|
* The ID of the conversation
|
|
23
81
|
*/
|
|
24
|
-
conversationId:
|
|
82
|
+
conversationId: string;
|
|
25
83
|
|
|
26
84
|
/**
|
|
27
|
-
* The timestamp of when the
|
|
85
|
+
* The timestamp of the when the conversation was created in our system.
|
|
28
86
|
*/
|
|
29
87
|
createdAt: string;
|
|
30
88
|
|
|
31
89
|
/**
|
|
32
|
-
* The
|
|
90
|
+
* The latest message type - useful for polling
|
|
33
91
|
*/
|
|
34
|
-
|
|
92
|
+
latestMessageType: 'CUSTOMER' | 'PENDING_RESPONSE' | 'DRAFT_RESPONSE' | 'BOT_RESPONSE';
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The full list of messages. This endpoint supports markdown.
|
|
96
|
+
*/
|
|
97
|
+
messages: Array<ChatGenerateResponse.Message>;
|
|
35
98
|
|
|
36
99
|
/**
|
|
37
100
|
* The timestamp of when the ticket was last updated in our system.
|
|
@@ -40,9 +103,6 @@ export interface ChatGenerateResponse {
|
|
|
40
103
|
}
|
|
41
104
|
|
|
42
105
|
export namespace ChatGenerateResponse {
|
|
43
|
-
/**
|
|
44
|
-
* The created message. This endpoint supports markdown.
|
|
45
|
-
*/
|
|
46
106
|
export interface Message {
|
|
47
107
|
/**
|
|
48
108
|
* The ID of the conversation message
|
|
@@ -54,6 +114,11 @@ export namespace ChatGenerateResponse {
|
|
|
54
114
|
*/
|
|
55
115
|
content: string;
|
|
56
116
|
|
|
117
|
+
/**
|
|
118
|
+
* The timestamp of the message.
|
|
119
|
+
*/
|
|
120
|
+
createdAt: string;
|
|
121
|
+
|
|
57
122
|
/**
|
|
58
123
|
* The raw content of the message. Usually HTML.
|
|
59
124
|
*/
|
|
@@ -70,17 +135,22 @@ export interface ChatGetResponse {
|
|
|
70
135
|
/**
|
|
71
136
|
* The ID of the conversation
|
|
72
137
|
*/
|
|
73
|
-
conversationId:
|
|
138
|
+
conversationId: string;
|
|
74
139
|
|
|
75
140
|
/**
|
|
76
|
-
* The timestamp of when the
|
|
141
|
+
* The timestamp of the when the conversation was created in our system.
|
|
77
142
|
*/
|
|
78
143
|
createdAt: string;
|
|
79
144
|
|
|
80
145
|
/**
|
|
81
|
-
* The
|
|
146
|
+
* The latest message type - useful for polling
|
|
82
147
|
*/
|
|
83
|
-
|
|
148
|
+
latestMessageType: 'CUSTOMER' | 'PENDING_RESPONSE' | 'DRAFT_RESPONSE' | 'BOT_RESPONSE';
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* The full list of messages. This endpoint supports markdown.
|
|
152
|
+
*/
|
|
153
|
+
messages: Array<ChatGetResponse.Message>;
|
|
84
154
|
|
|
85
155
|
/**
|
|
86
156
|
* The timestamp of when the ticket was last updated in our system.
|
|
@@ -89,9 +159,6 @@ export interface ChatGetResponse {
|
|
|
89
159
|
}
|
|
90
160
|
|
|
91
161
|
export namespace ChatGetResponse {
|
|
92
|
-
/**
|
|
93
|
-
* The created message. This endpoint supports markdown.
|
|
94
|
-
*/
|
|
95
162
|
export interface Message {
|
|
96
163
|
/**
|
|
97
164
|
* The ID of the conversation message
|
|
@@ -103,6 +170,11 @@ export namespace ChatGetResponse {
|
|
|
103
170
|
*/
|
|
104
171
|
content: string;
|
|
105
172
|
|
|
173
|
+
/**
|
|
174
|
+
* The timestamp of the message.
|
|
175
|
+
*/
|
|
176
|
+
createdAt: string;
|
|
177
|
+
|
|
106
178
|
/**
|
|
107
179
|
* The raw content of the message. Usually HTML.
|
|
108
180
|
*/
|
|
@@ -119,7 +191,7 @@ export interface ChatStartResponse {
|
|
|
119
191
|
/**
|
|
120
192
|
* The ID of the conversation
|
|
121
193
|
*/
|
|
122
|
-
conversationId:
|
|
194
|
+
conversationId: string;
|
|
123
195
|
|
|
124
196
|
/**
|
|
125
197
|
* The timestamp of the when the conversation was created in our system.
|
|
@@ -131,7 +203,7 @@ export interface ChatGenerateParams {
|
|
|
131
203
|
/**
|
|
132
204
|
* The ID of the conversation
|
|
133
205
|
*/
|
|
134
|
-
conversationId:
|
|
206
|
+
conversationId: string;
|
|
135
207
|
|
|
136
208
|
/**
|
|
137
209
|
* The message to be sent to the user. This endpoint supports markdown.
|
|
@@ -150,7 +222,12 @@ export interface ChatStartParams {
|
|
|
150
222
|
/**
|
|
151
223
|
* The ID of the customer. If omitted, a new customer will be created.
|
|
152
224
|
*/
|
|
153
|
-
customerId:
|
|
225
|
+
customerId: string;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* The public key associated with this agent
|
|
229
|
+
*/
|
|
230
|
+
publicKey: string;
|
|
154
231
|
|
|
155
232
|
/**
|
|
156
233
|
* The timestamp of the when the conversation was created in our system.
|
|
@@ -12,7 +12,15 @@ import {
|
|
|
12
12
|
ChatStartResponse,
|
|
13
13
|
} from './chat';
|
|
14
14
|
import * as EmailAPI from './email';
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
Email,
|
|
17
|
+
EmailGenerateParams,
|
|
18
|
+
EmailGenerateResponse,
|
|
19
|
+
EmailGetParams,
|
|
20
|
+
EmailGetResponse,
|
|
21
|
+
EmailStartParams,
|
|
22
|
+
EmailStartResponse,
|
|
23
|
+
} from './email';
|
|
16
24
|
|
|
17
25
|
export class Conversation extends APIResource {
|
|
18
26
|
email: EmailAPI.Email = new EmailAPI.Email(this._client);
|
|
@@ -25,7 +33,11 @@ Conversation.Chat = Chat;
|
|
|
25
33
|
export declare namespace Conversation {
|
|
26
34
|
export {
|
|
27
35
|
Email as Email,
|
|
36
|
+
type EmailGenerateResponse as EmailGenerateResponse,
|
|
37
|
+
type EmailGetResponse as EmailGetResponse,
|
|
28
38
|
type EmailStartResponse as EmailStartResponse,
|
|
39
|
+
type EmailGenerateParams as EmailGenerateParams,
|
|
40
|
+
type EmailGetParams as EmailGetParams,
|
|
29
41
|
type EmailStartParams as EmailStartParams,
|
|
30
42
|
};
|
|
31
43
|
|
|
@@ -4,16 +4,136 @@ import { APIResource } from '../../resource';
|
|
|
4
4
|
import * as Core from '../../core';
|
|
5
5
|
|
|
6
6
|
export class Email extends APIResource {
|
|
7
|
+
generate(body: EmailGenerateParams, options?: Core.RequestOptions): Core.APIPromise<EmailGenerateResponse> {
|
|
8
|
+
return this._client.post('/v1/conversation/email/message', { body, ...options });
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
get(query: EmailGetParams, options?: Core.RequestOptions): Core.APIPromise<EmailGetResponse> {
|
|
12
|
+
return this._client.get('/v1/conversation/email/message', { query, ...options });
|
|
13
|
+
}
|
|
14
|
+
|
|
7
15
|
start(body: EmailStartParams, options?: Core.RequestOptions): Core.APIPromise<EmailStartResponse> {
|
|
8
16
|
return this._client.post('/v1/conversation/email/create', { body, ...options });
|
|
9
17
|
}
|
|
10
18
|
}
|
|
11
19
|
|
|
20
|
+
export interface EmailGenerateResponse {
|
|
21
|
+
/**
|
|
22
|
+
* The ID of the conversation
|
|
23
|
+
*/
|
|
24
|
+
conversationId: string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The timestamp of the when the conversation was created in our system.
|
|
28
|
+
*/
|
|
29
|
+
createdAt: string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The latest message type - useful for polling
|
|
33
|
+
*/
|
|
34
|
+
latestMessageType: 'CUSTOMER' | 'PENDING_RESPONSE' | 'DRAFT_RESPONSE' | 'BOT_RESPONSE';
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The full list of messages. This endpoint supports markdown.
|
|
38
|
+
*/
|
|
39
|
+
messages: Array<EmailGenerateResponse.Message>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The timestamp of when the ticket was last updated in our system.
|
|
43
|
+
*/
|
|
44
|
+
updatedAt: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export namespace EmailGenerateResponse {
|
|
48
|
+
export interface Message {
|
|
49
|
+
/**
|
|
50
|
+
* The ID of the conversation message
|
|
51
|
+
*/
|
|
52
|
+
id: string;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The content of the message. Markdown on plain text.
|
|
56
|
+
*/
|
|
57
|
+
content: string;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The timestamp of the message.
|
|
61
|
+
*/
|
|
62
|
+
createdAt: string;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The raw content of the message. Usually HTML.
|
|
66
|
+
*/
|
|
67
|
+
rawContent: string;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The type of the message
|
|
71
|
+
*/
|
|
72
|
+
type: 'CUSTOMER' | 'PENDING_RESPONSE' | 'DRAFT_RESPONSE' | 'BOT_RESPONSE';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface EmailGetResponse {
|
|
77
|
+
/**
|
|
78
|
+
* The ID of the conversation
|
|
79
|
+
*/
|
|
80
|
+
conversationId: string;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The timestamp of the when the conversation was created in our system.
|
|
84
|
+
*/
|
|
85
|
+
createdAt: string;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The latest message type - useful for polling
|
|
89
|
+
*/
|
|
90
|
+
latestMessageType: 'CUSTOMER' | 'PENDING_RESPONSE' | 'DRAFT_RESPONSE' | 'BOT_RESPONSE';
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The full list of messages. This endpoint supports markdown.
|
|
94
|
+
*/
|
|
95
|
+
messages: Array<EmailGetResponse.Message>;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The timestamp of when the ticket was last updated in our system.
|
|
99
|
+
*/
|
|
100
|
+
updatedAt: string;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export namespace EmailGetResponse {
|
|
104
|
+
export interface Message {
|
|
105
|
+
/**
|
|
106
|
+
* The ID of the conversation message
|
|
107
|
+
*/
|
|
108
|
+
id: string;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The content of the message. Markdown on plain text.
|
|
112
|
+
*/
|
|
113
|
+
content: string;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* The timestamp of the message.
|
|
117
|
+
*/
|
|
118
|
+
createdAt: string;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* The raw content of the message. Usually HTML.
|
|
122
|
+
*/
|
|
123
|
+
rawContent: string;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* The type of the message
|
|
127
|
+
*/
|
|
128
|
+
type: 'CUSTOMER' | 'PENDING_RESPONSE' | 'DRAFT_RESPONSE' | 'BOT_RESPONSE';
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
12
132
|
export interface EmailStartResponse {
|
|
13
133
|
/**
|
|
14
134
|
* The ID of the conversation
|
|
15
135
|
*/
|
|
16
|
-
conversationId:
|
|
136
|
+
conversationId: string;
|
|
17
137
|
|
|
18
138
|
/**
|
|
19
139
|
* The timestamp of the when the conversation was created in our system.
|
|
@@ -21,11 +141,35 @@ export interface EmailStartResponse {
|
|
|
21
141
|
createdAt: string;
|
|
22
142
|
}
|
|
23
143
|
|
|
144
|
+
export interface EmailGenerateParams {
|
|
145
|
+
/**
|
|
146
|
+
* The ID of the conversation
|
|
147
|
+
*/
|
|
148
|
+
conversationId: string;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* The message to be sent to the user. This endpoint supports markdown.
|
|
152
|
+
*/
|
|
153
|
+
message: string;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export interface EmailGetParams {
|
|
157
|
+
/**
|
|
158
|
+
* The ID of the conversation you need to poll.
|
|
159
|
+
*/
|
|
160
|
+
conversationId: string;
|
|
161
|
+
}
|
|
162
|
+
|
|
24
163
|
export interface EmailStartParams {
|
|
25
164
|
/**
|
|
26
165
|
* The ID of the customer. If omitted, a new customer will be created.
|
|
27
166
|
*/
|
|
28
|
-
customerId:
|
|
167
|
+
customerId: string;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* The public key associated with this agent
|
|
171
|
+
*/
|
|
172
|
+
publicKey: string;
|
|
29
173
|
|
|
30
174
|
/**
|
|
31
175
|
* The timestamp of the when the conversation was created in our system.
|
|
@@ -34,5 +178,12 @@ export interface EmailStartParams {
|
|
|
34
178
|
}
|
|
35
179
|
|
|
36
180
|
export declare namespace Email {
|
|
37
|
-
export {
|
|
181
|
+
export {
|
|
182
|
+
type EmailGenerateResponse as EmailGenerateResponse,
|
|
183
|
+
type EmailGetResponse as EmailGetResponse,
|
|
184
|
+
type EmailStartResponse as EmailStartResponse,
|
|
185
|
+
type EmailGenerateParams as EmailGenerateParams,
|
|
186
|
+
type EmailGetParams as EmailGetParams,
|
|
187
|
+
type EmailStartParams as EmailStartParams,
|
|
188
|
+
};
|
|
38
189
|
}
|
|
@@ -10,4 +10,12 @@ export {
|
|
|
10
10
|
type ChatStartParams,
|
|
11
11
|
} from './chat';
|
|
12
12
|
export { Conversation } from './conversation';
|
|
13
|
-
export {
|
|
13
|
+
export {
|
|
14
|
+
Email,
|
|
15
|
+
type EmailGenerateResponse,
|
|
16
|
+
type EmailGetResponse,
|
|
17
|
+
type EmailStartResponse,
|
|
18
|
+
type EmailGenerateParams,
|
|
19
|
+
type EmailGetParams,
|
|
20
|
+
type EmailStartParams,
|
|
21
|
+
} from './email';
|
|
@@ -8,6 +8,10 @@ export class Customer extends APIResource {
|
|
|
8
8
|
return this._client.post('/v1/customer', { body, ...options });
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
get(id: string, options?: Core.RequestOptions): Core.APIPromise<CustomerGetResponse> {
|
|
12
|
+
return this._client.get(`/v1/customer/${id}`, options);
|
|
13
|
+
}
|
|
14
|
+
|
|
11
15
|
token(body: CustomerTokenParams, options?: Core.RequestOptions): Core.APIPromise<string> {
|
|
12
16
|
return this._client.post('/v1/customer/token', {
|
|
13
17
|
body,
|
|
@@ -46,7 +50,44 @@ export interface CustomerCreateResponse {
|
|
|
46
50
|
/**
|
|
47
51
|
* The id of the customer in the subscriber system
|
|
48
52
|
*/
|
|
49
|
-
remoteId:
|
|
53
|
+
remoteId: string;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The display name of the customer
|
|
57
|
+
*/
|
|
58
|
+
displayName?: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface CustomerGetResponse {
|
|
62
|
+
/**
|
|
63
|
+
* The id of the customer in the subscriber system
|
|
64
|
+
*/
|
|
65
|
+
id: unknown;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The timestamp of the when the customer was created in our system
|
|
69
|
+
*/
|
|
70
|
+
createdAt: string;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The email of the customer
|
|
74
|
+
*/
|
|
75
|
+
email: string;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The first name of the customer
|
|
79
|
+
*/
|
|
80
|
+
firstName: string;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The last name of the customer
|
|
84
|
+
*/
|
|
85
|
+
lastName: string;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The id of the customer in the subscriber system
|
|
89
|
+
*/
|
|
90
|
+
remoteId: string;
|
|
50
91
|
|
|
51
92
|
/**
|
|
52
93
|
* The display name of the customer
|
|
@@ -75,7 +116,7 @@ export interface CustomerCreateParams {
|
|
|
75
116
|
/**
|
|
76
117
|
* The id of the customer in the subscriber system
|
|
77
118
|
*/
|
|
78
|
-
remoteId:
|
|
119
|
+
remoteId: string;
|
|
79
120
|
|
|
80
121
|
/**
|
|
81
122
|
* The display name of the customer
|
|
@@ -108,6 +149,7 @@ export interface CustomerTokenParams {
|
|
|
108
149
|
export declare namespace Customer {
|
|
109
150
|
export {
|
|
110
151
|
type CustomerCreateResponse as CustomerCreateResponse,
|
|
152
|
+
type CustomerGetResponse as CustomerGetResponse,
|
|
111
153
|
type CustomerTokenResponse as CustomerTokenResponse,
|
|
112
154
|
type CustomerCreateParams as CustomerCreateParams,
|
|
113
155
|
type CustomerTokenParams as CustomerTokenParams,
|
package/src/resources/index.ts
CHANGED
|
@@ -4,8 +4,10 @@ export { Conversation } from './conversation/conversation';
|
|
|
4
4
|
export {
|
|
5
5
|
Customer,
|
|
6
6
|
type CustomerCreateResponse,
|
|
7
|
+
type CustomerGetResponse,
|
|
7
8
|
type CustomerTokenResponse,
|
|
8
9
|
type CustomerCreateParams,
|
|
9
10
|
type CustomerTokenParams,
|
|
10
11
|
} from './customer';
|
|
11
12
|
export { Ingest, type IngestTestParams } from './ingest';
|
|
13
|
+
export { Workflow } from './workflow';
|