KosmoKrator

productivity

Freshdesk Lua API for KosmoKrator Agents

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

15 functions 9 read 6 write API key auth

Lua Namespace

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

Freshdesk — Lua API Reference

Authentication

The Freshdesk integration uses HTTP Basic Auth with your API key as the username and X as the password. Configure your API Key and Domain (the part before .freshdesk.com) in the integration settings.


Ticket Operations

list_tickets

List support tickets with optional filters and pagination.

ParameterTypeRequiredDescription
pageintegernoPage number (default: 1)
per_pageintegernoResults per page (max: 100, default: 30)
filterstringnoPredefined filter: "new_and_my_open", "watching", "spam", "deleted"
company_idintegernoFilter by company ID
requester_idintegernoFilter by requester ID
emailstringnoFilter by requester email
local result = app.integrations.freshdesk.list_tickets({
  filter = "new_and_my_open",
  per_page = 25
})
for _, ticket in ipairs(result) do
  print(ticket.id .. ": " .. ticket.subject .. " [" .. ticket.status .. "]")
end

get_ticket

Get full details of a specific ticket.

ParameterTypeRequiredDescription
ticket_idintegeryesThe ticket ID
local ticket = app.integrations.freshdesk.get_ticket({ ticket_id = 12345 })
print(ticket.subject)
print(ticket.description)
print("Status: " .. ticket.status .. ", Priority: " .. ticket.priority)

create_ticket

Create a new support ticket.

ParameterTypeRequiredDescription
subjectstringyesTicket subject
descriptionstringyesHTML description
emailstringyesRequester email
priorityintegerno1=Low, 2=Medium, 3=High, 4=Urgent
statusintegerno2=Open, 3=Pending, 4=Resolved, 5=Closed
typestringnoTicket type (e.g., “Question”, “Incident”)
tagsarraynoArray of tag strings
group_idintegernoGroup to assign
assignee_idintegernoAgent to assign
cc_emailsarraynoCC email addresses
local ticket = app.integrations.freshdesk.create_ticket({
  subject = "Cannot access account",
  description = "<p>User reports being locked out after password reset.</p>",
  email = "[email protected]",
  priority = 3,
  status = 2,
  tags = { "login", "urgent" }
})
print("Created ticket #" .. ticket.id)

update_ticket

Update an existing ticket.

ParameterTypeRequiredDescription
ticket_idintegeryesThe ticket ID
subjectstringnoNew subject
descriptionstringnoNew description
priorityintegernoNew priority (1–4)
statusintegernoNew status (2–5)
typestringnoNew type
tagsarraynoReplace tags
group_idintegernoNew group
assignee_idintegernoNew assignee
app.integrations.freshdesk.update_ticket({
  ticket_id = 12345,
  status = 4,
  priority = 2
})

delete_ticket

Permanently delete a ticket.

ParameterTypeRequiredDescription
ticket_idintegeryesThe ticket ID
app.integrations.freshdesk.delete_ticket({ ticket_id = 12345 })

Contact Operations

list_contacts

List customer contacts.

ParameterTypeRequiredDescription
pageintegernoPage number
per_pageintegernoResults per page
emailstringnoFilter by email
company_idintegernoFilter by company
mobilestringnoFilter by mobile
phonestringnoFilter by phone
local contacts = app.integrations.freshdesk.list_contacts({ per_page = 50 })

get_contact

Get details of a specific contact.

ParameterTypeRequiredDescription
contact_idintegeryesThe contact ID
local contact = app.integrations.freshdesk.get_contact({ contact_id = 42 })
print(contact.name .. " <" .. contact.email .. ">")

create_contact

Create a new customer contact.

ParameterTypeRequiredDescription
emailstringyesContact email
namestringyesFull name
phonestringnoPhone number
mobilestringnoMobile number
company_idintegernoCompany to associate
job_titlestringnoJob title
tagsarraynoTags
local contact = app.integrations.freshdesk.create_contact({
  email = "[email protected]",
  name = "Jane Smith",
  job_title = "CTO"
})

Agent Operations

list_agents

List all helpdesk agents.

ParameterTypeRequiredDescription
pageintegernoPage number
per_pageintegernoResults per page
local agents = app.integrations.freshdesk.list_agents()

get_agent

Get details of a specific agent.

ParameterTypeRequiredDescription
agent_idintegeryesThe agent ID
local agent = app.integrations.freshdesk.get_agent({ agent_id = 5 })
print(agent.contact.name)

get_current_user

Get the currently authenticated agent. Useful for verifying API credentials.

local user = app.integrations.freshdesk.get_current_user({})
print("Authenticated as: " .. user.contact.name)

Conversation Operations

list_conversations

List all conversations (replies and notes) on a ticket.

ParameterTypeRequiredDescription
ticket_idintegeryesThe ticket ID
local convos = app.integrations.freshdesk.list_conversations({ ticket_id = 12345 })
for _, c in ipairs(convos) do
  print(c.source .. ": " .. c.body_text)
end

create_reply

Post a public reply to a ticket (visible to the customer).

ParameterTypeRequiredDescription
ticket_idintegeryesThe ticket ID
bodystringyesHTML body of the reply
cc_emailsarraynoCC email addresses
bcc_emailsarraynoBCC email addresses
app.integrations.freshdesk.create_reply({
  ticket_id = 12345,
  body = "<p>Hi, we've resolved this issue. Please let us know if you need anything else!</p>"
})

create_note

Add a private note to a ticket (only visible to agents).

ParameterTypeRequiredDescription
ticket_idintegeryesThe ticket ID
bodystringyesHTML body of the note
app.integrations.freshdesk.create_note({
  ticket_id = 12345,
  body = "<p>Spoke with customer on the phone. They confirmed the fix works.</p>"
})

Company Operations

list_companies

List customer companies.

ParameterTypeRequiredDescription
pageintegernoPage number
per_pageintegernoResults per page
local companies = app.integrations.freshdesk.list_companies({ page = 1 })
for _, company in ipairs(companies) do
  print(company.name)
end

Status & Priority Reference

Ticket Status

ValueMeaning
2Open
3Pending
4Resolved
5Closed

Ticket Priority

ValueMeaning
1Low
2Medium
3High
4Urgent

Multi-Account Usage

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

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

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

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

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

Raw agent markdown
# Freshdesk — Lua API Reference

## Authentication

The Freshdesk integration uses HTTP Basic Auth with your API key as the username and `X` as the password. Configure your **API Key** and **Domain** (the part before `.freshdesk.com`) in the integration settings.

---

## Ticket Operations

### list_tickets

List support tickets with optional filters and pagination.

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `page` | integer | no | Page number (default: 1) |
| `per_page` | integer | no | Results per page (max: 100, default: 30) |
| `filter` | string | no | Predefined filter: `"new_and_my_open"`, `"watching"`, `"spam"`, `"deleted"` |
| `company_id` | integer | no | Filter by company ID |
| `requester_id` | integer | no | Filter by requester ID |
| `email` | string | no | Filter by requester email |

```lua
local result = app.integrations.freshdesk.list_tickets({
  filter = "new_and_my_open",
  per_page = 25
})
for _, ticket in ipairs(result) do
  print(ticket.id .. ": " .. ticket.subject .. " [" .. ticket.status .. "]")
end
```

### get_ticket

Get full details of a specific ticket.

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

```lua
local ticket = app.integrations.freshdesk.get_ticket({ ticket_id = 12345 })
print(ticket.subject)
print(ticket.description)
print("Status: " .. ticket.status .. ", Priority: " .. ticket.priority)
```

### create_ticket

Create a new support ticket.

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `subject` | string | yes | Ticket subject |
| `description` | string | yes | HTML description |
| `email` | string | yes | Requester email |
| `priority` | integer | no | 1=Low, 2=Medium, 3=High, 4=Urgent |
| `status` | integer | no | 2=Open, 3=Pending, 4=Resolved, 5=Closed |
| `type` | string | no | Ticket type (e.g., "Question", "Incident") |
| `tags` | array | no | Array of tag strings |
| `group_id` | integer | no | Group to assign |
| `assignee_id` | integer | no | Agent to assign |
| `cc_emails` | array | no | CC email addresses |

```lua
local ticket = app.integrations.freshdesk.create_ticket({
  subject = "Cannot access account",
  description = "<p>User reports being locked out after password reset.</p>",
  email = "[email protected]",
  priority = 3,
  status = 2,
  tags = { "login", "urgent" }
})
print("Created ticket #" .. ticket.id)
```

### update_ticket

Update an existing ticket.

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `ticket_id` | integer | yes | The ticket ID |
| `subject` | string | no | New subject |
| `description` | string | no | New description |
| `priority` | integer | no | New priority (1–4) |
| `status` | integer | no | New status (2–5) |
| `type` | string | no | New type |
| `tags` | array | no | Replace tags |
| `group_id` | integer | no | New group |
| `assignee_id` | integer | no | New assignee |

```lua
app.integrations.freshdesk.update_ticket({
  ticket_id = 12345,
  status = 4,
  priority = 2
})
```

### delete_ticket

Permanently delete a ticket.

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

```lua
app.integrations.freshdesk.delete_ticket({ ticket_id = 12345 })
```

---

## Contact Operations

### list_contacts

List customer contacts.

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `page` | integer | no | Page number |
| `per_page` | integer | no | Results per page |
| `email` | string | no | Filter by email |
| `company_id` | integer | no | Filter by company |
| `mobile` | string | no | Filter by mobile |
| `phone` | string | no | Filter by phone |

```lua
local contacts = app.integrations.freshdesk.list_contacts({ per_page = 50 })
```

### get_contact

Get details of a specific contact.

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `contact_id` | integer | yes | The contact ID |

```lua
local contact = app.integrations.freshdesk.get_contact({ contact_id = 42 })
print(contact.name .. " <" .. contact.email .. ">")
```

### create_contact

Create a new customer contact.

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `email` | string | yes | Contact email |
| `name` | string | yes | Full name |
| `phone` | string | no | Phone number |
| `mobile` | string | no | Mobile number |
| `company_id` | integer | no | Company to associate |
| `job_title` | string | no | Job title |
| `tags` | array | no | Tags |

```lua
local contact = app.integrations.freshdesk.create_contact({
  email = "[email protected]",
  name = "Jane Smith",
  job_title = "CTO"
})
```

---

## Agent Operations

### list_agents

List all helpdesk agents.

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `page` | integer | no | Page number |
| `per_page` | integer | no | Results per page |

```lua
local agents = app.integrations.freshdesk.list_agents()
```

### get_agent

Get details of a specific agent.

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

```lua
local agent = app.integrations.freshdesk.get_agent({ agent_id = 5 })
print(agent.contact.name)
```

### get_current_user

Get the currently authenticated agent. Useful for verifying API credentials.

```lua
local user = app.integrations.freshdesk.get_current_user({})
print("Authenticated as: " .. user.contact.name)
```

---

## Conversation Operations

### list_conversations

List all conversations (replies and notes) on a ticket.

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

```lua
local convos = app.integrations.freshdesk.list_conversations({ ticket_id = 12345 })
for _, c in ipairs(convos) do
  print(c.source .. ": " .. c.body_text)
end
```

### create_reply

Post a public reply to a ticket (visible to the customer).

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `ticket_id` | integer | yes | The ticket ID |
| `body` | string | yes | HTML body of the reply |
| `cc_emails` | array | no | CC email addresses |
| `bcc_emails` | array | no | BCC email addresses |

```lua
app.integrations.freshdesk.create_reply({
  ticket_id = 12345,
  body = "<p>Hi, we've resolved this issue. Please let us know if you need anything else!</p>"
})
```

### create_note

Add a private note to a ticket (only visible to agents).

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `ticket_id` | integer | yes | The ticket ID |
| `body` | string | yes | HTML body of the note |

```lua
app.integrations.freshdesk.create_note({
  ticket_id = 12345,
  body = "<p>Spoke with customer on the phone. They confirmed the fix works.</p>"
})
```

---

## Company Operations

### list_companies

List customer companies.

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `page` | integer | no | Page number |
| `per_page` | integer | no | Results per page |

```lua
local companies = app.integrations.freshdesk.list_companies({ page = 1 })
for _, company in ipairs(companies) do
  print(company.name)
end
```

---

## Status & Priority Reference

### Ticket Status

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

### Ticket Priority

| Value | Meaning |
|-------|---------|
| 1 | Low |
| 2 | Medium |
| 3 | High |
| 4 | Urgent |

---

## Multi-Account Usage

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

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

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

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

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

Metadata-Derived Lua Example

local result = app.integrations.freshdesk.freshdesk_list_tickets({
  page = 1,
  per_page = 1,
  filter = "example_filter",
  company_id = 1,
  requester_id = 1,
  email = "example_email"
})
print(result)

Functions

freshdesk_list_tickets

List support tickets from Freshdesk. Supports filtering by status, priority, and pagination. Returns ticket details including subject, status, priority, requester, and assignee.

Operation
Read read
Full name
freshdesk.freshdesk_list_tickets
ParameterTypeRequiredDescription
page integer no Page number (default: 1).
per_page integer no Results per page (max: 100, default: 30).
filter string no Predefined filter: "new_and_my_open", "watching", "spam", "deleted".
company_id integer no Filter by company ID.
requester_id integer no Filter by requester ID.
email string no Filter by requester email.

freshdesk_get_ticket

Get full details of a specific support ticket including description, custom fields, conversation history, and associated contacts.

Operation
Read read
Full name
freshdesk.freshdesk_get_ticket
ParameterTypeRequiredDescription
ticket_id integer yes The ticket ID.

freshdesk_create_ticket

Create a new support ticket. Requires a subject, description, and requester email. Optionally set priority and status.

Operation
Write write
Full name
freshdesk.freshdesk_create_ticket
ParameterTypeRequiredDescription
subject string yes Subject of the ticket.
description string yes HTML description of the ticket.
email string yes Email address of the requester.
priority integer no Priority: 1=Low, 2=Medium, 3=High, 4=Urgent.
status integer no Status: 2=Open, 3=Pending, 4=Resolved, 5=Closed.
type string no Ticket type (e.g., "Question", "Incident", "Problem").
tags array no Array of tags to assign.
group_id integer no ID of the group to assign the ticket to.
assignee_id integer no ID of the agent to assign the ticket to.
cc_emails array no Array of email addresses to CC.

freshdesk_update_ticket

Update an existing support ticket. Can change subject, description, status, priority, assignee, and other fields.

Operation
Write write
Full name
freshdesk.freshdesk_update_ticket
ParameterTypeRequiredDescription
ticket_id integer yes The ticket ID to update.
subject string no New subject.
description string no New HTML 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.
type string no Ticket type.
tags array no Replace tags (array of strings).
group_id integer no Group ID to assign.
assignee_id integer no Agent ID to assign.

freshdesk_delete_ticket

Permanently delete a support ticket. This action cannot be undone.

Operation
Write write
Full name
freshdesk.freshdesk_delete_ticket
ParameterTypeRequiredDescription
ticket_id integer yes The ticket ID to delete.

freshdesk_list_contacts

List customer contacts from Freshdesk. Supports pagination. Returns contact names, emails, and company associations.

Operation
Read read
Full name
freshdesk.freshdesk_list_contacts
ParameterTypeRequiredDescription
page integer no Page number (default: 1).
per_page integer no Results per page (max: 100, default: 30).
email string no Filter by contact email.
company_id integer no Filter by company ID.
mobile string no Filter by mobile number.
phone string no Filter by phone number.

freshdesk_get_contact

Get full details of a specific customer contact including email, phone, company, and custom fields.

Operation
Read read
Full name
freshdesk.freshdesk_get_contact
ParameterTypeRequiredDescription
contact_id integer yes The contact ID.

freshdesk_create_contact

Create a new customer contact in Freshdesk. Requires an email address and name.

Operation
Write write
Full name
freshdesk.freshdesk_create_contact
ParameterTypeRequiredDescription
email string yes Email address of the contact.
name string yes Full name of the contact.
phone string no Phone number.
mobile string no Mobile number.
company_id integer no ID of the company to associate.
job_title string no Job title.
tags array no Array of tags.

freshdesk_list_agents

List all helpdesk agents. Returns agent details including name, email, availability, and group memberships.

Operation
Read read
Full name
freshdesk.freshdesk_list_agents
ParameterTypeRequiredDescription
page integer no Page number (default: 1).
per_page integer no Results per page (max: 100, default: 30).

freshdesk_get_agent

Get details of a specific helpdesk agent including name, email, role, availability, and group assignments.

Operation
Read read
Full name
freshdesk.freshdesk_get_agent
ParameterTypeRequiredDescription
agent_id integer yes The agent ID.

freshdesk_list_conversations

List all conversations on a ticket — includes public replies and private notes. Shows who posted, the body, and timestamps.

Operation
Read read
Full name
freshdesk.freshdesk_list_conversations
ParameterTypeRequiredDescription
ticket_id integer yes The ticket ID.

freshdesk_create_reply

Post a public reply to a support ticket. The reply is visible to the requester. Use this to respond to customers.

Operation
Write write
Full name
freshdesk.freshdesk_create_reply
ParameterTypeRequiredDescription
ticket_id integer yes The ticket ID to reply to.
body string yes HTML body of the reply.
cc_emails array no Array of email addresses to CC on the reply.
bcc_emails array no Array of email addresses to BCC.

freshdesk_create_note

Add a private note to a support ticket. Notes are only visible to agents, not to the customer. Use for internal communication.

Operation
Write write
Full name
freshdesk.freshdesk_create_note
ParameterTypeRequiredDescription
ticket_id integer yes The ticket ID.
body string yes HTML body of the note.

freshdesk_list_companies

List customer companies from Freshdesk. Supports pagination. Returns company names, domains, and associated contacts.

Operation
Read read
Full name
freshdesk.freshdesk_list_companies
ParameterTypeRequiredDescription
page integer no Page number (default: 1).
per_page integer no Results per page (max: 100, default: 30).

freshdesk_get_current_user

Get the currently authenticated Freshdesk agent. Returns agent name, email, role, and availability. Use this to verify API credentials are working.

Operation
Read read
Full name
freshdesk.freshdesk_get_current_user
ParameterTypeRequiredDescription
No parameters.