KosmoKrator

healthcare

Weave Lua API for KosmoKrator Agents

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

7 functions 7 read 0 write Bearer token auth

Lua Namespace

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

Weave — Lua API Reference

list_patients

Search and list patients from the Weave platform.

Parameters

NameTypeRequiredDescription
limitintegernoMaximum number of patients to return (default: 25)
pageintegernoPage number for pagination, 1-based (default: 1)
querystringnoSearch query to filter patients by name, phone, or email

Example

local result = app.integrations.weave.list_patients({
  query = "Smith",
  limit = 10
})

for _, patient in ipairs(result.patients) do
  print(patient.id .. ": " .. patient.name)
end

get_patient

Retrieve a single patient by ID.

Parameters

NameTypeRequiredDescription
idstringyesThe unique patient identifier

Example

local result = app.integrations.weave.get_patient({
  id = "patient-123"
})

print(result.name .. " — " .. result.email)

list_appointments

List appointments with optional date range filtering.

Parameters

NameTypeRequiredDescription
startDatestringnoStart date (ISO 8601, e.g. “2025-01-01”)
endDatestringnoEnd date (ISO 8601, e.g. “2025-01-31”)
limitintegernoMaximum number of appointments to return (default: 25)

Example

local result = app.integrations.weave.list_appointments({
  startDate = "2025-01-01",
  endDate = "2025-01-31",
  limit = 50
})

for _, appt in ipairs(result.appointments) do
  print(appt.id .. ": " .. appt.patient_name .. " at " .. appt.scheduled_at)
end

get_appointment

Retrieve a single appointment by ID.

Parameters

NameTypeRequiredDescription
idstringyesThe unique appointment identifier

Example

local result = app.integrations.weave.get_appointment({
  id = "appt-456"
})

print(result.patient_name .. " — " .. result.scheduled_at .. " (" .. result.status .. ")")

list_messages

List patient messages with optional type filtering.

Parameters

NameTypeRequiredDescription
limitintegernoMaximum number of messages to return (default: 25)
pageintegernoPage number for pagination, 1-based (default: 1)
typestringnoFilter by message type (e.g. “sms”, “email”)

Example

local result = app.integrations.weave.list_messages({
  type = "sms",
  limit = 20
})

for _, msg in ipairs(result.messages) do
  print(msg.id .. ": " .. msg.preview)
end

get_message

Retrieve a single message by ID.

Parameters

NameTypeRequiredDescription
idstringyesThe unique message identifier

Example

local result = app.integrations.weave.get_message({
  id = "msg-789"
})

print("From: " .. result.sender .. "\n" .. result.body)

get_current_user

Get the currently authenticated Weave user profile.

Parameters

None.

Example

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

print("Logged in as: " .. result.name .. " (" .. result.email .. ")")
print("Role: " .. result.role)

Multi-Account Usage

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

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

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

-- Named accounts
app.integrations.weave.clinic_a.function_name({...})
app.integrations.weave.clinic_b.function_name({...})

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

Raw agent markdown
# Weave — Lua API Reference

## list_patients

Search and list patients from the Weave platform.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of patients to return (default: 25) |
| `page` | integer | no | Page number for pagination, 1-based (default: 1) |
| `query` | string | no | Search query to filter patients by name, phone, or email |

### Example

```lua
local result = app.integrations.weave.list_patients({
  query = "Smith",
  limit = 10
})

for _, patient in ipairs(result.patients) do
  print(patient.id .. ": " .. patient.name)
end
```

---

## get_patient

Retrieve a single patient by ID.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The unique patient identifier |

### Example

```lua
local result = app.integrations.weave.get_patient({
  id = "patient-123"
})

print(result.name .. " — " .. result.email)
```

---

## list_appointments

List appointments with optional date range filtering.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `startDate` | string | no | Start date (ISO 8601, e.g. "2025-01-01") |
| `endDate` | string | no | End date (ISO 8601, e.g. "2025-01-31") |
| `limit` | integer | no | Maximum number of appointments to return (default: 25) |

### Example

```lua
local result = app.integrations.weave.list_appointments({
  startDate = "2025-01-01",
  endDate = "2025-01-31",
  limit = 50
})

for _, appt in ipairs(result.appointments) do
  print(appt.id .. ": " .. appt.patient_name .. " at " .. appt.scheduled_at)
end
```

---

## get_appointment

Retrieve a single appointment by ID.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The unique appointment identifier |

### Example

```lua
local result = app.integrations.weave.get_appointment({
  id = "appt-456"
})

print(result.patient_name .. " — " .. result.scheduled_at .. " (" .. result.status .. ")")
```

---

## list_messages

List patient messages with optional type filtering.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of messages to return (default: 25) |
| `page` | integer | no | Page number for pagination, 1-based (default: 1) |
| `type` | string | no | Filter by message type (e.g. "sms", "email") |

### Example

```lua
local result = app.integrations.weave.list_messages({
  type = "sms",
  limit = 20
})

for _, msg in ipairs(result.messages) do
  print(msg.id .. ": " .. msg.preview)
end
```

---

## get_message

Retrieve a single message by ID.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The unique message identifier |

### Example

```lua
local result = app.integrations.weave.get_message({
  id = "msg-789"
})

print("From: " .. result.sender .. "\n" .. result.body)
```

---

## get_current_user

Get the currently authenticated Weave user profile.

### Parameters

None.

### Example

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

print("Logged in as: " .. result.name .. " (" .. result.email .. ")")
print("Role: " .. result.role)
```

---

## Multi-Account Usage

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

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

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

-- Named accounts
app.integrations.weave.clinic_a.function_name({...})
app.integrations.weave.clinic_b.function_name({...})
```

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

Metadata-Derived Lua Example

local result = app.integrations.weave.weave_list_patients({
  limit = 1,
  page = 1,
  query = "example_query"
})
print(result)

Functions

weave_list_patients

Search and list patients from Weave. Returns patient records with names, contact info, and metadata. Use the query parameter to search by name, phone, or email.

Operation
Read read
Full name
weave.weave_list_patients
ParameterTypeRequiredDescription
limit integer no Maximum number of patients to return (default: 25).
page integer no Page number for pagination, 1-based (default: 1).
query string no Search query to filter patients by name, phone, or email.

weave_get_patient

Retrieve a single patient by ID. Returns full patient details including demographics and contact information.

Operation
Read read
Full name
weave.weave_get_patient
ParameterTypeRequiredDescription
id string yes The unique patient identifier.

weave_list_appointments

List appointments from Weave with optional date range filtering. Returns appointment records with patient info, scheduled times, and status.

Operation
Read read
Full name
weave.weave_list_appointments
ParameterTypeRequiredDescription
startDate string no Start date for the range (ISO 8601, e.g. "2025-01-01").
endDate string no End date for the range (ISO 8601, e.g. "2025-01-31").
limit integer no Maximum number of appointments to return (default: 25).

weave_get_appointment

Retrieve a single appointment by ID. Returns full details including patient info, scheduled time, duration, and status.

Operation
Read read
Full name
weave.weave_get_appointment
ParameterTypeRequiredDescription
id string yes The unique appointment identifier.

weave_list_messages

List patient messages from Weave with optional type filtering. Returns message records with sender, recipient, content previews, and status.

Operation
Read read
Full name
weave.weave_list_messages
ParameterTypeRequiredDescription
limit integer no Maximum number of messages to return (default: 25).
page integer no Page number for pagination, 1-based (default: 1).
type string no Filter by message type (e.g. "sms", "email").

weave_get_message

Retrieve a single message by ID. Returns full message content, sender, recipient, timestamps, and delivery status.

Operation
Read read
Full name
weave.weave_get_message
ParameterTypeRequiredDescription
id string yes The unique message identifier.

weave_get_current_user

Get the currently authenticated Weave user profile. Returns user details including name, email, role, and organization info.

Operation
Read read
Full name
weave.weave_get_current_user
ParameterTypeRequiredDescription
No parameters.