Skip to content

Commit a75bf0c

Browse files
authored
[Components] FreshChat - new component (#18944)
1 parent 76a26f6 commit a75bf0c

File tree

3 files changed

+217
-19
lines changed

3 files changed

+217
-19
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import app from "../../freshchat.app.mjs";
2+
3+
export default {
4+
key: "freshchat-list-messages",
5+
name: "List Messages",
6+
description: "Lists all messages in a conversation. [See the documentation](https://developers.freshchat.com/api/#list_messages)",
7+
type: "action",
8+
version: "0.0.1",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
app,
16+
userId: {
17+
propDefinition: [
18+
app,
19+
"userId",
20+
],
21+
},
22+
conversationId: {
23+
propDefinition: [
24+
app,
25+
"conversationId",
26+
({ userId }) => ({
27+
userId,
28+
}),
29+
],
30+
},
31+
fromTime: {
32+
type: "string",
33+
label: "From Time",
34+
description: "UTC datetime to retrieve messages after this timestamp (ISO 8601 format). Example: `2025-01-01T00:00:00Z`.",
35+
optional: true,
36+
},
37+
maxResults: {
38+
propDefinition: [
39+
app,
40+
"maxResults",
41+
],
42+
},
43+
},
44+
async run({ $ }) {
45+
const {
46+
app,
47+
conversationId,
48+
fromTime,
49+
maxResults,
50+
} = this;
51+
52+
const response = await app.getPaginatedResults({
53+
fn: app.listMessages,
54+
args: {
55+
$,
56+
conversationId,
57+
params: {
58+
from_time: fromTime,
59+
},
60+
},
61+
resourceKey: "messages",
62+
max: maxResults,
63+
});
64+
65+
$.export("$summary", `Listed ${response.length} message(s)`);
66+
return response;
67+
},
68+
};

components/freshchat/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/freshchat",
3-
"version": "0.1.1",
3+
"version": "0.2.0",
44
"description": "Pipedream Freshchat Components",
55
"main": "freshchat.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)