KosmoKrator

productivity

Intercom Lua API for KosmoKrator Agents

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

Lua Namespace

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

Inline Lua call
kosmo integrations:lua --eval 'dump(app.integrations.intercom.list_conversations({limit = 1, starting_after = "example_starting_after", sort_order = "example_sort_order", status = "example_status"}))' --json
Read Lua docs headlessly
kosmo integrations:lua --eval 'print(docs.read("intercom"))' --json
kosmo integrations:lua --eval 'print(docs.read("intercom.list_conversations"))' --json

Workflow file

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

workflow.lua
local intercom = app.integrations.intercom
local result = intercom.list_conversations({limit = 1, starting_after = "example_starting_after", sort_order = "example_sort_order", status = "example_status"})

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.intercom, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.intercom.default.* or app.integrations.intercom.work.* when you configured named credential accounts.

MCP-only Lua

If the script only needs configured MCP servers and does not need Intercom, 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.

Client for the Intercom REST API covering conversations, contacts, and companies — Lua API Reference

intercom_list_conversations

List Intercom conversations with pagination and sorting. Returns conversation IDs, created dates, and state.

Parameters

NameTypeRequiredDescription
limitintegernoMaximum number of conversations to return (default 20).
starting_afterstringnoPagination cursor from a previous response.
sort_orderstringnoSort order: “asc” or “desc”.
statusstringnoFilter by conversation status: “open”, “closed”, or “all”.

Example

local result = app.integrations.intercom.intercom_list_conversations({
  limit = 20
  starting_after = ""
  sort_order = "desc"
})

intercom_get_conversation

Retrieve an Intercom conversation by its ID. Returns the full conversation including message parts, contacts, and metadata.

Parameters

NameTypeRequiredDescription
conversation_idstringyesIntercom conversation ID.

Example

local result = app.integrations.intercom.intercom_get_conversation({
  conversation_id = "12345"
})

intercom_create_conversation

Create a new conversation in Intercom. Requires a user_id (Intercom contact ID) and a message body. Returns the created conversation with its ID.

Parameters

NameTypeRequiredDescription
user_idstringyesIntercom contact ID (user) to create the conversation for.
bodystringyesInitial message body for the conversation.

Example

local result = app.integrations.intercom.intercom_create_conversation({
  user_id = "67890"
  body = "Hello, I need help with my account."
})

intercom_list_contacts

List Intercom contacts with pagination. Returns contact IDs, emails, names, and roles.

Parameters

NameTypeRequiredDescription
limitintegernoMaximum number of contacts to return (default 20).
starting_afterstringnoPagination cursor from a previous response.

Example

local result = app.integrations.intercom.intercom_list_contacts({
  limit = 20
  starting_after = ""
})

intercom_get_contact

Retrieve an Intercom contact by its ID. Returns the contact’s ID, email, name, phone, role, and custom attributes.

Parameters

NameTypeRequiredDescription
contact_idstringyesIntercom contact ID.

Example

local result = app.integrations.intercom.intercom_get_contact({
  contact_id = "67890"
})

intercom_list_companies

List Intercom companies with pagination. Returns company IDs, names, employee counts, and industry.

Parameters

NameTypeRequiredDescription
limitintegernoMaximum number of companies to return (default 20).
starting_afterstringnoPagination cursor from a previous response.

Example

local result = app.integrations.intercom.intercom_list_companies({
  limit = 20
  starting_after = ""
})

intercom_get_current_user

Retrieve the currently authenticated Intercom admin user. Returns the admin’s ID, name, email, and avatar. Useful for identifying which workspace or token is in use.

Example

local result = app.integrations.intercom.intercom_get_current_user({
})

Multi-Account Usage

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

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

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

-- Named accounts
app.integrations.intercom.work.function_name({...})
app.integrations.intercom.personal.function_name({...})

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

Raw agent markdown
# Client for the Intercom REST API covering conversations, contacts, and companies — Lua API Reference

## intercom_list_conversations

List Intercom conversations with pagination and sorting.
Returns conversation IDs, created dates, and state.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of conversations to return (default 20). |
| `starting_after` | string | no | Pagination cursor from a previous response. |
| `sort_order` | string | no | Sort order: "asc" or "desc". |
| `status` | string | no | Filter by conversation status: "open", "closed", or "all". |

### Example

```lua
local result = app.integrations.intercom.intercom_list_conversations({
  limit = 20
  starting_after = ""
  sort_order = "desc"
})
```

## intercom_get_conversation

Retrieve an Intercom conversation by its ID.
Returns the full conversation including message parts, contacts, and metadata.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `conversation_id` | string | yes | Intercom conversation ID. |

### Example

```lua
local result = app.integrations.intercom.intercom_get_conversation({
  conversation_id = "12345"
})
```

## intercom_create_conversation

Create a new conversation in Intercom.
Requires a user_id (Intercom contact ID) and a message body.
Returns the created conversation with its ID.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `user_id` | string | yes | Intercom contact ID (user) to create the conversation for. |
| `body` | string | yes | Initial message body for the conversation. |

### Example

```lua
local result = app.integrations.intercom.intercom_create_conversation({
  user_id = "67890"
  body = "Hello, I need help with my account."
})
```

## intercom_list_contacts

List Intercom contacts with pagination.
Returns contact IDs, emails, names, and roles.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of contacts to return (default 20). |
| `starting_after` | string | no | Pagination cursor from a previous response. |

### Example

```lua
local result = app.integrations.intercom.intercom_list_contacts({
  limit = 20
  starting_after = ""
})
```

## intercom_get_contact

Retrieve an Intercom contact by its ID.
Returns the contact's ID, email, name, phone, role, and custom attributes.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `contact_id` | string | yes | Intercom contact ID. |

### Example

```lua
local result = app.integrations.intercom.intercom_get_contact({
  contact_id = "67890"
})
```

## intercom_list_companies

List Intercom companies with pagination.
Returns company IDs, names, employee counts, and industry.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of companies to return (default 20). |
| `starting_after` | string | no | Pagination cursor from a previous response. |

### Example

```lua
local result = app.integrations.intercom.intercom_list_companies({
  limit = 20
  starting_after = ""
})
```

## intercom_get_current_user

Retrieve the currently authenticated Intercom admin user.
Returns the admin's ID, name, email, and avatar.
Useful for identifying which workspace or token is in use.

### Example

```lua
local result = app.integrations.intercom.intercom_get_current_user({
})
```

---

## Multi-Account Usage

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

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

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

-- Named accounts
app.integrations.intercom.work.function_name({...})
app.integrations.intercom.personal.function_name({...})
```

All functions are identical across accounts — only the credentials differ.
Metadata-derived Lua example
local result = app.integrations.intercom.list_conversations({limit = 1, starting_after = "example_starting_after", sort_order = "example_sort_order", status = "example_status"})
print(result)

Functions

list_conversations Read

List Intercom conversations with pagination and sorting. Returns conversation IDs, created dates, and state. Use limit, starting_after, and sort_order for pagination and ordering.

Lua path
app.integrations.intercom.list_conversations
Full name
intercom.intercom_list_conversations
ParameterTypeRequiredDescription
limit integer no Maximum number of conversations to return (default 20).
starting_after string no Pagination cursor from a previous response.
sort_order string no Sort order: "asc" or "desc".
status string no Filter by conversation status: "open", "closed", or "all".
get_conversation Read

Retrieve an Intercom conversation by its ID. Returns the full conversation including message parts, contacts, and metadata.

Lua path
app.integrations.intercom.get_conversation
Full name
intercom.intercom_get_conversation
ParameterTypeRequiredDescription
conversation_id string yes Intercom conversation ID.
create_conversation Write

Create a new conversation in Intercom. Requires a user_id (Intercom contact ID) and a message body. Returns the created conversation with its ID.

Lua path
app.integrations.intercom.create_conversation
Full name
intercom.intercom_create_conversation
ParameterTypeRequiredDescription
user_id string yes Intercom contact ID (user) to create the conversation for.
body string yes Initial message body for the conversation.
list_contacts Read

List Intercom contacts with pagination. Returns contact IDs, emails, names, and roles. Use limit and starting_after for pagination.

Lua path
app.integrations.intercom.list_contacts
Full name
intercom.intercom_list_contacts
ParameterTypeRequiredDescription
limit integer no Maximum number of contacts to return (default 20).
starting_after string no Pagination cursor from a previous response.
get_contact Read

Retrieve an Intercom contact by its ID. Returns the contact's ID, email, name, phone, role, and custom attributes.

Lua path
app.integrations.intercom.get_contact
Full name
intercom.intercom_get_contact
ParameterTypeRequiredDescription
contact_id string yes Intercom contact ID.
list_companies Read

List Intercom companies with pagination. Returns company IDs, names, and employee counts. Use limit and starting_after for pagination.

Lua path
app.integrations.intercom.list_companies
Full name
intercom.intercom_list_companies
ParameterTypeRequiredDescription
limit integer no Maximum number of companies to return (default 20).
starting_after string no Pagination cursor from a previous response.
get_current_user Read

Retrieve the currently authenticated Intercom admin user. Returns the admin's ID, name, email, and avatar. Useful for identifying which workspace or token is in use.

Lua path
app.integrations.intercom.get_current_user
Full name
intercom.intercom_get_current_user
ParameterTypeRequiredDescription
No parameters.