Skip to content

Commit 396dabd

Browse files
committed
[Components] kustomer #15920
Sources - New Conversation (Instant) - New Customer (Instant) - New Message (Instant) - Updated Conversation (Instant) - Updated Customer (Instant) Actions - Create Conversation - Update Conversation - Create Customer - Update Customer
1 parent 9f7d802 commit 396dabd

File tree

19 files changed

+1839
-1487
lines changed

19 files changed

+1839
-1487
lines changed
Lines changed: 63 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,56 @@
1+
import {
2+
parseObject, throwError,
3+
} from "../../common/utils.mjs";
14
import kustomer from "../../kustomer.app.mjs";
2-
import { axios } from "@pipedream/platform";
35

46
export default {
57
key: "kustomer-create-conversation",
68
name: "Create Conversation",
7-
description: "Creates a new conversation in Kustomer. [See the documentation]()",
8-
version: "0.0.{{ts}}",
9+
description: "Creates a new conversation in Kustomer. [See the documentation](https://developer.kustomer.com/kustomer-api-docs/reference/createaconversation)",
10+
version: "0.0.1",
911
type: "action",
1012
props: {
1113
kustomer,
12-
13-
// Required prop
14-
customerId: {
15-
type: "string",
16-
label: "Customer ID",
17-
description: "Unique identifier for the customer",
14+
customer: {
15+
propDefinition: [
16+
kustomer,
17+
"customerId",
18+
],
1819
},
19-
20-
// Optional props
2120
externalId: {
22-
type: "string",
23-
label: "External ID",
24-
description: "External identifier",
21+
propDefinition: [
22+
kustomer,
23+
"externalId",
24+
],
2525
optional: true,
2626
},
2727
name: {
28-
type: "string",
29-
label: "Name",
28+
propDefinition: [
29+
kustomer,
30+
"name",
31+
],
3032
description: "Name of the conversation",
3133
optional: true,
3234
},
3335
status: {
34-
type: "string",
35-
label: "Status",
36-
description: "Status of the conversation",
36+
propDefinition: [
37+
kustomer,
38+
"status",
39+
],
3740
optional: true,
3841
},
3942
priority: {
40-
type: "integer",
41-
label: "Priority",
42-
description: "Priority level (1-5)",
43+
propDefinition: [
44+
kustomer,
45+
"priority",
46+
],
4347
optional: true,
44-
min: 1,
45-
max: 5,
4648
},
4749
direction: {
48-
type: "string",
49-
label: "Direction",
50-
description: "Direction of the conversation",
51-
optional: true,
52-
},
53-
replyChannel: {
54-
type: "string",
55-
label: "Reply Channel",
56-
description: "Channel to reply to",
50+
propDefinition: [
51+
kustomer,
52+
"direction",
53+
],
5754
optional: true,
5855
},
5956
tags: {
@@ -78,35 +75,45 @@ export default {
7875
optional: true,
7976
},
8077
defaultLang: {
81-
type: "string",
82-
label: "Default Language",
78+
propDefinition: [
79+
kustomer,
80+
"defaultLang",
81+
],
8382
description: "Default language for the conversation",
8483
optional: true,
8584
},
86-
queue: {
87-
type: "string",
88-
label: "Queue",
89-
description: "Queue information",
90-
optional: true,
85+
queueId: {
86+
propDefinition: [
87+
kustomer,
88+
"queueId",
89+
],
9190
},
9291
},
9392
async run({ $ }) {
94-
const response = await this.kustomer.createConversation({
95-
customerId: this.customerId,
96-
externalId: this.externalId,
97-
name: this.name,
98-
status: this.status,
99-
priority: this.priority,
100-
direction: this.direction,
101-
replyChannel: this.replyChannel,
102-
tags: this.tags,
103-
assignedUsers: this.assignedUsers,
104-
assignedTeams: this.assignedTeams,
105-
defaultLang: this.defaultLang,
106-
queue: this.queue,
107-
});
93+
try {
94+
const response = await this.kustomer.createConversation({
95+
$,
96+
data: {
97+
customer: this.customer,
98+
externalId: this.externalId,
99+
name: this.name,
100+
status: this.status,
101+
priority: this.priority,
102+
direction: this.direction,
103+
tags: parseObject(this.tags),
104+
assignedUsers: parseObject(this.assignedUsers),
105+
assignedTeams: parseObject(this.assignedTeams),
106+
defaultLang: this.defaultLang,
107+
queue: {
108+
id: this.queueId,
109+
},
110+
},
111+
});
108112

109-
$.export("$summary", `Created conversation with ID ${response.id}`);
110-
return response;
113+
$.export("$summary", `Created conversation with ID ${response.data.id}`);
114+
return response;
115+
} catch ({ message }) {
116+
throwError(message);
117+
}
111118
},
112119
};

0 commit comments

Comments
 (0)