KosmoKrator

productivity

Freshsales Lua API for KosmoKrator Agents

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

Lua Namespace

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

Inline Lua call
kosmo integrations:lua --eval 'dump(app.integrations.freshsales.create_contact({first_name = "example_first_name", last_name = "example_last_name", email = "example_email", mobile_number = "example_mobile_number"}))' --json
Read Lua docs headlessly
kosmo integrations:lua --eval 'print(docs.read("freshsales"))' --json
kosmo integrations:lua --eval 'print(docs.read("freshsales.create_contact"))' --json

Workflow file

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

workflow.lua
local freshsales = app.integrations.freshsales
local result = freshsales.create_contact({first_name = "example_first_name", last_name = "example_last_name", email = "example_email", mobile_number = "example_mobile_number"})

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

MCP-only Lua

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

Freshsales Integration

Tools for interacting with the Freshsales CRM API.

Tools

freshsales_list_contacts

List contacts from Freshsales CRM.

Parameters:

  • page (integer, optional) — Page number for pagination (default: 1)
  • per_page (integer, optional) — Number of contacts per page (default: 20, max: 100)
  • sort (string, optional) — Sort direction: “asc” or “desc”
  • sort_by (string, optional) — Field to sort by (e.g., “created_at”, “updated_at”, “first_name”)

freshsales_get_contact

Get full details for a specific contact.

Parameters:

  • id (integer, required) — The contact ID

freshsales_create_contact

Create a new contact in Freshsales.

Parameters:

  • first_name (string, required) — First name
  • last_name (string, required) — Last name
  • email (string, optional) — Email address
  • mobile_number (string, optional) — Mobile phone number

freshsales_list_deals

List deals from Freshsales CRM.

Parameters:

  • page (integer, optional) — Page number for pagination (default: 1)
  • per_page (integer, optional) — Number of deals per page (default: 20, max: 100)

freshsales_get_deal

Get full details for a specific deal.

Parameters:

  • id (integer, required) — The deal ID

freshsales_list_accounts

List sales accounts from Freshsales CRM.

Parameters:

  • page (integer, optional) — Page number for pagination (default: 1)
  • per_page (integer, optional) — Number of accounts per page (default: 20, max: 100)

freshsales_get_current_user

Get the currently authenticated user profile. Useful for verifying the API connection.

Parameters: None

Raw agent markdown
# Freshsales Integration

Tools for interacting with the Freshsales CRM API.

## Tools

### freshsales_list_contacts
List contacts from Freshsales CRM.

**Parameters:**
- `page` (integer, optional) — Page number for pagination (default: 1)
- `per_page` (integer, optional) — Number of contacts per page (default: 20, max: 100)
- `sort` (string, optional) — Sort direction: "asc" or "desc"
- `sort_by` (string, optional) — Field to sort by (e.g., "created_at", "updated_at", "first_name")

### freshsales_get_contact
Get full details for a specific contact.

**Parameters:**
- `id` (integer, required) — The contact ID

### freshsales_create_contact
Create a new contact in Freshsales.

**Parameters:**
- `first_name` (string, required) — First name
- `last_name` (string, required) — Last name
- `email` (string, optional) — Email address
- `mobile_number` (string, optional) — Mobile phone number

### freshsales_list_deals
List deals from Freshsales CRM.

**Parameters:**
- `page` (integer, optional) — Page number for pagination (default: 1)
- `per_page` (integer, optional) — Number of deals per page (default: 20, max: 100)

### freshsales_get_deal
Get full details for a specific deal.

**Parameters:**
- `id` (integer, required) — The deal ID

### freshsales_list_accounts
List sales accounts from Freshsales CRM.

**Parameters:**
- `page` (integer, optional) — Page number for pagination (default: 1)
- `per_page` (integer, optional) — Number of accounts per page (default: 20, max: 100)

### freshsales_get_current_user
Get the currently authenticated user profile. Useful for verifying the API connection.

**Parameters:** None
Metadata-derived Lua example
local result = app.integrations.freshsales.create_contact({first_name = "example_first_name", last_name = "example_last_name", email = "example_email", mobile_number = "example_mobile_number"})
print(result)

Functions

create_contact Write

Create a new contact in Freshsales CRM with name, email, and phone details.

Lua path
app.integrations.freshsales.create_contact
Full name
freshsales.freshsales_create_contact
ParameterTypeRequiredDescription
first_name string yes First name of the contact.
last_name string yes Last name of the contact.
email string no Email address of the contact.
mobile_number string no Mobile phone number of the contact.
get_contact Read

Get full details for a specific Freshsales contact by ID.

Lua path
app.integrations.freshsales.get_contact
Full name
freshsales.freshsales_get_contact
ParameterTypeRequiredDescription
id integer yes The contact ID.
get_current_user Read

Get the profile of the currently authenticated Freshsales user. Useful for verifying the API connection.

Lua path
app.integrations.freshsales.get_current_user
Full name
freshsales.freshsales_get_current_user
ParameterTypeRequiredDescription
No parameters.
get_deal Read

Get full details for a specific Freshsales deal by ID.

Lua path
app.integrations.freshsales.get_deal
Full name
freshsales.freshsales_get_deal
ParameterTypeRequiredDescription
id integer yes The deal ID.
list_accounts Read

List sales accounts (companies) from Freshsales CRM. Returns paginated results.

Lua path
app.integrations.freshsales.list_accounts
Full name
freshsales.freshsales_list_accounts
ParameterTypeRequiredDescription
page integer no Page number for pagination (default: 1).
per_page integer no Number of accounts per page (default: 20, max: 100).
list_contacts Read

List contacts from Freshsales CRM. Returns paginated results with optional sorting by field and direction.

Lua path
app.integrations.freshsales.list_contacts
Full name
freshsales.freshsales_list_contacts
ParameterTypeRequiredDescription
page integer no Page number for pagination (default: 1).
per_page integer no Number of contacts per page (default: 20, max: 100).
sort string no Sort direction: "asc" or "desc" (default: "desc").
sort_by string no Field to sort by, e.g., "created_at", "updated_at", "first_name".
list_deals Read

List deals from Freshsales CRM. Returns paginated results showing deal pipeline information.

Lua path
app.integrations.freshsales.list_deals
Full name
freshsales.freshsales_list_deals
ParameterTypeRequiredDescription
page integer no Page number for pagination (default: 1).
per_page integer no Number of deals per page (default: 20, max: 100).