KosmoKrator

other

Helpscout Lua API for KosmoKrator Agents

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

10 functions 7 read 3 write Bearer token auth

Lua Namespace

Agents call this integration through app.integrations.helpscout.*. Use lua_read_doc("integrations.helpscout") 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.

HelpScout — Lua API Reference

list_conversations

List support conversations with optional filters.

Parameters

NameTypeRequiredDescription
mailboxintegernoFilter by mailbox ID
statusstringnoFilter by status: "open", "closed", "pending", "spam", "all"
assigneeintegernoFilter by assigned user ID (0 for unassigned)
customerintegernoFilter by customer ID
tagstringnoFilter by tag name
pageintegernoPage number (default: 1)
per_pageintegernoResults per page (default: 25, max: 50)
sort_fieldstringnoSort by: createdAt, updatedAt, customer.name, subject, status, mailbox
sort_orderstringnoSort direction: "asc" or "desc" (default: "desc")
querystringnoSearch query to filter by keyword

Example

local result = app.integrations.helpscout.list_conversations({
  status = "open",
  mailbox = 123,
  per_page = 10
})

for _, conv in ipairs(result._embedded.conversations) do
  print(conv.id .. ": " .. conv.subject .. " (" .. conv.status .. ")")
end

get_conversation

Get full details of a specific conversation.

Parameters

NameTypeRequiredDescription
idintegeryesThe conversation ID

Example

local conv = app.integrations.helpscout.get_conversation({ id = 456 })
print("Subject: " .. conv.subject)
print("Status: " .. conv.status)
print("Customer: " .. conv._embedded.customer.firstName .. " " .. conv._embedded.customer.lastName)

create_conversation

Create a new support conversation.

Parameters

NameTypeRequiredDescription
subjectstringyesConversation subject line
mailbox_idintegeryesMailbox ID to create the conversation in
customer_idintegerno*Customer ID (required unless customer_email is provided)
customer_emailstringno*Customer email (used if customer_id is not provided)
bodystringyesContent of the first message
typestringno"email" (default) or "chat"
statusstringno"open" (default), "pending", or "closed"
assignee_idintegernoUser ID to assign to
tagsarraynoArray of tag names
ccarraynoArray of email addresses to CC
bccarraynoArray of email addresses to BCC

Example

local result = app.integrations.helpscout.create_conversation({
  subject = "Billing question",
  mailbox_id = 123,
  customer_email = "[email protected]",
  body = "I have a question about my latest invoice.",
  tags = { "billing", "priority" }
})

print("Created conversation: " .. result.id)

update_conversation

Update an existing conversation.

Parameters

NameTypeRequiredDescription
idintegeryesThe conversation ID to update
statusstringnoNew status: "open", "closed", "pending", "spam"
subjectstringnoUpdated subject line
assignee_idintegernoUser ID to assign (0 to unassign)
mailbox_idintegernoMove to a different mailbox
tagsarraynoReplace all tags (array of strings)

Example

app.integrations.helpscout.update_conversation({
  id = 456,
  status = "closed",
  tags = { "resolved", "billing" }
})

list_customers

List or search customers.

Parameters

NameTypeRequiredDescription
first_namestringnoFilter by first name (partial match)
last_namestringnoFilter by last name (partial match)
emailstringnoFilter by email (partial match)
pageintegernoPage number (default: 1)
per_pageintegernoResults per page (default: 25, max: 50)
sort_fieldstringnoSort by: firstName, lastName, createdAt, updatedAt
sort_orderstringnoSort direction: "asc" or "desc"
querystringnoSearch query to filter by keyword

Example

local result = app.integrations.helpscout.list_customers({
  email = "[email protected]"
})

for _, customer in ipairs(result._embedded.customers) do
  print(customer.id .. ": " .. customer.firstName .. " " .. customer.lastName)
end

get_customer

Get details of a specific customer.

Parameters

NameTypeRequiredDescription
idintegeryesThe customer ID

Example

local customer = app.integrations.helpscout.get_customer({ id = 789 })
print(customer.firstName .. " " .. customer.lastName)
print("Email: " .. customer._embedded.emails[1].value)

create_customer

Create a new customer.

Parameters

NameTypeRequiredDescription
first_namestringnoFirst name
last_namestringnoLast name
emailstringnoPrimary email address
organizationstringnoCompany or organization name
job_titlestringnoJob title
phonestringnoPhone number

At least one of first_name, last_name, or email is required.

Example

local result = app.integrations.helpscout.create_customer({
  first_name = "Jane",
  last_name = "Doe",
  email = "[email protected]",
  organization = "Acme Corp"
})

print("Created customer: " .. result.id)

list_mailboxes

List all mailboxes.

Parameters

NameTypeRequiredDescription
pageintegernoPage number (default: 1)
per_pageintegernoResults per page (default: 25, max: 50)

Example

local result = app.integrations.helpscout.list_mailboxes({})

for _, mailbox in ipairs(result._embedded.mailboxes) do
  print(mailbox.id .. ": " .. mailbox.name .. " (" .. mailbox.email .. ")")
end

get_mailbox

Get details of a specific mailbox.

Parameters

NameTypeRequiredDescription
idintegeryesThe mailbox ID

Example

local mailbox = app.integrations.helpscout.get_mailbox({ id = 123 })
print("Mailbox: " .. mailbox.name)
print("Email: " .. mailbox.email)

get_current_user

Get the profile of the currently authenticated user.

Parameters

None.

Example

local user = app.integrations.helpscout.get_current_user({})
print("Logged in as: " .. user.firstName .. " " .. user.lastName)
print("Email: " .. user.email)
print("Role: " .. user.role)

Multi-Account Usage

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

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

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

-- Named accounts
app.integrations.helpscout.work.function_name({...})
app.integrations.helpscout.support.function_name({...})

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

Raw agent markdown
# HelpScout — Lua API Reference

## list_conversations

List support conversations with optional filters.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `mailbox` | integer | no | Filter by mailbox ID |
| `status` | string | no | Filter by status: `"open"`, `"closed"`, `"pending"`, `"spam"`, `"all"` |
| `assignee` | integer | no | Filter by assigned user ID (0 for unassigned) |
| `customer` | integer | no | Filter by customer ID |
| `tag` | string | no | Filter by tag name |
| `page` | integer | no | Page number (default: 1) |
| `per_page` | integer | no | Results per page (default: 25, max: 50) |
| `sort_field` | string | no | Sort by: `createdAt`, `updatedAt`, `customer.name`, `subject`, `status`, `mailbox` |
| `sort_order` | string | no | Sort direction: `"asc"` or `"desc"` (default: `"desc"`) |
| `query` | string | no | Search query to filter by keyword |

### Example

```lua
local result = app.integrations.helpscout.list_conversations({
  status = "open",
  mailbox = 123,
  per_page = 10
})

for _, conv in ipairs(result._embedded.conversations) do
  print(conv.id .. ": " .. conv.subject .. " (" .. conv.status .. ")")
end
```

---

## get_conversation

Get full details of a specific conversation.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | integer | yes | The conversation ID |

### Example

```lua
local conv = app.integrations.helpscout.get_conversation({ id = 456 })
print("Subject: " .. conv.subject)
print("Status: " .. conv.status)
print("Customer: " .. conv._embedded.customer.firstName .. " " .. conv._embedded.customer.lastName)
```

---

## create_conversation

Create a new support conversation.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `subject` | string | yes | Conversation subject line |
| `mailbox_id` | integer | yes | Mailbox ID to create the conversation in |
| `customer_id` | integer | no* | Customer ID (required unless `customer_email` is provided) |
| `customer_email` | string | no* | Customer email (used if `customer_id` is not provided) |
| `body` | string | yes | Content of the first message |
| `type` | string | no | `"email"` (default) or `"chat"` |
| `status` | string | no | `"open"` (default), `"pending"`, or `"closed"` |
| `assignee_id` | integer | no | User ID to assign to |
| `tags` | array | no | Array of tag names |
| `cc` | array | no | Array of email addresses to CC |
| `bcc` | array | no | Array of email addresses to BCC |

### Example

```lua
local result = app.integrations.helpscout.create_conversation({
  subject = "Billing question",
  mailbox_id = 123,
  customer_email = "[email protected]",
  body = "I have a question about my latest invoice.",
  tags = { "billing", "priority" }
})

print("Created conversation: " .. result.id)
```

---

## update_conversation

Update an existing conversation.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | integer | yes | The conversation ID to update |
| `status` | string | no | New status: `"open"`, `"closed"`, `"pending"`, `"spam"` |
| `subject` | string | no | Updated subject line |
| `assignee_id` | integer | no | User ID to assign (0 to unassign) |
| `mailbox_id` | integer | no | Move to a different mailbox |
| `tags` | array | no | Replace all tags (array of strings) |

### Example

```lua
app.integrations.helpscout.update_conversation({
  id = 456,
  status = "closed",
  tags = { "resolved", "billing" }
})
```

---

## list_customers

List or search customers.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `first_name` | string | no | Filter by first name (partial match) |
| `last_name` | string | no | Filter by last name (partial match) |
| `email` | string | no | Filter by email (partial match) |
| `page` | integer | no | Page number (default: 1) |
| `per_page` | integer | no | Results per page (default: 25, max: 50) |
| `sort_field` | string | no | Sort by: `firstName`, `lastName`, `createdAt`, `updatedAt` |
| `sort_order` | string | no | Sort direction: `"asc"` or `"desc"` |
| `query` | string | no | Search query to filter by keyword |

### Example

```lua
local result = app.integrations.helpscout.list_customers({
  email = "[email protected]"
})

for _, customer in ipairs(result._embedded.customers) do
  print(customer.id .. ": " .. customer.firstName .. " " .. customer.lastName)
end
```

---

## get_customer

Get details of a specific customer.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | integer | yes | The customer ID |

### Example

```lua
local customer = app.integrations.helpscout.get_customer({ id = 789 })
print(customer.firstName .. " " .. customer.lastName)
print("Email: " .. customer._embedded.emails[1].value)
```

---

## create_customer

Create a new customer.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `first_name` | string | no | First name |
| `last_name` | string | no | Last name |
| `email` | string | no | Primary email address |
| `organization` | string | no | Company or organization name |
| `job_title` | string | no | Job title |
| `phone` | string | no | Phone number |

At least one of `first_name`, `last_name`, or `email` is required.

### Example

```lua
local result = app.integrations.helpscout.create_customer({
  first_name = "Jane",
  last_name = "Doe",
  email = "[email protected]",
  organization = "Acme Corp"
})

print("Created customer: " .. result.id)
```

---

## list_mailboxes

List all mailboxes.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `page` | integer | no | Page number (default: 1) |
| `per_page` | integer | no | Results per page (default: 25, max: 50) |

### Example

```lua
local result = app.integrations.helpscout.list_mailboxes({})

for _, mailbox in ipairs(result._embedded.mailboxes) do
  print(mailbox.id .. ": " .. mailbox.name .. " (" .. mailbox.email .. ")")
end
```

---

## get_mailbox

Get details of a specific mailbox.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | integer | yes | The mailbox ID |

### Example

```lua
local mailbox = app.integrations.helpscout.get_mailbox({ id = 123 })
print("Mailbox: " .. mailbox.name)
print("Email: " .. mailbox.email)
```

---

## get_current_user

Get the profile of the currently authenticated user.

### Parameters

None.

### Example

```lua
local user = app.integrations.helpscout.get_current_user({})
print("Logged in as: " .. user.firstName .. " " .. user.lastName)
print("Email: " .. user.email)
print("Role: " .. user.role)
```

---

## Multi-Account Usage

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

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

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

-- Named accounts
app.integrations.helpscout.work.function_name({...})
app.integrations.helpscout.support.function_name({...})
```

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

Metadata-Derived Lua Example

local result = app.integrations.helpscout.helpscout_list_conversations({
  mailbox = 1,
  status = "example_status",
  assignee = 1,
  customer = 1,
  tag = "example_tag",
  page = 1,
  per_page = 1,
  sort_field = "example_sort_field"
})
print(result)

Functions

helpscout_list_conversations

List support conversations from HelpScout. Supports filtering by mailbox, status, assignee, customer, and more. Returns paginated results.

Operation
Read read
Full name
helpscout.helpscout_list_conversations
ParameterTypeRequiredDescription
mailbox integer no Filter by mailbox ID.
status string no Filter by status: "open", "closed", "pending", "spam", "all". Defaults to "all".
assignee integer no Filter by assigned user ID. Use 0 for unassigned.
customer integer no Filter by customer ID.
tag string no Filter by tag name.
page integer no Page number for pagination (default: 1).
per_page integer no Number of results per page (default: 25, max: 50).
sort_field string no Sort field: "createdAt", "updatedAt", "customer.name", "subject", "status", "mailbox".
sort_order string no Sort direction: "asc" or "desc" (default: "desc").
query string no Search query to filter conversations by keyword.

helpscout_get_conversation

Get full details of a specific HelpScout conversation, including threads, customer info, and custom fields.

Operation
Read read
Full name
helpscout.helpscout_get_conversation
ParameterTypeRequiredDescription
id integer yes The conversation ID.

helpscout_create_conversation

Create a new conversation in HelpScout. Requires a subject, customer, mailbox, and at least one thread (message or note).

Operation
Write write
Full name
helpscout.helpscout_create_conversation
ParameterTypeRequiredDescription
subject string yes The conversation subject line.
mailbox_id integer yes The mailbox ID to create the conversation in.
customer_id integer no The customer ID. Required unless customer_email is provided.
customer_email string no Customer email address. Used if customer_id is not provided.
body string yes The content of the first message in the conversation.
type string no Conversation type: "email" (default) or "chat".
status string no Initial status: "open" (default), "pending", or "closed".
assignee_id integer no User ID to assign the conversation to.
tags array no Array of tag names to apply.
cc array no Array of email addresses to CC.
bcc array no Array of email addresses to BCC.

helpscout_update_conversation

Update an existing HelpScout conversation. Change status, assignee, tags, subject, or other fields.

Operation
Write write
Full name
helpscout.helpscout_update_conversation
ParameterTypeRequiredDescription
id integer yes The conversation ID to update.
status string no New status: "open", "closed", "pending", or "spam".
subject string no Updated subject line.
assignee_id integer no User ID to assign. Use 0 to unassign.
mailbox_id integer no Move to a different mailbox.
tags array no Replace all tags (array of strings).

helpscout_list_customers

List or search customers in HelpScout. Supports filtering by name, email, and pagination.

Operation
Read read
Full name
helpscout.helpscout_list_customers
ParameterTypeRequiredDescription
first_name string no Filter by first name (partial match).
last_name string no Filter by last name (partial match).
email string no Filter by email address (partial match).
page integer no Page number for pagination (default: 1).
per_page integer no Number of results per page (default: 25, max: 50).
sort_field string no Sort field: "firstName", "lastName", "createdAt", "updatedAt".
sort_order string no Sort direction: "asc" or "desc" (default: "asc").
query string no Search query to filter customers by keyword.

helpscout_get_customer

Get full details of a specific HelpScout customer, including contact info, social profiles, and custom fields.

Operation
Read read
Full name
helpscout.helpscout_get_customer
ParameterTypeRequiredDescription
id integer yes The customer ID.

helpscout_create_customer

Create a new customer in HelpScout. Provide at least a name or email address.

Operation
Write write
Full name
helpscout.helpscout_create_customer
ParameterTypeRequiredDescription
first_name string no Customer first name.
last_name string no Customer last name.
email string no Primary email address for the customer.
organization string no Company or organization name.
job_title string no Job title.
phone string no Phone number.

helpscout_list_mailboxes

List all mailboxes in HelpScout. Returns mailbox IDs, names, and email addresses. Use mailbox IDs when creating or filtering conversations.

Operation
Read read
Full name
helpscout.helpscout_list_mailboxes
ParameterTypeRequiredDescription
page integer no Page number for pagination (default: 1).
per_page integer no Number of results per page (default: 25, max: 50).

helpscout_get_mailbox

Get details of a specific HelpScout mailbox, including name, email, folders, and user assignments.

Operation
Read read
Full name
helpscout.helpscout_get_mailbox
ParameterTypeRequiredDescription
id integer yes The mailbox ID.

helpscout_get_current_user

Get the profile of the currently authenticated HelpScout user. Useful for verifying API connectivity and identifying the active account.

Operation
Read read
Full name
helpscout.helpscout_get_current_user
ParameterTypeRequiredDescription
No parameters.