productivity
Facebook CLI for AI Agents
Use the Facebook CLI from KosmoKrator to call Facebook tools headlessly, return JSON, inspect schemas, and automate workflows from coding agents, scripts, and CI.Facebook CLI Setup
Facebook can be configured headlessly with `kosmokrator integrations:configure facebook`.
# Install KosmoKrator first if it is not available on PATH.
curl -fsSL https://raw.githubusercontent.com/OpenCompanyApp/kosmokrator/main/install.sh | bash
# Configure and verify this integration.
kosmokrator integrations:configure facebook --set access_token="$FACEBOOK_ACCESS_TOKEN" --enable --read allow --write ask --json
kosmokrator integrations:doctor facebook --json
kosmokrator integrations:status --json Credentials
Authentication type: Bearer token bearer_token. Configure credentials once, then reuse the same stored profile from scripts, coding CLIs, Lua, and MCP.
| Key | Env var | Type | Required | Label |
|---|---|---|---|---|
access_token | FACEBOOK_ACCESS_TOKEN | Secret secret | yes | Access Token |
base_url | FACEBOOK_BASE_URL | URL url | no | Graph API Base URL |
Command Patterns
The generic command is stable across every integration. The provider shortcut is shorter for humans.
kosmo integrations:call facebook.facebook_list_pages '{"fields":"example_fields","limit":1}' --json kosmo integrations:facebook facebook_list_pages '{"fields":"example_fields","limit":1}' --json Discovery
These commands return structured output for coding agents that need to inspect capabilities before choosing a function.
kosmo integrations:docs facebook --json
kosmo integrations:docs facebook.facebook_list_pages --json
kosmo integrations:schema facebook.facebook_list_pages --json
kosmo integrations:search "Facebook" --json
kosmo integrations:list --json Automation Contexts
The same configured command surface works in these environments. The command does not change unless the host wrapper, credentials, or permissions change.
CLI Functions
Every function below can be called headlessly. Commands are highlighted, copyable, and scroll horizontally when payloads are long.
facebook.facebook_list_pages
List all Facebook Pages the authenticated user manages. Returns page IDs, names, and access tokens for further operations.
read - Parameters
- fields, limit
kosmo integrations:call facebook.facebook_list_pages '{"fields":"example_fields","limit":1}' --json kosmo integrations:facebook facebook_list_pages '{"fields":"example_fields","limit":1}' --json facebook.facebook_get_page
Get details for a specific Facebook Page by its ID. Returns page name, category, follower count, and other metadata.
read - Parameters
- page_id, fields
kosmo integrations:call facebook.facebook_get_page '{"page_id":"example_page_id","fields":"example_fields"}' --json kosmo integrations:facebook facebook_get_page '{"page_id":"example_page_id","fields":"example_fields"}' --json facebook.facebook_list_posts
List posts published by a Facebook Page. Returns post IDs, messages, creation times, and engagement metrics.
read - Parameters
- page_id, fields, limit, since, until
kosmo integrations:call facebook.facebook_list_posts '{"page_id":"example_page_id","fields":"example_fields","limit":1,"since":"example_since","until":"example_until"}' --json kosmo integrations:facebook facebook_list_posts '{"page_id":"example_page_id","fields":"example_fields","limit":1,"since":"example_since","until":"example_until"}' --json facebook.facebook_create_post
Publish a new post on a Facebook Page. The post will appear on the Page's timeline immediately unless scheduled.
write - Parameters
- page_id, message, link, scheduled_publish_time
kosmo integrations:call facebook.facebook_create_post '{"page_id":"example_page_id","message":"example_message","link":"example_link","scheduled_publish_time":"example_scheduled_publish_time"}' --json kosmo integrations:facebook facebook_create_post '{"page_id":"example_page_id","message":"example_message","link":"example_link","scheduled_publish_time":"example_scheduled_publish_time"}' --json facebook.facebook_get_post
Get details for a specific Facebook post by its ID. Returns the post content, creation time, and engagement metrics.
read - Parameters
- post_id, fields
kosmo integrations:call facebook.facebook_get_post '{"post_id":"example_post_id","fields":"example_fields"}' --json kosmo integrations:facebook facebook_get_post '{"post_id":"example_post_id","fields":"example_fields"}' --json facebook.facebook_list_insights
Get engagement and performance metrics (insights) for a Facebook Page. Supports metrics like page_impressions, page_engaged_users, page_post_engagements, and more.
read - Parameters
- page_id, metric, period, since, until
kosmo integrations:call facebook.facebook_list_insights '{"page_id":"example_page_id","metric":"example_metric","period":"example_period","since":"example_since","until":"example_until"}' --json kosmo integrations:facebook facebook_list_insights '{"page_id":"example_page_id","metric":"example_metric","period":"example_period","since":"example_since","until":"example_until"}' --json facebook.facebook_get_current_user
Get the authenticated user's Facebook profile information, including name and user ID.
read - Parameters
- fields
kosmo integrations:call facebook.facebook_get_current_user '{"fields":"example_fields"}' --json kosmo integrations:facebook facebook_get_current_user '{"fields":"example_fields"}' --json Function Schemas
Use these parameter tables when building CLI payloads without calling integrations:schema first.
facebook.facebook_list_pages 2 parameters
kosmo integrations:schema facebook.facebook_list_pages --json | Parameter | Type | Required | Description |
|---|---|---|---|
fields | string | no | Comma-separated list of fields to return per page (e.g. "id,name,category,fan_count,about"). Defaults to "id,name,category". |
limit | integer | no | Maximum number of pages to return per request. |
facebook.facebook_get_page 2 parameters
kosmo integrations:schema facebook.facebook_get_page --json | Parameter | Type | Required | Description |
|---|---|---|---|
page_id | string | yes | The Facebook Page ID. |
fields | string | no | Comma-separated list of fields to return (e.g. "id,name,category,fan_count,about,website,phone"). Defaults to "id,name,category,fan_count,about". |
facebook.facebook_list_posts 5 parameters
kosmo integrations:schema facebook.facebook_list_posts --json | Parameter | Type | Required | Description |
|---|---|---|---|
page_id | string | yes | The Facebook Page ID. |
fields | string | no | Comma-separated list of fields to return per post (e.g. "id,message,created_time,attachments,insights"). Defaults to "id,message,created_time". |
limit | integer | no | Maximum number of posts to return per request. |
since | string | no | Only return posts created after this UNIX timestamp or ISO date. |
until | string | no | Only return posts created before this UNIX timestamp or ISO date. |
facebook.facebook_create_post 4 parameters
kosmo integrations:schema facebook.facebook_create_post --json | Parameter | Type | Required | Description |
|---|---|---|---|
page_id | string | yes | The Facebook Page ID to publish the post on. |
message | string | yes | The text content of the post. |
link | string | no | A URL to attach to the post (e.g. "https://example.com/article"). |
scheduled_publish_time | string | no | UNIX timestamp to schedule the post for future publication. The post will be saved as a draft until this time. |
facebook.facebook_get_post 2 parameters
kosmo integrations:schema facebook.facebook_get_post --json | Parameter | Type | Required | Description |
|---|---|---|---|
post_id | string | yes | The Facebook Post ID. |
fields | string | no | Comma-separated list of fields to return (e.g. "id,message,created_time,attachments,shares,likes.summary(true)"). Defaults to "id,message,created_time,attachments". |
facebook.facebook_list_insights 5 parameters
kosmo integrations:schema facebook.facebook_list_insights --json | Parameter | Type | Required | Description |
|---|---|---|---|
page_id | string | yes | The Facebook Page ID. |
metric | string | no | Comma-separated list of insight metrics to retrieve (e.g. "page_impressions,page_engaged_users,page_post_engagements"). Omit to return all available metrics. |
period | string | no | Aggregation period: "day", "week", "days_28", "month", or "lifetime". Defaults to "day". |
since | string | no | Start date for the insight data (UNIX timestamp or ISO date). |
until | string | no | End date for the insight data (UNIX timestamp or ISO date). |
facebook.facebook_get_current_user 1 parameters
kosmo integrations:schema facebook.facebook_get_current_user --json | Parameter | Type | Required | Description |
|---|---|---|---|
fields | string | no | Comma-separated list of fields to return (e.g. "id,name,email,picture"). Defaults to "id,name". |
Permissions
Headless calls still follow the integration read/write permission policy. Configure read/write defaults with
integrations:configure. Add --force only for trusted automation that should bypass that policy.