KosmoKrator

communication

Knock Lua API for KosmoKrator Agents

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

7 functions 6 read 1 write API key auth

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.

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.knock_list_workflows({
  limit = 1,
  page = 1
})
print(result)

Functions

knock_list_workflows

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

Operation
Read read
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.

knock_get_workflow

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

Operation
Read read
Full name
knock.knock_get_workflow
ParameterTypeRequiredDescription
id string yes The workflow ID.

knock_trigger_workflow

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.

Operation
Write write
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.

knock_list_messages

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

Operation
Read read
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.

knock_get_message

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

Operation
Read read
Full name
knock.knock_get_message
ParameterTypeRequiredDescription
id string yes The message ID.

knock_list_recipients

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

Operation
Read read
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.

knock_get_current_user

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

Operation
Read read
Full name
knock.knock_get_current_user
ParameterTypeRequiredDescription
No parameters.