@pipedream/facebook_pages 0.1.0 → 0.1.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/README.md +11 -0
- package/facebook_pages.app.mjs +39 -3
- package/package.json +2 -2
- package/actions/common/common.mjs +0 -37
- package/actions/create-comment/create-comment.mjs +0 -43
- package/actions/create-post/create-post.mjs +0 -46
- package/actions/get-comment/get-comment.mjs +0 -43
- package/actions/get-page/get-page.mjs +0 -20
- package/actions/get-post/get-post.mjs +0 -33
- package/actions/list-comments/list-comments.mjs +0 -54
- package/actions/list-posts/list-posts.mjs +0 -44
- package/actions/update-comment/update-comment.mjs +0 -53
- package/actions/update-post/update-post.mjs +0 -43
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Overview
|
|
2
|
+
|
|
3
|
+
The Facebook Pages API on Pipedream allows you to automate interactions with your Facebook Page. Using Pipedream's serverless platform, you can create workflows that respond to events, publish new content, manage posts, and analyze Page performance data. This API enables seamless integration with other apps and services, allowing for complex automations and data-driven decision-making.
|
|
4
|
+
|
|
5
|
+
# Example Use Cases
|
|
6
|
+
|
|
7
|
+
- **Automate Content Posting**: Create a workflow that schedules and posts content to your Facebook Page. When you add new content to a Google Sheets spreadsheet, Pipedream triggers a workflow that automatically publishes the content to your Page at the scheduled time.
|
|
8
|
+
|
|
9
|
+
- **Audience Engagement Tracker**: Craft a workflow that monitors comments and messages on your Page. Leveraging Pipedream's built-in code steps, you can analyze sentiment, flag important items, and even respond automatically. Connect with Slack to send notifications when a user interaction requires personal attention.
|
|
10
|
+
|
|
11
|
+
- **Performance Reporting**: Set up a recurring workflow that gathers analytics from your Facebook Page and compiles them into a report. Integrate with email services like SendGrid to send weekly performance insights directly to your inbox or to your marketing team.
|
package/facebook_pages.app.mjs
CHANGED
|
@@ -135,9 +135,20 @@ export default {
|
|
|
135
135
|
});
|
|
136
136
|
},
|
|
137
137
|
async getAccessToken(pageId) {
|
|
138
|
-
const
|
|
139
|
-
const page =
|
|
140
|
-
return page
|
|
138
|
+
const pages = await this.listAllPages();
|
|
139
|
+
const page = pages.find(({ id }) => id == pageId);
|
|
140
|
+
return page?.access_token;
|
|
141
|
+
},
|
|
142
|
+
async listAllPages(args = {}) {
|
|
143
|
+
const results = this.paginate({
|
|
144
|
+
fn: this.listPages,
|
|
145
|
+
args,
|
|
146
|
+
});
|
|
147
|
+
const pages = [];
|
|
148
|
+
for await (const page of results) {
|
|
149
|
+
pages.push(page);
|
|
150
|
+
}
|
|
151
|
+
return pages;
|
|
141
152
|
},
|
|
142
153
|
getPost({
|
|
143
154
|
pageId, postId, ...args
|
|
@@ -221,5 +232,30 @@ export default {
|
|
|
221
232
|
...args,
|
|
222
233
|
});
|
|
223
234
|
},
|
|
235
|
+
async *paginate({
|
|
236
|
+
fn, args = {},
|
|
237
|
+
}) {
|
|
238
|
+
do {
|
|
239
|
+
const {
|
|
240
|
+
data, paging,
|
|
241
|
+
} = await fn(args);
|
|
242
|
+
if (!data.length) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
for (const item of data) {
|
|
246
|
+
yield item;
|
|
247
|
+
}
|
|
248
|
+
if (!paging?.next) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
args = {
|
|
252
|
+
...args,
|
|
253
|
+
params: {
|
|
254
|
+
...args.params,
|
|
255
|
+
after: paging.cursors.after,
|
|
256
|
+
},
|
|
257
|
+
};
|
|
258
|
+
} while (true);
|
|
259
|
+
},
|
|
224
260
|
},
|
|
225
261
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipedream/facebook_pages",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Pipedream Facebook Pages Components",
|
|
5
5
|
"main": "facebook_pages.app.mjs",
|
|
6
6
|
"keywords": [
|
|
@@ -13,6 +13,6 @@
|
|
|
13
13
|
"access": "public"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@pipedream/platform": "^1.
|
|
16
|
+
"@pipedream/platform": "^1.6.8"
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import facebookPages from "../../facebook_pages.app.mjs";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
props: {
|
|
5
|
-
facebookPages,
|
|
6
|
-
page: {
|
|
7
|
-
propDefinition: [
|
|
8
|
-
facebookPages,
|
|
9
|
-
"page",
|
|
10
|
-
],
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
methods: {
|
|
14
|
-
async *paginate({
|
|
15
|
-
fn, args = {},
|
|
16
|
-
}) {
|
|
17
|
-
do {
|
|
18
|
-
const {
|
|
19
|
-
data, paging,
|
|
20
|
-
} = await fn(args);
|
|
21
|
-
if (!data.length) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
for (const item of data) {
|
|
25
|
-
yield item;
|
|
26
|
-
}
|
|
27
|
-
args = {
|
|
28
|
-
...args,
|
|
29
|
-
params: {
|
|
30
|
-
...args.params,
|
|
31
|
-
after: paging.cursors.after,
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
} while (true);
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import common from "../common/common.mjs";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
...common,
|
|
5
|
-
key: "facebook_pages-create-comment",
|
|
6
|
-
name: "Create Comment",
|
|
7
|
-
description: "Create a new comment on a post on a Facebook Page. [See the documentation](https://developers.facebook.com/docs/graph-api/reference/object/comments/#publish)",
|
|
8
|
-
version: "0.0.1",
|
|
9
|
-
type: "action",
|
|
10
|
-
props: {
|
|
11
|
-
...common.props,
|
|
12
|
-
post: {
|
|
13
|
-
propDefinition: [
|
|
14
|
-
common.props.facebookPages,
|
|
15
|
-
"post",
|
|
16
|
-
(c) => ({
|
|
17
|
-
pageId: c.page,
|
|
18
|
-
}),
|
|
19
|
-
],
|
|
20
|
-
},
|
|
21
|
-
message: {
|
|
22
|
-
type: "string",
|
|
23
|
-
label: "Message",
|
|
24
|
-
description: "The comment text",
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
async run({ $ }) {
|
|
28
|
-
const response = await this.facebookPages.createComment({
|
|
29
|
-
pageId: this.page,
|
|
30
|
-
postId: this.post,
|
|
31
|
-
data: {
|
|
32
|
-
message: this.message,
|
|
33
|
-
},
|
|
34
|
-
$,
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
if (response) {
|
|
38
|
-
$.export("$summary", `Successfully created new comment with ID ${response.id}.`);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return response;
|
|
42
|
-
},
|
|
43
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import common from "../common/common.mjs";
|
|
2
|
-
import { ConfigurationError } from "@pipedream/platform";
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
...common,
|
|
6
|
-
key: "facebook_pages-create-post",
|
|
7
|
-
name: "Create Post",
|
|
8
|
-
description: "Create a new post on a Facebook Page. [See the documentation](https://developers.facebook.com/docs/graph-api/reference/page/feed#publish)",
|
|
9
|
-
version: "0.0.1",
|
|
10
|
-
type: "action",
|
|
11
|
-
props: {
|
|
12
|
-
...common.props,
|
|
13
|
-
message: {
|
|
14
|
-
type: "string",
|
|
15
|
-
label: "Message",
|
|
16
|
-
description: "The main body of the post, otherwise called the status message. Either `link` or `message` must be supplied.",
|
|
17
|
-
optional: true,
|
|
18
|
-
},
|
|
19
|
-
link: {
|
|
20
|
-
type: "string",
|
|
21
|
-
label: "Link",
|
|
22
|
-
description: "The URL of a link to attach to the post. Either link or message must be supplied.",
|
|
23
|
-
optional: true,
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
async run({ $ }) {
|
|
27
|
-
if (!this.message && !this.link) {
|
|
28
|
-
throw new ConfigurationError("Either `link` or `message` must be supplied");
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const response = await this.facebookPages.createPost({
|
|
32
|
-
pageId: this.page,
|
|
33
|
-
data: {
|
|
34
|
-
message: this.message,
|
|
35
|
-
link: this.link,
|
|
36
|
-
},
|
|
37
|
-
$,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
if (response) {
|
|
41
|
-
$.export("$summary", `Successfully created new post with ID ${response.id}.`);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return response;
|
|
45
|
-
},
|
|
46
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import common from "../common/common.mjs";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
...common,
|
|
5
|
-
key: "facebook_pages-get-comment",
|
|
6
|
-
name: "Get Comment",
|
|
7
|
-
description: "Retrieves a comment on a post on a Facebook Page. [See the documentation](https://developers.facebook.com/docs/graph-api/reference/comment/#read)",
|
|
8
|
-
version: "0.0.1",
|
|
9
|
-
type: "action",
|
|
10
|
-
props: {
|
|
11
|
-
...common.props,
|
|
12
|
-
post: {
|
|
13
|
-
propDefinition: [
|
|
14
|
-
common.props.facebookPages,
|
|
15
|
-
"post",
|
|
16
|
-
(c) => ({
|
|
17
|
-
pageId: c.page,
|
|
18
|
-
}),
|
|
19
|
-
],
|
|
20
|
-
},
|
|
21
|
-
comment: {
|
|
22
|
-
propDefinition: [
|
|
23
|
-
common.props.facebookPages,
|
|
24
|
-
"comment",
|
|
25
|
-
(c) => ({
|
|
26
|
-
pageId: c.page,
|
|
27
|
-
postId: c.post,
|
|
28
|
-
}),
|
|
29
|
-
],
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
async run({ $ }) {
|
|
33
|
-
const response = await this.facebookPages.getComment({
|
|
34
|
-
pageId: this.page,
|
|
35
|
-
commentId: this.comment,
|
|
36
|
-
$,
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
$.export("$summary", `Successfully retrieved comment with ID ${this.comment}`);
|
|
40
|
-
|
|
41
|
-
return response;
|
|
42
|
-
},
|
|
43
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import common from "../common/common.mjs";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
...common,
|
|
5
|
-
key: "facebook_pages-get-page",
|
|
6
|
-
name: "Get Page",
|
|
7
|
-
description: "Retrieves a Facebook Page. [See the documentation](https://developers.facebook.com/docs/graph-api/reference/page)",
|
|
8
|
-
version: "0.0.1",
|
|
9
|
-
type: "action",
|
|
10
|
-
async run({ $ }) {
|
|
11
|
-
const { data } = await this.facebookPages.listPages({
|
|
12
|
-
$,
|
|
13
|
-
});
|
|
14
|
-
const page = data.find(({ id }) => id == this.page);
|
|
15
|
-
|
|
16
|
-
$.export("$summary", `Successfully retrieved page with ID ${this.page}`);
|
|
17
|
-
|
|
18
|
-
return page;
|
|
19
|
-
},
|
|
20
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import common from "../common/common.mjs";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
...common,
|
|
5
|
-
key: "facebook_pages-get-post",
|
|
6
|
-
name: "Get Post",
|
|
7
|
-
description: "Retrieves a post on a Facebook Page. [See the documentation](https://developers.facebook.com/docs/graph-api/reference/pagepost)",
|
|
8
|
-
version: "0.0.1",
|
|
9
|
-
type: "action",
|
|
10
|
-
props: {
|
|
11
|
-
...common.props,
|
|
12
|
-
post: {
|
|
13
|
-
propDefinition: [
|
|
14
|
-
common.props.facebookPages,
|
|
15
|
-
"post",
|
|
16
|
-
(c) => ({
|
|
17
|
-
pageId: c.page,
|
|
18
|
-
}),
|
|
19
|
-
],
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
async run({ $ }) {
|
|
23
|
-
const response = await this.facebookPages.getPost({
|
|
24
|
-
pageId: this.page,
|
|
25
|
-
postId: this.post,
|
|
26
|
-
$,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
$.export("$summary", `Successfully retrieved post with ID ${this.post}`);
|
|
30
|
-
|
|
31
|
-
return response;
|
|
32
|
-
},
|
|
33
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import common from "../common/common.mjs";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
...common,
|
|
5
|
-
key: "facebook_pages-list-comments",
|
|
6
|
-
name: "List Comments",
|
|
7
|
-
description: "Retrieves a list of comments on a post on a Facebook Page. [See the documentation](https://developers.facebook.com/docs/graph-api/reference/comment/#read)",
|
|
8
|
-
version: "0.0.1",
|
|
9
|
-
type: "action",
|
|
10
|
-
props: {
|
|
11
|
-
...common.props,
|
|
12
|
-
post: {
|
|
13
|
-
propDefinition: [
|
|
14
|
-
common.props.facebookPages,
|
|
15
|
-
"post",
|
|
16
|
-
(c) => ({
|
|
17
|
-
pageId: c.page,
|
|
18
|
-
}),
|
|
19
|
-
],
|
|
20
|
-
},
|
|
21
|
-
maxResults: {
|
|
22
|
-
propDefinition: [
|
|
23
|
-
common.props.facebookPages,
|
|
24
|
-
"maxResults",
|
|
25
|
-
],
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
async run({ $ }) {
|
|
29
|
-
const response = this.paginate({
|
|
30
|
-
fn: this.facebookPages.listComments,
|
|
31
|
-
args: {
|
|
32
|
-
pageId: this.page,
|
|
33
|
-
postId: this.post,
|
|
34
|
-
$,
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
const comments = [];
|
|
39
|
-
let count = 0;
|
|
40
|
-
for await (const comment of response) {
|
|
41
|
-
comments.push(comment);
|
|
42
|
-
|
|
43
|
-
if (this.maxResults && ++count === this.maxResults) {
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
$.export("$summary", `Successfully retrieved ${comments.length} comment${comments.length === 1
|
|
49
|
-
? ""
|
|
50
|
-
: "s"}`);
|
|
51
|
-
|
|
52
|
-
return comments;
|
|
53
|
-
},
|
|
54
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import common from "../common/common.mjs";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
...common,
|
|
5
|
-
key: "facebook_pages-list-posts",
|
|
6
|
-
name: "List Posts",
|
|
7
|
-
description: "Retrieves a list of posts on a Facebook Page. [See the documentation](https://developers.facebook.com/docs/graph-api/reference/v17.0/page/feed)",
|
|
8
|
-
version: "0.0.1",
|
|
9
|
-
type: "action",
|
|
10
|
-
props: {
|
|
11
|
-
...common.props,
|
|
12
|
-
maxResults: {
|
|
13
|
-
propDefinition: [
|
|
14
|
-
common.props.facebookPages,
|
|
15
|
-
"maxResults",
|
|
16
|
-
],
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
async run({ $ }) {
|
|
20
|
-
const response = this.paginate({
|
|
21
|
-
fn: this.facebookPages.listPosts,
|
|
22
|
-
args: {
|
|
23
|
-
pageId: this.page,
|
|
24
|
-
$,
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
const posts = [];
|
|
29
|
-
let count = 0;
|
|
30
|
-
for await (const post of response) {
|
|
31
|
-
posts.push(post);
|
|
32
|
-
|
|
33
|
-
if (this.maxResults && ++count === this.maxResults) {
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
$.export("$summary", `Successfully retrieved ${posts.length} post${posts.length === 1
|
|
39
|
-
? ""
|
|
40
|
-
: "s"}`);
|
|
41
|
-
|
|
42
|
-
return posts;
|
|
43
|
-
},
|
|
44
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import common from "../common/common.mjs";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
...common,
|
|
5
|
-
key: "facebook_pages-update-comment",
|
|
6
|
-
name: "Update Comment",
|
|
7
|
-
description: "Updates an existing comment on a post on a Facebook Page. [See the documentation](https://developers.facebook.com/docs/graph-api/reference/comment/#updating)",
|
|
8
|
-
version: "0.0.1",
|
|
9
|
-
type: "action",
|
|
10
|
-
props: {
|
|
11
|
-
...common.props,
|
|
12
|
-
post: {
|
|
13
|
-
propDefinition: [
|
|
14
|
-
common.props.facebookPages,
|
|
15
|
-
"post",
|
|
16
|
-
(c) => ({
|
|
17
|
-
pageId: c.page,
|
|
18
|
-
}),
|
|
19
|
-
],
|
|
20
|
-
},
|
|
21
|
-
comment: {
|
|
22
|
-
propDefinition: [
|
|
23
|
-
common.props.facebookPages,
|
|
24
|
-
"comment",
|
|
25
|
-
(c) => ({
|
|
26
|
-
pageId: c.page,
|
|
27
|
-
postId: c.post,
|
|
28
|
-
}),
|
|
29
|
-
],
|
|
30
|
-
},
|
|
31
|
-
message: {
|
|
32
|
-
type: "string",
|
|
33
|
-
label: "Message",
|
|
34
|
-
description: "The comment text",
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
async run({ $ }) {
|
|
38
|
-
const response = await this.facebookPages.updateComment({
|
|
39
|
-
pageId: this.page,
|
|
40
|
-
commentId: this.comment,
|
|
41
|
-
data: {
|
|
42
|
-
message: this.message,
|
|
43
|
-
},
|
|
44
|
-
$,
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
if (response) {
|
|
48
|
-
$.export("$summary", `Successfully updated comment with ID ${this.comment}.`);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return response;
|
|
52
|
-
},
|
|
53
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import common from "../common/common.mjs";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
...common,
|
|
5
|
-
key: "facebook_pages-update-post",
|
|
6
|
-
name: "Update Post",
|
|
7
|
-
description: "Update an existing post on a Facebook Page. [See the documentation](https://developers.facebook.com/docs/graph-api/reference/post#updating)",
|
|
8
|
-
version: "0.0.1",
|
|
9
|
-
type: "action",
|
|
10
|
-
props: {
|
|
11
|
-
...common.props,
|
|
12
|
-
post: {
|
|
13
|
-
propDefinition: [
|
|
14
|
-
common.props.facebookPages,
|
|
15
|
-
"post",
|
|
16
|
-
(c) => ({
|
|
17
|
-
pageId: c.page,
|
|
18
|
-
}),
|
|
19
|
-
],
|
|
20
|
-
},
|
|
21
|
-
message: {
|
|
22
|
-
type: "string",
|
|
23
|
-
label: "Message",
|
|
24
|
-
description: "The main body of the post, otherwise called the status message.",
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
async run({ $ }) {
|
|
28
|
-
const response = await this.facebookPages.updatePost({
|
|
29
|
-
pageId: this.page,
|
|
30
|
-
postId: this.post,
|
|
31
|
-
data: {
|
|
32
|
-
message: this.message,
|
|
33
|
-
},
|
|
34
|
-
$,
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
if (response) {
|
|
38
|
-
$.export("$summary", `Successfully updated post with ID ${this.post}.`);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return response;
|
|
42
|
-
},
|
|
43
|
-
};
|