Integrations / Facebook Pages
Facebook Pages
Facebook Pages: list the Pages you manage, read posts and comments, publish posts and reply as the Page. Page actions use a Page access token.
6 actions
OAuth 2
4 read2 write
Calls graph.facebook.com
Connect
const conn = await setu.connections.initiate({ userId: "user_1", toolkit: "facebook" });
console.log(conn.connectUrl); // show this to your user
await conn.waitUntilActive();Permissions requested
| Scope | Why it is requested |
|---|---|
public_profile | Read your name and ID so Setu can label the connection |
pages_show_list | List the Facebook Pages you manage |
pages_read_engagement | Read posts and engagement on the Pages you manage |
pages_read_user_content | Read comments and posts made by visitors on your Pages |
pages_manage_posts | Publish posts to your Pages |
pages_manage_engagement | Reply to comments on your Pages |
Actions
Publish Page postwritefacebook.create_page_postPublish a text post (optionally with a link) on a Facebook Page, immediately. Needs the Page access token from get_page_access_token. The post goes public at once.
Needs scopes: pages_manage_posts, pages_read_engagement, pages_show_list
| Input | Type | Description | |
|---|---|---|---|
page_id | string | Required | Page id |
page_access_token | string | Required | Page access token for this Page (from get_page_access_token) |
message | string | Required | Post text |
link | string | Optional | Optional URL to attach |
await setu.execute({
userId: "user_1",
action: "facebook.create_page_post",
input: {
"page_id": "<page_id>",
"page_access_token": "<page_access_token>",
"message": "<message>"
},
});Get Page access tokenreadfacebook.get_page_access_tokenReturn each managed Page's id, name and Page access token (read via /me/accounts). Pass the token as page_access_token to the other Page actions. Treat the token as a secret and never show it to the user.
Needs scope: pages_show_list
| Input | Type | Description | |
|---|---|---|---|
limit | integer | Optional | Maximum Pages to return |
await setu.execute({
userId: "user_1",
action: "facebook.get_page_access_token",
input: {},
});List Page postsreadfacebook.list_page_postsRead recent posts on a Facebook Page's feed (id, text, time, link). Needs the Page access token from get_page_access_token.
Needs scopes: pages_read_engagement, pages_read_user_content
| Input | Type | Description | |
|---|---|---|---|
page_id | string | Required | Page id |
page_access_token | string | Required | Page access token for this Page (from get_page_access_token) |
limit | integer | Optional | Maximum posts to return (up to 100) |
await setu.execute({
userId: "user_1",
action: "facebook.list_page_posts",
input: {
"page_id": "<page_id>",
"page_access_token": "<page_access_token>"
},
});List my Pagesreadfacebook.list_pagesList the Facebook Pages the connected person can manage, with each Page's id, name, category and their tasks. Use the id with the other Page actions.
Needs scope: pages_show_list
| Input | Type | Description | |
|---|---|---|---|
limit | integer | Optional | Maximum Pages to return |
await setu.execute({
userId: "user_1",
action: "facebook.list_pages",
input: {},
});List comments on a postreadfacebook.list_post_commentsRead the top-level comments on a Page post (id, text, author, time). Needs the Page access token from get_page_access_token and a person who can moderate the Page.
Needs scopes: pages_read_engagement, pages_read_user_content
| Input | Type | Description | |
|---|---|---|---|
post_id | string | Required | Post id in pageid_postid form |
page_access_token | string | Required | Page access token for this Page (from get_page_access_token) |
limit | integer | Optional | Maximum comments to return |
await setu.execute({
userId: "user_1",
action: "facebook.list_post_comments",
input: {
"post_id": "<post_id>",
"page_access_token": "<page_access_token>"
},
});Reply to a commentwritefacebook.reply_to_commentPost a public reply as the Page to a comment (or a comment on a post). Needs the Page access token from get_page_access_token.
Needs scope: pages_manage_engagement
| Input | Type | Description | |
|---|---|---|---|
object_id | string | Required | Comment id (reply) or post id (new top-level comment) |
page_access_token | string | Required | Page access token for this Page (from get_page_access_token) |
message | string | Required | Reply text |
await setu.execute({
userId: "user_1",
action: "facebook.reply_to_comment",
input: {
"object_id": "<object_id>",
"page_access_token": "<page_access_token>",
"message": "<message>"
},
});