KosmoKrator

other

Freshservice Lua API for KosmoKrator Agents

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

10 functions 7 read 3 write API key auth

Lua Namespace

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

Freshservice — Lua API Reference

list_tickets

List support tickets with optional pagination and filtering.

Parameters

NameTypeRequiredDescription
pageintegernoPage number for pagination (1-based)
per_pageintegernoNumber of tickets per page (max 100)
filterstringnoPredefined filter: "new_and_my_open", "watching", "spam", or "deleted"

Examples

-- List open tickets (first page)
local result = app.integrations.freshservice.list_tickets({
  filter = "new_and_my_open",
  per_page = 25
})

for _, ticket in ipairs(result.tickets) do
  print(ticket.id .. ": " .. ticket.subject .. " [Priority: " .. ticket.priority .. "]")
end
-- Paginate through tickets
local result = app.integrations.freshservice.list_tickets({
  page = 2,
  per_page = 50
})

get_ticket

Get full details of a specific ticket.

Parameters

NameTypeRequiredDescription
ticket_idintegeryesThe ticket display ID

Example

local result = app.integrations.freshservice.get_ticket({
  ticket_id = 42
})

local ticket = result.ticket
print("Subject: " .. ticket.subject)
print("Status: " .. ticket.status)
print("Priority: " .. ticket.priority)
print("Requester: " .. ticket.requester.email)

create_ticket

Create a new support ticket.

Parameters

NameTypeRequiredDescription
subjectstringyesThe ticket subject / title
descriptionstringyesTicket description (supports HTML)
emailstringnoEmail address of the requester
priorityintegernoPriority: 1=Low, 2=Medium, 3=High, 4=Urgent

Priority Values

ValueLevel
1Low
2Medium (default)
3High
4Urgent

Example

local result = app.integrations.freshservice.create_ticket({
  subject = "VPN connection issue",
  description = "<p>Cannot connect to the company VPN since this morning. Getting error code 691.</p>",
  email = "[email protected]",
  priority = 3
})

print("Created ticket #" .. result.ticket.id)

update_ticket

Update an existing ticket.

Parameters

NameTypeRequiredDescription
ticket_idintegeryesThe ticket display ID
subjectstringnoUpdated ticket subject
descriptionstringnoUpdated ticket description
priorityintegernoPriority: 1=Low, 2=Medium, 3=High, 4=Urgent
statusintegernoStatus: 2=Open, 3=Pending, 4=Resolved, 5=Closed
responder_idintegernoID of the agent to assign
tagsarraynoArray of tag strings

Status Values

ValueStatus
2Open
3Pending
4Resolved
5Closed

Examples

-- Assign and prioritize a ticket
local result = app.integrations.freshservice.update_ticket({
  ticket_id = 42,
  responder_id = 5,
  priority = 4
})

-- Resolve a ticket
local result = app.integrations.freshservice.update_ticket({
  ticket_id = 42,
  status = 4
})

-- Add tags
local result = app.integrations.freshservice.update_ticket({
  ticket_id = 42,
  tags = {"vpn", "urgent", "networking"}
})

delete_ticket

Delete a ticket permanently.

Parameters

NameTypeRequiredDescription
ticket_idintegeryesThe ticket display ID to delete

Example

local result = app.integrations.freshservice.delete_ticket({
  ticket_id = 42
})

print(result) -- "Ticket 42 has been deleted."

list_agents

List all agents (support staff) in the Freshservice account.

Parameters

NameTypeRequiredDescription
pagestringnoPage cursor for pagination

Example

local result = app.integrations.freshservice.list_agents({})

for _, agent in ipairs(result.agents) do
  print(agent.id .. ": " .. agent.first_name .. " " .. agent.last_name .. " (" .. agent.email .. ")")
end

get_agent

Get details of a specific agent.

Parameters

NameTypeRequiredDescription
agent_idintegeryesThe agent ID

Example

local result = app.integrations.freshservice.get_agent({
  agent_id = 5
})

local agent = result.agent
print(agent.first_name .. " " .. agent.last_name)
print("Email: " .. agent.email)
print("Available: " .. tostring(agent.available))

list_assets

List IT assets with optional pagination.

Parameters

NameTypeRequiredDescription
pageintegernoPage number for pagination (1-based)

Example

local result = app.integrations.freshservice.list_assets({
  page = 1
})

for _, asset in ipairs(result.assets) do
  print(asset.display_id .. ": " .. asset.name .. " [" .. asset.asset_type .. "]")
end

get_asset

Get details of a specific asset.

Parameters

NameTypeRequiredDescription
asset_idintegeryesThe asset display ID

Example

local result = app.integrations.freshservice.get_asset({
  asset_id = 15
})

local asset = result.asset
print("Name: " .. asset.name)
print("Type: " .. asset.asset_type)
print("State: " .. asset.state_name)

get_current_user

Get the profile of the currently authenticated agent. Takes no parameters.

Example

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

local agent = result.agent
print("Authenticated as: " .. agent.first_name .. " " .. agent.last_name)
print("Email: " .. agent.email)

Multi-Account Usage

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

-- Default account (always works)
app.integrations.freshservice.list_tickets({})

-- Explicit default (portable across setups)
app.integrations.freshservice.default.list_tickets({})

-- Named accounts
app.integrations.freshservice.production.list_tickets({})
app.integrations.freshservice.staging.list_tickets({})

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

Raw agent markdown
# Freshservice — Lua API Reference

## list_tickets

List support tickets with optional pagination and filtering.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `page` | integer | no | Page number for pagination (1-based) |
| `per_page` | integer | no | Number of tickets per page (max 100) |
| `filter` | string | no | Predefined filter: `"new_and_my_open"`, `"watching"`, `"spam"`, or `"deleted"` |

### Examples

```lua
-- List open tickets (first page)
local result = app.integrations.freshservice.list_tickets({
  filter = "new_and_my_open",
  per_page = 25
})

for _, ticket in ipairs(result.tickets) do
  print(ticket.id .. ": " .. ticket.subject .. " [Priority: " .. ticket.priority .. "]")
end
```

```lua
-- Paginate through tickets
local result = app.integrations.freshservice.list_tickets({
  page = 2,
  per_page = 50
})
```

---

## get_ticket

Get full details of a specific ticket.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `ticket_id` | integer | yes | The ticket display ID |

### Example

```lua
local result = app.integrations.freshservice.get_ticket({
  ticket_id = 42
})

local ticket = result.ticket
print("Subject: " .. ticket.subject)
print("Status: " .. ticket.status)
print("Priority: " .. ticket.priority)
print("Requester: " .. ticket.requester.email)
```

---

## create_ticket

Create a new support ticket.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `subject` | string | yes | The ticket subject / title |
| `description` | string | yes | Ticket description (supports HTML) |
| `email` | string | no | Email address of the requester |
| `priority` | integer | no | Priority: 1=Low, 2=Medium, 3=High, 4=Urgent |

### Priority Values

| Value | Level |
|-------|-------|
| 1 | Low |
| 2 | Medium (default) |
| 3 | High |
| 4 | Urgent |

### Example

```lua
local result = app.integrations.freshservice.create_ticket({
  subject = "VPN connection issue",
  description = "<p>Cannot connect to the company VPN since this morning. Getting error code 691.</p>",
  email = "[email protected]",
  priority = 3
})

print("Created ticket #" .. result.ticket.id)
```

---

## update_ticket

Update an existing ticket.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `ticket_id` | integer | yes | The ticket display ID |
| `subject` | string | no | Updated ticket subject |
| `description` | string | no | Updated ticket description |
| `priority` | integer | no | Priority: 1=Low, 2=Medium, 3=High, 4=Urgent |
| `status` | integer | no | Status: 2=Open, 3=Pending, 4=Resolved, 5=Closed |
| `responder_id` | integer | no | ID of the agent to assign |
| `tags` | array | no | Array of tag strings |

### Status Values

| Value | Status |
|-------|--------|
| 2 | Open |
| 3 | Pending |
| 4 | Resolved |
| 5 | Closed |

### Examples

```lua
-- Assign and prioritize a ticket
local result = app.integrations.freshservice.update_ticket({
  ticket_id = 42,
  responder_id = 5,
  priority = 4
})

-- Resolve a ticket
local result = app.integrations.freshservice.update_ticket({
  ticket_id = 42,
  status = 4
})

-- Add tags
local result = app.integrations.freshservice.update_ticket({
  ticket_id = 42,
  tags = {"vpn", "urgent", "networking"}
})
```

---

## delete_ticket

Delete a ticket permanently.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `ticket_id` | integer | yes | The ticket display ID to delete |

### Example

```lua
local result = app.integrations.freshservice.delete_ticket({
  ticket_id = 42
})

print(result) -- "Ticket 42 has been deleted."
```

---

## list_agents

List all agents (support staff) in the Freshservice account.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `page` | string | no | Page cursor for pagination |

### Example

```lua
local result = app.integrations.freshservice.list_agents({})

for _, agent in ipairs(result.agents) do
  print(agent.id .. ": " .. agent.first_name .. " " .. agent.last_name .. " (" .. agent.email .. ")")
end
```

---

## get_agent

Get details of a specific agent.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `agent_id` | integer | yes | The agent ID |

### Example

```lua
local result = app.integrations.freshservice.get_agent({
  agent_id = 5
})

local agent = result.agent
print(agent.first_name .. " " .. agent.last_name)
print("Email: " .. agent.email)
print("Available: " .. tostring(agent.available))
```

---

## list_assets

List IT assets with optional pagination.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `page` | integer | no | Page number for pagination (1-based) |

### Example

```lua
local result = app.integrations.freshservice.list_assets({
  page = 1
})

for _, asset in ipairs(result.assets) do
  print(asset.display_id .. ": " .. asset.name .. " [" .. asset.asset_type .. "]")
end
```

---

## get_asset

Get details of a specific asset.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `asset_id` | integer | yes | The asset display ID |

### Example

```lua
local result = app.integrations.freshservice.get_asset({
  asset_id = 15
})

local asset = result.asset
print("Name: " .. asset.name)
print("Type: " .. asset.asset_type)
print("State: " .. asset.state_name)
```

---

## get_current_user

Get the profile of the currently authenticated agent. Takes no parameters.

### Example

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

local agent = result.agent
print("Authenticated as: " .. agent.first_name .. " " .. agent.last_name)
print("Email: " .. agent.email)
```

---

## Multi-Account Usage

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

```lua
-- Default account (always works)
app.integrations.freshservice.list_tickets({})

-- Explicit default (portable across setups)
app.integrations.freshservice.default.list_tickets({})

-- Named accounts
app.integrations.freshservice.production.list_tickets({})
app.integrations.freshservice.staging.list_tickets({})
```

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

Metadata-Derived Lua Example

local result = app.integrations.freshservice.freshservice_list_tickets({
  page = 1,
  per_page = 1,
  filter = "example_filter"
})
print(result)

Functions

freshservice_list_tickets

List support tickets from Freshservice. Supports pagination and predefined filters (e.g., new_and_my_open, watching, spam, deleted). Returns ticket summaries including subject, status, priority, and requester.

Operation
Read read
Full name
freshservice.freshservice_list_tickets
ParameterTypeRequiredDescription
page integer no Page number for pagination (1-based).
per_page integer no Number of tickets per page (max 100).
filter string no Predefined filter: "new_and_my_open", "watching", "spam", or "deleted".

freshservice_get_ticket

Get full details of a specific Freshservice ticket by its ID, including description, status, priority, requester, assigned agent, and custom fields.

Operation
Read read
Full name
freshservice.freshservice_get_ticket
ParameterTypeRequiredDescription
ticket_id integer yes The ticket display ID.

freshservice_create_ticket

Create a new support ticket in Freshservice. Requires a subject and description. Optionally specify the requester email and priority (1=Low, 2=Medium, 3=High, 4=Urgent).

Operation
Write write
Full name
freshservice.freshservice_create_ticket
ParameterTypeRequiredDescription
subject string yes The ticket subject / title.
description string yes The ticket description (supports HTML).
email string no Email address of the requester.
priority integer no Priority level: 1=Low, 2=Medium, 3=High, 4=Urgent.

freshservice_update_ticket

Update an existing Freshservice ticket. You can change status, priority, assigned agent, add tags, or modify any writable field.

Operation
Write write
Full name
freshservice.freshservice_update_ticket
ParameterTypeRequiredDescription
ticket_id integer yes The ticket display ID.
subject string no Updated ticket subject.
description string no Updated ticket description (supports HTML).
priority integer no Priority level: 1=Low, 2=Medium, 3=High, 4=Urgent.
status integer no Status: 2=Open, 3=Pending, 4=Resolved, 5=Closed.
responder_id integer no ID of the agent to assign the ticket to.
tags array no Array of tag strings to set on the ticket.

freshservice_delete_ticket

Delete a support ticket from Freshservice. This action permanently removes the ticket and its conversations.

Operation
Write write
Full name
freshservice.freshservice_delete_ticket
ParameterTypeRequiredDescription
ticket_id integer yes The ticket display ID to delete.

freshservice_list_agents

List all agents (support staff) in the Freshservice account. Returns agent profiles including name, email, and availability.

Operation
Read read
Full name
freshservice.freshservice_list_agents
ParameterTypeRequiredDescription
page string no Page cursor for pagination — pass the value from a previous response to get the next page.

freshservice_get_agent

Get details of a specific Freshservice agent by their ID, including name, email, role, and availability status.

Operation
Read read
Full name
freshservice.freshservice_get_agent
ParameterTypeRequiredDescription
agent_id integer yes The agent ID.

freshservice_list_assets

List IT assets from Freshservice. Supports pagination. Returns asset summaries including name, asset type, and state.

Operation
Read read
Full name
freshservice.freshservice_list_assets
ParameterTypeRequiredDescription
page integer no Page number for pagination (1-based).

freshservice_get_asset

Get full details of a specific Freshservice asset by its display ID, including name, type, state, location, and custom fields.

Operation
Read read
Full name
freshservice.freshservice_get_asset
ParameterTypeRequiredDescription
asset_id integer yes The asset display ID.

freshservice_get_current_user

Get the profile of the currently authenticated Freshservice agent. Useful for identifying which agent is performing actions.

Operation
Read read
Full name
freshservice.freshservice_get_current_user
ParameterTypeRequiredDescription
No parameters.