productivity
Manychat Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the Manychat KosmoKrator integration.Lua Namespace
Agents call this integration through app.integrations.manychat.*.
Use lua_read_doc("integrations.manychat") inside KosmoKrator to discover the same reference at runtime.
Call Lua from the Headless CLI
Use kosmo integrations:lua when a shell script, CI job, cron job, or another coding CLI should run a deterministic
Manychat workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.manychat.get_page_info({}))' --json kosmo integrations:lua --eval 'print(docs.read("manychat"))' --json
kosmo integrations:lua --eval 'print(docs.read("manychat.get_page_info"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local manychat = app.integrations.manychat
local result = manychat.get_page_info({})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.manychat, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.manychat.default.* or app.integrations.manychat.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need Manychat, use the narrower mcp:lua command.
# Use mcp:lua for MCP-only scripts; use integrations:lua for this integration namespace.
kosmo mcp:lua --eval 'dump(mcp.servers())' --json Agent-Facing Lua Docs
This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.
Manychat - Lua API Reference
Namespace: app.integrations.manychat
Use this integration for Manychat Account Public API operations. Responses are decoded Manychat JSON. Most endpoints return a top-level status and data object or list.
Account And Flows
local page = app.integrations.manychat.get_page_info({})
local flows = app.integrations.manychat.list_flows({})
get_flow is a compatibility helper. Manychat documents getFlows, not a single-flow endpoint, so this tool searches the list response by namespace or ID.
local flow = app.integrations.manychat.get_flow({page_id = "content20260101000000"})
Tags
local tags = app.integrations.manychat.list_tags({})
local created = app.integrations.manychat.create_tag({
name = "VIP"
})
app.integrations.manychat.remove_tag({tag_id = 123})
app.integrations.manychat.remove_tag_by_name({tag_name = "VIP"})
Fields
local custom_fields = app.integrations.manychat.list_custom_fields({})
local field = app.integrations.manychat.create_custom_field({
caption = "Lead status",
type = "text",
description = "CRM qualification status"
})
local bot_fields = app.integrations.manychat.list_bot_fields({})
app.integrations.manychat.set_bot_field({
field_id = 456,
field_value = "open"
})
Sending
Use send_content for direct content payloads and send_flow to trigger an existing automation flow.
local sent = app.integrations.manychat.send_content({
subscriber_id = 123456,
data = {
version = "v2",
content = {
type = "text",
messages = {
{type = "text", text = "Hello from an agent"}
}
}
}
})
local flow = app.integrations.manychat.send_flow({
subscriber_id = 123456,
flow_ns = "content20260101000000"
})
send_message remains as a compatibility alias for older scripts. New scripts should use send_content.
Subscribers
local subscriber = app.integrations.manychat.get_subscriber_info({
subscriber_id = 123456
})
local matches = app.integrations.manychat.find_subscriber_by_name({
name = "Example User"
})
app.integrations.manychat.add_subscriber_tag({
subscriber_id = 123456,
tag_id = 111
})
app.integrations.manychat.remove_subscriber_tag({
subscriber_id = 123456,
tag_id = 111
})
app.integrations.manychat.set_subscriber_custom_field({
subscriber_id = 123456,
field_id = 222,
field_value = "qualified"
})
Create or update subscribers with the payload shape documented by Manychat:
local created = app.integrations.manychat.create_subscriber({
data = {
first_name = "Example",
last_name = "User",
email = "user@example.test",
has_opt_in_email = true
}
})
local updated = app.integrations.manychat.update_subscriber({
data = {
subscriber_id = 123456,
email = "new-address@example.test",
has_opt_in_email = true
}
})
Generic API Helpers
Use generic helpers only for documented Manychat endpoints that do not yet have a dedicated tool. path must be relative to the configured API base URL; absolute URLs are rejected.
local topics = app.integrations.manychat.api_get({
path = "/fb/page/getOtnTopics"
})
local tagged = app.integrations.manychat.api_post({
path = "/fb/subscriber/addTagByName",
body = {
subscriber_id = 123456,
tag_name = "VIP"
}
})
Multi-Account Usage
app.integrations.manychat.list_flows({})
app.integrations.manychat.default.list_flows({})
app.integrations.manychat.work.add_subscriber_tag({
subscriber_id = 123456,
tag_id = 111
})
The function names are identical across accounts; only stored API keys differ.
Raw agent markdown
# Manychat - Lua API Reference
Namespace: `app.integrations.manychat`
Use this integration for Manychat Account Public API operations. Responses are decoded Manychat JSON. Most endpoints return a top-level `status` and `data` object or list.
## Account And Flows
```lua
local page = app.integrations.manychat.get_page_info({})
local flows = app.integrations.manychat.list_flows({})
```
`get_flow` is a compatibility helper. Manychat documents `getFlows`, not a single-flow endpoint, so this tool searches the list response by namespace or ID.
```lua
local flow = app.integrations.manychat.get_flow({page_id = "content20260101000000"})
```
## Tags
```lua
local tags = app.integrations.manychat.list_tags({})
local created = app.integrations.manychat.create_tag({
name = "VIP"
})
app.integrations.manychat.remove_tag({tag_id = 123})
app.integrations.manychat.remove_tag_by_name({tag_name = "VIP"})
```
## Fields
```lua
local custom_fields = app.integrations.manychat.list_custom_fields({})
local field = app.integrations.manychat.create_custom_field({
caption = "Lead status",
type = "text",
description = "CRM qualification status"
})
local bot_fields = app.integrations.manychat.list_bot_fields({})
app.integrations.manychat.set_bot_field({
field_id = 456,
field_value = "open"
})
```
## Sending
Use `send_content` for direct content payloads and `send_flow` to trigger an existing automation flow.
```lua
local sent = app.integrations.manychat.send_content({
subscriber_id = 123456,
data = {
version = "v2",
content = {
type = "text",
messages = {
{type = "text", text = "Hello from an agent"}
}
}
}
})
local flow = app.integrations.manychat.send_flow({
subscriber_id = 123456,
flow_ns = "content20260101000000"
})
```
`send_message` remains as a compatibility alias for older scripts. New scripts should use `send_content`.
## Subscribers
```lua
local subscriber = app.integrations.manychat.get_subscriber_info({
subscriber_id = 123456
})
local matches = app.integrations.manychat.find_subscriber_by_name({
name = "Example User"
})
app.integrations.manychat.add_subscriber_tag({
subscriber_id = 123456,
tag_id = 111
})
app.integrations.manychat.remove_subscriber_tag({
subscriber_id = 123456,
tag_id = 111
})
app.integrations.manychat.set_subscriber_custom_field({
subscriber_id = 123456,
field_id = 222,
field_value = "qualified"
})
```
Create or update subscribers with the payload shape documented by Manychat:
```lua
local created = app.integrations.manychat.create_subscriber({
data = {
first_name = "Example",
last_name = "User",
email = "user@example.test",
has_opt_in_email = true
}
})
local updated = app.integrations.manychat.update_subscriber({
data = {
subscriber_id = 123456,
email = "new-address@example.test",
has_opt_in_email = true
}
})
```
## Generic API Helpers
Use generic helpers only for documented Manychat endpoints that do not yet have a dedicated tool. `path` must be relative to the configured API base URL; absolute URLs are rejected.
```lua
local topics = app.integrations.manychat.api_get({
path = "/fb/page/getOtnTopics"
})
local tagged = app.integrations.manychat.api_post({
path = "/fb/subscriber/addTagByName",
body = {
subscriber_id = 123456,
tag_name = "VIP"
}
})
```
## Multi-Account Usage
```lua
app.integrations.manychat.list_flows({})
app.integrations.manychat.default.list_flows({})
app.integrations.manychat.work.add_subscriber_tag({
subscriber_id = 123456,
tag_id = 111
})
```
The function names are identical across accounts; only stored API keys differ. local result = app.integrations.manychat.get_page_info({})
print(result) Functions
get_page_info Read
Get Manychat page/account information.
- Lua path
app.integrations.manychat.get_page_info- Full name
manychat.manychat_get_page_info
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
get_current_user Read
Get the currently authenticated ManyChat user profile. Returns account details, plan info, and connected channels.
- Lua path
app.integrations.manychat.get_current_user- Full name
manychat.manychat_get_current_user
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
list_flows Read
List all flows (pages) in your ManyChat account. Returns flow IDs and names that can be used with get_flow.
- Lua path
app.integrations.manychat.list_flows- Full name
manychat.manychat_list_flows
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
get_flow Read
Get details of a specific ManyChat flow (page) by ID. Returns the full flow configuration including nodes and content.
- Lua path
app.integrations.manychat.get_flow- Full name
manychat.manychat_get_flow
| Parameter | Type | Required | Description |
|---|---|---|---|
page_id | string | yes | Flow namespace or ID to find in the getFlows response. |
list_tags Read
List all tags in your ManyChat account. Tags are used to segment subscribers and trigger automations.
- Lua path
app.integrations.manychat.list_tags- Full name
manychat.manychat_list_tags
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
create_tag Write
Create a new tag in ManyChat. Tags help segment subscribers for targeted messaging and automation.
- Lua path
app.integrations.manychat.create_tag- Full name
manychat.manychat_create_tag
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | yes | The name for the new tag (e.g., "VIP Customer", "Newsletter Subscriber"). |
remove_tag Write
Remove a bot tag by ID.
- Lua path
app.integrations.manychat.remove_tag- Full name
manychat.manychat_remove_tag
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
remove_tag_by_name Write
Remove a bot tag by name.
- Lua path
app.integrations.manychat.remove_tag_by_name- Full name
manychat.manychat_remove_tag_by_name
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
list_growth_tools Read
List growth tools.
- Lua path
app.integrations.manychat.list_growth_tools- Full name
manychat.manychat_list_growth_tools
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
list_custom_fields Read
List custom user fields.
- Lua path
app.integrations.manychat.list_custom_fields- Full name
manychat.manychat_list_custom_fields
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
create_custom_field Write
Create a custom user field.
- Lua path
app.integrations.manychat.create_custom_field- Full name
manychat.manychat_create_custom_field
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
list_bot_fields Read
List bot fields.
- Lua path
app.integrations.manychat.list_bot_fields- Full name
manychat.manychat_list_bot_fields
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
set_bot_field Write
Set a bot field by ID.
- Lua path
app.integrations.manychat.set_bot_field- Full name
manychat.manychat_set_bot_field
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
send_message Write
Send a message via ManyChat to a subscriber on Instagram, Messenger, WhatsApp, or SMS. Requires a subscriber ID and message content.
- Lua path
app.integrations.manychat.send_message- Full name
manychat.manychat_send_message
| Parameter | Type | Required | Description |
|---|---|---|---|
subscriber_id | string | yes | The ManyChat subscriber ID to send the message to. |
message | object | yes | The message payload to send. Can include text, buttons, cards, or other supported message types. |
message_type | string | no | The messaging channel: "instagram", "messenger", "whatsapp", or "sms". Defaults to the subscriber's primary channel. |
send_content Write
Send content to a subscriber.
- Lua path
app.integrations.manychat.send_content- Full name
manychat.manychat_send_content
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
send_flow Write
Send a flow to a subscriber.
- Lua path
app.integrations.manychat.send_flow- Full name
manychat.manychat_send_flow
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
get_subscriber_info Read
Get subscriber info by ID.
- Lua path
app.integrations.manychat.get_subscriber_info- Full name
manychat.manychat_get_subscriber_info
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
find_subscriber_by_name Read
Find subscribers by name.
- Lua path
app.integrations.manychat.find_subscriber_by_name- Full name
manychat.manychat_find_subscriber_by_name
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
add_subscriber_tag Write
Add a tag to a subscriber.
- Lua path
app.integrations.manychat.add_subscriber_tag- Full name
manychat.manychat_add_subscriber_tag
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
remove_subscriber_tag Write
Remove a tag from a subscriber.
- Lua path
app.integrations.manychat.remove_subscriber_tag- Full name
manychat.manychat_remove_subscriber_tag
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
set_subscriber_custom_field Write
Set one subscriber custom field.
- Lua path
app.integrations.manychat.set_subscriber_custom_field- Full name
manychat.manychat_set_subscriber_custom_field
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
create_subscriber Write
Create a subscriber.
- Lua path
app.integrations.manychat.create_subscriber- Full name
manychat.manychat_create_subscriber
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
update_subscriber Write
Update a subscriber.
- Lua path
app.integrations.manychat.update_subscriber- Full name
manychat.manychat_update_subscriber
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
api_get Read
Call a documented GET endpoint.
- Lua path
app.integrations.manychat.api_get- Full name
manychat.manychat_api_get
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
api_post Write
Call a documented POST endpoint.
- Lua path
app.integrations.manychat.api_post- Full name
manychat.manychat_api_post
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||