Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import freshchat from "../../freshchat.app.mjs";

export default {
key: "freshchat-fetch-conversation-details",
name: "Fetch Conversation Details",
description: "Fetches details for a specific conversation. [See the documentation](https://developers.freshchat.com/api/#retrieve_a_conversation)",
version: "0.0.1",
type: "action",
props: {
freshchat,
userId: {
propDefinition: [
freshchat,
"userId",
],
},
conversationId: {
propDefinition: [
freshchat,
"conversationId",
(c) => ({
userId: c.userId,
}),
],
},
},
async run({ $ }) {
const response = await this.freshchat.getConversation({
conversationId: this.conversationId,
});
$.export("$summary", `Fetched conversation details for conversation ${this.conversationId}`);
return response;
},
};
69 changes: 69 additions & 0 deletions components/freshchat/actions/list-agents/list-agents.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import freshchat from "../../freshchat.app.mjs";
import { ConfigurationError } from "@pipedream/platform";

export default {
key: "freshchat-list-agents",
name: "List Agents",
description: "Lists all agents in Freshchat. [See the documentation](https://developers.freshchat.com/api/#list_all_agents)",
version: "0.0.1",
type: "action",
props: {
freshchat,
groupId: {
propDefinition: [
freshchat,
"groupId",
],
optional: true,
},
isDeactivated: {
type: "boolean",
label: "Is Deactivated",
description: "Limits the response to agent objects whose is_deactivated value matches the parameter value",
optional: true,
},
availabilityStatus: {
type: "string",
label: "Availability Status",
description: "Limits the response to agent objects whose availability_status value matches the parameter value",
options: [
"AVAILABLE",
"UNAVAILABLE",
],
optional: true,
},
maxResults: {
propDefinition: [
freshchat,
"maxResults",
],
},
},
async run({ $ }) {
try {
const response = await this.freshchat.getPaginatedResults({
fn: this.freshchat.listAgents,
args: {
$,
params: {
groups: this.groupId,
is_deactivated: this.isDeactivated,
availability_status: this.availabilityStatus,
},
},
resourceKey: "agents",
max: this.maxResults,
});
$.export("$summary", `Listed ${response.length} agent${response.length === 1
? ""
: "s"}`);
return response;
} catch (e) {
if (e.status === 404) {
$.export("$summary", "No agents found");
} else {
throw new ConfigurationError(e);
}
}
},
};
41 changes: 41 additions & 0 deletions components/freshchat/actions/list-channels/list-channels.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import freshchat from "../../freshchat.app.mjs";

export default {
key: "freshchat-list-channels",
name: "List Channels",
description: "Lists all channels in Freshchat. [See the documentation](https://developers.freshchat.com/api/#channels-(topics))",
version: "0.0.1",
type: "action",
props: {
freshchat,
locale: {
type: "string",
label: "Locale",
description: "Limits the response to topics whose locale value matches the parameter value. Must be specified in the ISO-639 format. E.g. `en`",
optional: true,
},
maxResults: {
propDefinition: [
freshchat,
"maxResults",
],
},
},
async run({ $ }) {
const channels = await this.freshchat.getPaginatedResults({
fn: this.freshchat.listChannels,
resourceKey: "channels",
args: {
$,
params: {
locale: this.locale,
},
},
max: this.maxResults,
});
$.export("$summary", `Listed ${channels.length} channel${channels.length === 1
? ""
: "s"}`);
return channels;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import freshchat from "../../freshchat.app.mjs";

export default {
key: "freshchat-send-message-in-chat",
name: "Send Message in Chat",
description: "Sends a message in a specific conversation. [See the documentation](https://developers.freshchat.com/api/#send_message_to_conversation)",
version: "0.0.1",
type: "action",
props: {
freshchat,
userId: {
propDefinition: [
freshchat,
"userId",
],
},
conversationId: {
propDefinition: [
freshchat,
"conversationId",
(c) => ({
userId: c.userId,
}),
],
},
message: {
type: "string",
label: "Message",
description: "The content of the message to send",
},
},
async run({ $ }) {
const data = {
message_parts: [
{
text: {
content: this.message,
},
},
],
actor_type: "user",
actor_id: this.userId,
user_id: this.userId,
};
try {
await this.freshchat.sendMessageInChat({
$,
conversationId: this.conversationId,
data,
});
} catch {
// Sends message, but always returns the error
/* {
"code": 400,
"status": "INVALID_VALUE",
"message": "com.demach.konotor.model.fragment.TextFragment cannot be cast to
com.demach.konotor.model.fragment.EmailFragment"
}
*/
}
$.export("$summary", `Sent message in conversation ${this.conversationId}`);
return data;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import freshchat from "../../freshchat.app.mjs";
import { ConfigurationError } from "@pipedream/platform";

export default {
key: "freshchat-update-conversation-status",
name: "Update Conversation Status",
description: "Updates the status of a specific conversation. [See the documentation](https://developers.freshchat.com/api/#update_a_conversation)",
version: "0.0.1",
type: "action",
props: {
freshchat,
userId: {
propDefinition: [
freshchat,
"userId",
],
},
conversationId: {
propDefinition: [
freshchat,
"conversationId",
(c) => ({
userId: c.userId,
}),
],
},
status: {
type: "string",
label: "Status",
description: "Status of the conversation",
options: [
"new",
"assigned",
"resolved",
"reopened",
],
},
agentId: {
propDefinition: [
freshchat,
"agentId",
],
description: "The ID of an agent to assign the conversation to. Required if status is `assigned`",
optional: true,
},
},
async run({ $ }) {
if (this.status === "assigned" && !this.agentId) {
throw new ConfigurationError("Agent ID is required when status is `assigned`");
}

const response = await this.freshchat.updateConversation({
$,
conversationId: this.conversationId,
data: {
status: this.status,
assigned_agent_id: this.agentId,
},
});
$.export("$summary", `Updated conversation status to ${this.status}`);
return response;
},
};
Loading
Loading