KosmoKrator

productivity

Knock Lua API for KosmoKrator Agents

Agent-facing Lua documentation and function reference for the Knock KosmoKrator integration.

Lua Namespace

Agents call this integration through app.integrations.knock.*. Use lua_read_doc("integrations.knock") 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 Knock workflow without starting an interactive agent session.

Inline Lua call
kosmo integrations:lua --eval 'dump(app.integrations.knock.list_workflows({limit = 1, page = 1}))' --json
Read Lua docs headlessly
kosmo integrations:lua --eval 'print(docs.read("knock"))' --json
kosmo integrations:lua --eval 'print(docs.read("knock.list_workflows"))' --json

Workflow file

Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.

workflow.lua
local knock = app.integrations.knock
local result = knock.list_workflows({limit = 1, page = 1})

dump(result)
Run the workflow
kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json
Namespace note. integrations:lua exposes app.integrations.knock, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.knock.default.* or app.integrations.knock.work.* when you configured named credential accounts.

MCP-only Lua

If the script only needs configured MCP servers and does not need Knock, use the narrower mcp:lua command.

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.

Knock — Lua API Reference

list_workflows

List notification workflows from Knock.

Parameters

NameTypeRequiredDescription
limitintegernoMaximum number of workflows to return (default: 25)
pageintegernoPage number for pagination

Example

local result = app.integrations.knock.list_workflows({
  limit = 10,
  page = 1
})

for _, workflow in ipairs(result.data) do
  print(workflow.id .. ": " .. workflow.name)
end

get_workflow

Get details of a specific notification workflow.

Parameters

NameTypeRequiredDescription
idstringyesThe workflow ID

Example

local result = app.integrations.knock.get_workflow({
  id = "welcome-flow"
})

print("Workflow: " .. result.name)
print("Steps: " .. #result.steps)

trigger_workflow

Trigger a notification workflow for one or more recipients.

Parameters

NameTypeRequiredDescription
idstringyesThe workflow ID to trigger
recipientsarrayyesArray of recipient identifiers (user IDs or emails)
dataobjectnoPayload data for template merge variables
cancellation_criteriaobjectnoCancellation criteria for the workflow run

Example

local result = app.integrations.knock.trigger_workflow({
  id = "welcome",
  recipients = { "user-123", "user-456" },
  data = {
    name = "John",
    company = "Acme"
  }
})

print("Workflow run ID: " .. result.id)

With cancellation criteria

local result = app.integrations.knock.trigger_workflow({
  id = "order-confirmation",
  recipients = { "user-123" },
  data = {
    order_id = "ORD-001"
  },
  cancellation_criteria = {
    key = "order_id",
    criteria = "ORD-001"
  }
})

list_messages

List notification messages, optionally filtered by status.

Parameters

NameTypeRequiredDescription
limitintegernoMaximum number of messages to return (default: 25)
pageintegernoPage number for pagination
statusstringnoFilter by status: sent, delivered, undelivered, opened

Example

local result = app.integrations.knock.list_messages({
  limit = 10,
  status = "delivered"
})

for _, msg in ipairs(result.data) do
  print(msg.id .. " -> " .. msg.status)
end

get_message

Get details of a specific notification message.

Parameters

NameTypeRequiredDescription
idstringyesThe message ID

Example

local result = app.integrations.knock.get_message({
  id = "msg-abc123"
})

print("Status: " .. result.status)
print("Channel: " .. result.channel_id)

list_recipients

List notification recipients.

Parameters

NameTypeRequiredDescription
limitintegernoMaximum number of recipients to return (default: 25)
pageintegernoPage number for pagination

Example

local result = app.integrations.knock.list_recipients({
  limit = 50
})

for _, recipient in ipairs(result.data) do
  print(recipient.id .. ": " .. (recipient.email or "no email"))
end

get_current_user

Get the currently authenticated Knock user. Useful for verifying credentials.

Parameters

None.

Example

local result = app.integrations.knock.get_current_user({})

print("User: " .. result.name)
print("Email: " .. result.email)

Multi-Account Usage

If you have multiple Knock accounts configured, use account-specific namespaces:

-- Default account (always works)
app.integrations.knock.function_name({...})

-- Explicit default (portable across setups)
app.integrations.knock.default.function_name({...})

-- Named accounts
app.integrations.knock.production.function_name({...})
app.integrations.knock.staging.function_name({...})

All functions are identical across accounts — only the credentials differ.

Raw agent markdown
# Knock — Lua API Reference

## list_workflows

List notification workflows from Knock.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of workflows to return (default: 25) |
| `page` | integer | no | Page number for pagination |

### Example

```lua
local result = app.integrations.knock.list_workflows({
  limit = 10,
  page = 1
})

for _, workflow in ipairs(result.data) do
  print(workflow.id .. ": " .. workflow.name)
end
```

---

## get_workflow

Get details of a specific notification workflow.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The workflow ID |

### Example

```lua
local result = app.integrations.knock.get_workflow({
  id = "welcome-flow"
})

print("Workflow: " .. result.name)
print("Steps: " .. #result.steps)
```

---

## trigger_workflow

Trigger a notification workflow for one or more recipients.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The workflow ID to trigger |
| `recipients` | array | yes | Array of recipient identifiers (user IDs or emails) |
| `data` | object | no | Payload data for template merge variables |
| `cancellation_criteria` | object | no | Cancellation criteria for the workflow run |

### Example

```lua
local result = app.integrations.knock.trigger_workflow({
  id = "welcome",
  recipients = { "user-123", "user-456" },
  data = {
    name = "John",
    company = "Acme"
  }
})

print("Workflow run ID: " .. result.id)
```

### With cancellation criteria

```lua
local result = app.integrations.knock.trigger_workflow({
  id = "order-confirmation",
  recipients = { "user-123" },
  data = {
    order_id = "ORD-001"
  },
  cancellation_criteria = {
    key = "order_id",
    criteria = "ORD-001"
  }
})
```

---

## list_messages

List notification messages, optionally filtered by status.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of messages to return (default: 25) |
| `page` | integer | no | Page number for pagination |
| `status` | string | no | Filter by status: sent, delivered, undelivered, opened |

### Example

```lua
local result = app.integrations.knock.list_messages({
  limit = 10,
  status = "delivered"
})

for _, msg in ipairs(result.data) do
  print(msg.id .. " -> " .. msg.status)
end
```

---

## get_message

Get details of a specific notification message.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The message ID |

### Example

```lua
local result = app.integrations.knock.get_message({
  id = "msg-abc123"
})

print("Status: " .. result.status)
print("Channel: " .. result.channel_id)
```

---

## list_recipients

List notification recipients.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of recipients to return (default: 25) |
| `page` | integer | no | Page number for pagination |

### Example

```lua
local result = app.integrations.knock.list_recipients({
  limit = 50
})

for _, recipient in ipairs(result.data) do
  print(recipient.id .. ": " .. (recipient.email or "no email"))
end
```

---

## get_current_user

Get the currently authenticated Knock user. Useful for verifying credentials.

### Parameters

None.

### Example

```lua
local result = app.integrations.knock.get_current_user({})

print("User: " .. result.name)
print("Email: " .. result.email)
```

---

## Multi-Account Usage

If you have multiple Knock accounts configured, use account-specific namespaces:

```lua
-- Default account (always works)
app.integrations.knock.function_name({...})

-- Explicit default (portable across setups)
app.integrations.knock.default.function_name({...})

-- Named accounts
app.integrations.knock.production.function_name({...})
app.integrations.knock.staging.function_name({...})
```

All functions are identical across accounts — only the credentials differ.
Metadata-derived Lua example
local result = app.integrations.knock.list_workflows({limit = 1, page = 1})
print(result)

Functions

list_workflows Read

List notification workflows from Knock. Returns workflow IDs and details you can use to trigger or inspect workflows.

Lua path
app.integrations.knock.list_workflows
Full name
knock.knock_list_workflows
ParameterTypeRequiredDescription
limit integer no Maximum number of workflows to return (default: 25).
page integer no Page number for pagination.
get_workflow Read

Get details of a specific notification workflow in Knock, including its steps and configuration.

Lua path
app.integrations.knock.get_workflow
Full name
knock.knock_get_workflow
ParameterTypeRequiredDescription
id string yes The workflow ID.
trigger_workflow Write

Trigger a notification workflow in Knock for one or more recipients. The workflow will execute its configured steps (email, Slack, in-app, etc.) for each recipient.

Lua path
app.integrations.knock.trigger_workflow
Full name
knock.knock_trigger_workflow
ParameterTypeRequiredDescription
id string yes The workflow ID to trigger.
recipients array yes Array of recipient identifiers (user IDs or emails) to receive the notification.
data array no Payload data to pass to the workflow. Used in notification templates as merge variables.
cancellation_criteria array no Cancellation criteria for the workflow run. Allows automatic cancellation based on conditions.
list_messages Read

List notification messages from Knock. Optionally filter by delivery status (e.g., sent, delivered, undelivered).

Lua path
app.integrations.knock.list_messages
Full name
knock.knock_list_messages
ParameterTypeRequiredDescription
limit integer no Maximum number of messages to return (default: 25).
page integer no Page number for pagination.
status string no Filter by message status: sent, delivered, undelivered, or opened.
get_message Read

Get details of a specific notification message in Knock, including its content, delivery status, and channel.

Lua path
app.integrations.knock.get_message
Full name
knock.knock_get_message
ParameterTypeRequiredDescription
id string yes The message ID.
list_recipients Read

List notification recipients from Knock. Returns recipient identifiers and their preferences.

Lua path
app.integrations.knock.list_recipients
Full name
knock.knock_list_recipients
ParameterTypeRequiredDescription
limit integer no Maximum number of recipients to return (default: 25).
page integer no Page number for pagination.
get_current_user Read

Get the currently authenticated Knock user. Useful for verifying API credentials and inspecting account details.

Lua path
app.integrations.knock.get_current_user
Full name
knock.knock_get_current_user
ParameterTypeRequiredDescription
No parameters.