Skip to content

Commit aa28fcb

Browse files
authored
Merging pull request #17572
* new components * pnpm-lock.yaml * update * update
1 parent 12fa61a commit aa28fcb

File tree

13 files changed

+734
-8
lines changed

13 files changed

+734
-8
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import freshchat from "../../freshchat.app.mjs";
2+
3+
export default {
4+
key: "freshchat-fetch-conversation-details",
5+
name: "Fetch Conversation Details",
6+
description: "Fetches details for a specific conversation. [See the documentation](https://developers.freshchat.com/api/#retrieve_a_conversation)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
freshchat,
11+
userId: {
12+
propDefinition: [
13+
freshchat,
14+
"userId",
15+
],
16+
},
17+
conversationId: {
18+
propDefinition: [
19+
freshchat,
20+
"conversationId",
21+
(c) => ({
22+
userId: c.userId,
23+
}),
24+
],
25+
},
26+
},
27+
async run({ $ }) {
28+
const response = await this.freshchat.getConversation({
29+
conversationId: this.conversationId,
30+
});
31+
$.export("$summary", `Fetched conversation details for conversation ${this.conversationId}`);
32+
return response;
33+
},
34+
};
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import freshchat from "../../freshchat.app.mjs";
2+
import { ConfigurationError } from "@pipedream/platform";
3+
4+
export default {
5+
key: "freshchat-list-agents",
6+
name: "List Agents",
7+
description: "Lists all agents in Freshchat. [See the documentation](https://developers.freshchat.com/api/#list_all_agents)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
freshchat,
12+
groupId: {
13+
propDefinition: [
14+
freshchat,
15+
"groupId",
16+
],
17+
optional: true,
18+
},
19+
isDeactivated: {
20+
type: "boolean",
21+
label: "Is Deactivated",
22+
description: "Limits the response to agent objects whose is_deactivated value matches the parameter value",
23+
optional: true,
24+
},
25+
availabilityStatus: {
26+
type: "string",
27+
label: "Availability Status",
28+
description: "Limits the response to agent objects whose availability_status value matches the parameter value",
29+
options: [
30+
"AVAILABLE",
31+
"UNAVAILABLE",
32+
],
33+
optional: true,
34+
},
35+
maxResults: {
36+
propDefinition: [
37+
freshchat,
38+
"maxResults",
39+
],
40+
},
41+
},
42+
async run({ $ }) {
43+
try {
44+
const response = await this.freshchat.getPaginatedResults({
45+
fn: this.freshchat.listAgents,
46+
args: {
47+
$,
48+
params: {
49+
groups: this.groupId,
50+
is_deactivated: this.isDeactivated,
51+
availability_status: this.availabilityStatus,
52+
},
53+
},
54+
resourceKey: "agents",
55+
max: this.maxResults,
56+
});
57+
$.export("$summary", `Listed ${response.length} agent${response.length === 1
58+
? ""
59+
: "s"}`);
60+
return response;
61+
} catch (e) {
62+
if (e.status === 404) {
63+
$.export("$summary", "No agents found");
64+
} else {
65+
throw new ConfigurationError(e);
66+
}
67+
}
68+
},
69+
};
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import freshchat from "../../freshchat.app.mjs";
2+
3+
export default {
4+
key: "freshchat-list-channels",
5+
name: "List Channels",
6+
description: "Lists all channels in Freshchat. [See the documentation](https://developers.freshchat.com/api/#channels-(topics))",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
freshchat,
11+
locale: {
12+
type: "string",
13+
label: "Locale",
14+
description: "Limits the response to topics whose locale value matches the parameter value. Must be specified in the ISO-639 format. E.g. `en`",
15+
optional: true,
16+
},
17+
maxResults: {
18+
propDefinition: [
19+
freshchat,
20+
"maxResults",
21+
],
22+
},
23+
},
24+
async run({ $ }) {
25+
const channels = await this.freshchat.getPaginatedResults({
26+
fn: this.freshchat.listChannels,
27+
resourceKey: "channels",
28+
args: {
29+
$,
30+
params: {
31+
locale: this.locale,
32+
},
33+
},
34+
max: this.maxResults,
35+
});
36+
$.export("$summary", `Listed ${channels.length} channel${channels.length === 1
37+
? ""
38+
: "s"}`);
39+
return channels;
40+
},
41+
};
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import freshchat from "../../freshchat.app.mjs";
2+
3+
export default {
4+
key: "freshchat-send-message-in-chat",
5+
name: "Send Message in Chat",
6+
description: "Sends a message in a specific conversation. [See the documentation](https://developers.freshchat.com/api/#send_message_to_conversation)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
freshchat,
11+
userId: {
12+
propDefinition: [
13+
freshchat,
14+
"userId",
15+
],
16+
},
17+
conversationId: {
18+
propDefinition: [
19+
freshchat,
20+
"conversationId",
21+
(c) => ({
22+
userId: c.userId,
23+
}),
24+
],
25+
},
26+
message: {
27+
type: "string",
28+
label: "Message",
29+
description: "The content of the message to send",
30+
},
31+
},
32+
async run({ $ }) {
33+
const data = {
34+
message_parts: [
35+
{
36+
text: {
37+
content: this.message,
38+
},
39+
},
40+
],
41+
actor_type: "user",
42+
actor_id: this.userId,
43+
user_id: this.userId,
44+
};
45+
try {
46+
await this.freshchat.sendMessageInChat({
47+
$,
48+
conversationId: this.conversationId,
49+
data,
50+
});
51+
} catch {
52+
// Sends message, but always returns the error
53+
/* {
54+
"code": 400,
55+
"status": "INVALID_VALUE",
56+
"message": "com.demach.konotor.model.fragment.TextFragment cannot be cast to
57+
com.demach.konotor.model.fragment.EmailFragment"
58+
}
59+
*/
60+
}
61+
$.export("$summary", `Sent message in conversation ${this.conversationId}`);
62+
return data;
63+
},
64+
};
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import freshchat from "../../freshchat.app.mjs";
2+
import { ConfigurationError } from "@pipedream/platform";
3+
4+
export default {
5+
key: "freshchat-update-conversation-status",
6+
name: "Update Conversation Status",
7+
description: "Updates the status of a specific conversation. [See the documentation](https://developers.freshchat.com/api/#update_a_conversation)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
freshchat,
12+
userId: {
13+
propDefinition: [
14+
freshchat,
15+
"userId",
16+
],
17+
},
18+
conversationId: {
19+
propDefinition: [
20+
freshchat,
21+
"conversationId",
22+
(c) => ({
23+
userId: c.userId,
24+
}),
25+
],
26+
},
27+
status: {
28+
type: "string",
29+
label: "Status",
30+
description: "Status of the conversation",
31+
options: [
32+
"new",
33+
"assigned",
34+
"resolved",
35+
"reopened",
36+
],
37+
},
38+
agentId: {
39+
propDefinition: [
40+
freshchat,
41+
"agentId",
42+
],
43+
description: "The ID of an agent to assign the conversation to. Required if status is `assigned`",
44+
optional: true,
45+
},
46+
},
47+
async run({ $ }) {
48+
if (this.status === "assigned" && !this.agentId) {
49+
throw new ConfigurationError("Agent ID is required when status is `assigned`");
50+
}
51+
52+
const response = await this.freshchat.updateConversation({
53+
$,
54+
conversationId: this.conversationId,
55+
data: {
56+
status: this.status,
57+
assigned_agent_id: this.agentId,
58+
},
59+
});
60+
$.export("$summary", `Updated conversation status to ${this.status}`);
61+
return response;
62+
},
63+
};

0 commit comments

Comments
 (0)