productivity
Freshdesk Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the Freshdesk KosmoKrator integration.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.
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
Freshdesk workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.freshdesk.list_tickets({page = 1, per_page = 1, filter = "example_filter", company_id = 1, requester_id = 1, email = "example_email"}))' --json kosmo integrations:lua --eval 'print(docs.read("freshdesk"))' --json
kosmo integrations:lua --eval 'print(docs.read("freshdesk.list_tickets"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local freshdesk = app.integrations.freshdesk
local result = freshdesk.list_tickets({page = 1, per_page = 1, filter = "example_filter", company_id = 1, requester_id = 1, email = "example_email"})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.freshdesk, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.freshdesk.default.* or app.integrations.freshdesk.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need Freshdesk, use the narrower 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.
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 |
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 |
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 |
local ticket = app.integrations.freshdesk.create_ticket({
subject = "Cannot access account",
description = "<p>User reports being locked out after password reset.</p>",
email = "john@example.com",
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 |
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 |
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 |
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 |
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 |
local contact = app.integrations.freshdesk.create_contact({
email = "jane@example.com",
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 |
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 |
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.
| Parameter | Type | Required | Description |
|---|---|---|---|
ticket_id | integer | yes | The 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).
| 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 |
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 |
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 |
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:
-- 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 = "john@example.com",
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 = "jane@example.com",
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. local result = app.integrations.freshdesk.list_tickets({page = 1, per_page = 1, filter = "example_filter", company_id = 1, requester_id = 1, email = "example_email"})
print(result) Functions
list_tickets Read
List support tickets from Freshdesk. Supports filtering by status, priority, and pagination. Returns ticket details including subject, status, priority, requester, and assignee.
- Lua path
app.integrations.freshdesk.list_tickets- Full name
freshdesk.freshdesk_list_tickets
| 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. |
get_ticket Read
Get full details of a specific support ticket including description, custom fields, conversation history, and associated contacts.
- Lua path
app.integrations.freshdesk.get_ticket- Full name
freshdesk.freshdesk_get_ticket
| Parameter | Type | Required | Description |
|---|---|---|---|
ticket_id | integer | yes | The ticket ID. |
create_ticket Write
Create a new support ticket. Requires a subject, description, and requester email. Optionally set priority and status.
- Lua path
app.integrations.freshdesk.create_ticket- Full name
freshdesk.freshdesk_create_ticket
| Parameter | Type | Required | Description |
|---|---|---|---|
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. |
update_ticket Write
Update an existing support ticket. Can change subject, description, status, priority, assignee, and other fields.
- Lua path
app.integrations.freshdesk.update_ticket- Full name
freshdesk.freshdesk_update_ticket
| Parameter | Type | Required | Description |
|---|---|---|---|
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. |
delete_ticket Write
Permanently delete a support ticket. This action cannot be undone.
- Lua path
app.integrations.freshdesk.delete_ticket- Full name
freshdesk.freshdesk_delete_ticket
| Parameter | Type | Required | Description |
|---|---|---|---|
ticket_id | integer | yes | The ticket ID to delete. |
list_contacts Read
List customer contacts from Freshdesk. Supports pagination. Returns contact names, emails, and company associations.
- Lua path
app.integrations.freshdesk.list_contacts- Full name
freshdesk.freshdesk_list_contacts
| Parameter | Type | Required | Description |
|---|---|---|---|
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. |
get_contact Read
Get full details of a specific customer contact including email, phone, company, and custom fields.
- Lua path
app.integrations.freshdesk.get_contact- Full name
freshdesk.freshdesk_get_contact
| Parameter | Type | Required | Description |
|---|---|---|---|
contact_id | integer | yes | The contact ID. |
create_contact Write
Create a new customer contact in Freshdesk. Requires an email address and name.
- Lua path
app.integrations.freshdesk.create_contact- Full name
freshdesk.freshdesk_create_contact
| Parameter | Type | Required | Description |
|---|---|---|---|
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. |
list_agents Read
List all helpdesk agents. Returns agent details including name, email, availability, and group memberships.
- Lua path
app.integrations.freshdesk.list_agents- Full name
freshdesk.freshdesk_list_agents
| Parameter | Type | Required | Description |
|---|---|---|---|
page | integer | no | Page number (default: 1). |
per_page | integer | no | Results per page (max: 100, default: 30). |
get_agent Read
Get details of a specific helpdesk agent including name, email, role, availability, and group assignments.
- Lua path
app.integrations.freshdesk.get_agent- Full name
freshdesk.freshdesk_get_agent
| Parameter | Type | Required | Description |
|---|---|---|---|
agent_id | integer | yes | The agent ID. |
list_conversations Read
List all conversations on a ticket — includes public replies and private notes. Shows who posted, the body, and timestamps.
- Lua path
app.integrations.freshdesk.list_conversations- Full name
freshdesk.freshdesk_list_conversations
| Parameter | Type | Required | Description |
|---|---|---|---|
ticket_id | integer | yes | The ticket ID. |
create_reply Write
Post a public reply to a support ticket. The reply is visible to the requester. Use this to respond to customers.
- Lua path
app.integrations.freshdesk.create_reply- Full name
freshdesk.freshdesk_create_reply
| Parameter | Type | Required | Description |
|---|---|---|---|
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. |
create_note Write
Add a private note to a support ticket. Notes are only visible to agents, not to the customer. Use for internal communication.
- Lua path
app.integrations.freshdesk.create_note- Full name
freshdesk.freshdesk_create_note
| Parameter | Type | Required | Description |
|---|---|---|---|
ticket_id | integer | yes | The ticket ID. |
body | string | yes | HTML body of the note. |
list_companies Read
List customer companies from Freshdesk. Supports pagination. Returns company names, domains, and associated contacts.
- Lua path
app.integrations.freshdesk.list_companies- Full name
freshdesk.freshdesk_list_companies
| Parameter | Type | Required | Description |
|---|---|---|---|
page | integer | no | Page number (default: 1). |
per_page | integer | no | Results per page (max: 100, default: 30). |
get_current_user Read
Get the currently authenticated Freshdesk agent. Returns agent name, email, role, and availability. Use this to verify API credentials are working.
- Lua path
app.integrations.freshdesk.get_current_user- Full name
freshdesk.freshdesk_get_current_user
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||