KosmoKrator

communication

Plivo Lua API for KosmoKrator Agents

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

7 functions 6 read 1 write API token auth

Lua Namespace

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

Plivo — Lua API Reference

list_messages

List SMS messages from Plivo with optional filters and pagination.

Parameters

NameTypeRequiredDescription
limitintegernoMaximum number of results (default: 20, max: 100)
offsetintegernoOffset for pagination (default: 0)
message_directionstringnoFilter by direction: "inbound" or "outbound"
message_statestringnoFilter by state: "queued", "sent", "delivered", "undelivered", "failed"
srcstringnoFilter by source phone number (sender)
dststringnoFilter by destination phone number (recipient)
start_timestringnoFilter messages after this datetime (ISO 8601)
end_timestringnoFilter messages before this datetime (ISO 8601)

Example

local result = app.integrations.plivo.list_messages({
  limit = 10,
  message_direction = "outbound"
})

for _, msg in ipairs(result.objects) do
  print(msg.message_uuid .. ": " .. msg.from .. " -> " .. msg.to .. " [" .. msg.message_state .. "]")
end

send_sms

Send an SMS message via Plivo.

Parameters

NameTypeRequiredDescription
srcstringyesSource phone number (must be a Plivo-hosted number, e.g., "+14155552671")
dststringyesDestination number(s). Single number or multiple separated by "<"
textstringyesThe SMS message text content
typestringnoMessage type: "sms" (default) or "mms"
urlstringnoWebhook URL for delivery status callbacks
logbooleannoWhether to log the message (default: true)

Example

local result = app.integrations.plivo.send_sms({
  src = "+14155552671",
  dst = "+14155552672",
  text = "Hello from Plivo!"
})

print("Message UUID: " .. tostring(result.message_uuid))
print("API ID: " .. tostring(result.api_id))

list_numbers

List phone numbers on your Plivo account.

Parameters

NameTypeRequiredDescription
limitintegernoMaximum number of results (default: 20, max: 100)
offsetintegernoOffset for pagination (default: 0)
number_typestringnoFilter by type: "local", "tollfree", or "national"
servicestringnoFilter by service: "voice", "sms", or "voice,sms"

Example

local result = app.integrations.plivo.list_numbers({
  limit = 20
})

for _, num in ipairs(result.objects) do
  print(num.number .. " (" .. (num.alias or "no alias") .. ")")
end

get_number

Retrieve details of a specific phone number.

Parameters

NameTypeRequiredDescription
numberstringyesThe phone number to retrieve (e.g., "+14155552671")

Example

local result = app.integrations.plivo.get_number({
  number = "+14155552671"
})

print("Number: " .. result.number)
print("Alias: " .. (result.alias or "none"))
print("Application: " .. (result.app_id or "none"))

list_calls

List calls from Plivo with optional filters and pagination.

Parameters

NameTypeRequiredDescription
limitintegernoMaximum number of results (default: 20, max: 100)
offsetintegernoOffset for pagination (default: 0)
call_directionstringnoFilter by direction: "inbound" or "outbound"
call_statestringnoFilter by state: "ringing", "in-progress", "ended", etc.
from_numberstringnoFilter by caller phone number
to_numberstringnoFilter by callee phone number
start_timestringnoFilter calls after this datetime (ISO 8601)
end_timestringnoFilter calls before this datetime (ISO 8601)

Example

local result = app.integrations.plivo.list_calls({
  limit = 10,
  call_direction = "inbound"
})

for _, call in ipairs(result.objects) do
  print(call.call_uuid .. ": " .. call.from .. " -> " .. call.to .. " [" .. call.call_status .. "]")
end

get_call

Retrieve detailed information about a specific call.

Parameters

NameTypeRequiredDescription
call_idstringyesThe unique call UUID

Example

local result = app.integrations.plivo.get_call({
  call_id = "abc123-def456-789"
})

print("From: " .. result.from .. " -> To: " .. result.to)
print("Duration: " .. tostring(result.duration) .. "s")
print("Status: " .. result.call_status)

list_applications

List Plivo voice applications on the account.

Parameters

NameTypeRequiredDescription
limitintegernoMaximum number of results (default: 20, max: 100)
offsetintegernoOffset for pagination (default: 0)

Example

local result = app.integrations.plivo.list_applications({})

for _, app in ipairs(result.objects) do
  print(app.app_id .. ": " .. app.app_name)
  print("  Answer URL: " .. app.answer_url)
end

Multi-Account Usage

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

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

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

-- Named accounts
app.integrations.plivo.us.function_name({...})
app.integrations.plivo.uk.function_name({...})

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

Raw agent markdown
# Plivo — Lua API Reference

## list_messages

List SMS messages from Plivo with optional filters and pagination.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of results (default: 20, max: 100) |
| `offset` | integer | no | Offset for pagination (default: 0) |
| `message_direction` | string | no | Filter by direction: `"inbound"` or `"outbound"` |
| `message_state` | string | no | Filter by state: `"queued"`, `"sent"`, `"delivered"`, `"undelivered"`, `"failed"` |
| `src` | string | no | Filter by source phone number (sender) |
| `dst` | string | no | Filter by destination phone number (recipient) |
| `start_time` | string | no | Filter messages after this datetime (ISO 8601) |
| `end_time` | string | no | Filter messages before this datetime (ISO 8601) |

### Example

```lua
local result = app.integrations.plivo.list_messages({
  limit = 10,
  message_direction = "outbound"
})

for _, msg in ipairs(result.objects) do
  print(msg.message_uuid .. ": " .. msg.from .. " -> " .. msg.to .. " [" .. msg.message_state .. "]")
end
```

---

## send_sms

Send an SMS message via Plivo.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `src` | string | yes | Source phone number (must be a Plivo-hosted number, e.g., `"+14155552671"`) |
| `dst` | string | yes | Destination number(s). Single number or multiple separated by `"<"` |
| `text` | string | yes | The SMS message text content |
| `type` | string | no | Message type: `"sms"` (default) or `"mms"` |
| `url` | string | no | Webhook URL for delivery status callbacks |
| `log` | boolean | no | Whether to log the message (default: true) |

### Example

```lua
local result = app.integrations.plivo.send_sms({
  src = "+14155552671",
  dst = "+14155552672",
  text = "Hello from Plivo!"
})

print("Message UUID: " .. tostring(result.message_uuid))
print("API ID: " .. tostring(result.api_id))
```

---

## list_numbers

List phone numbers on your Plivo account.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of results (default: 20, max: 100) |
| `offset` | integer | no | Offset for pagination (default: 0) |
| `number_type` | string | no | Filter by type: `"local"`, `"tollfree"`, or `"national"` |
| `service` | string | no | Filter by service: `"voice"`, `"sms"`, or `"voice,sms"` |

### Example

```lua
local result = app.integrations.plivo.list_numbers({
  limit = 20
})

for _, num in ipairs(result.objects) do
  print(num.number .. " (" .. (num.alias or "no alias") .. ")")
end
```

---

## get_number

Retrieve details of a specific phone number.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `number` | string | yes | The phone number to retrieve (e.g., `"+14155552671"`) |

### Example

```lua
local result = app.integrations.plivo.get_number({
  number = "+14155552671"
})

print("Number: " .. result.number)
print("Alias: " .. (result.alias or "none"))
print("Application: " .. (result.app_id or "none"))
```

---

## list_calls

List calls from Plivo with optional filters and pagination.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of results (default: 20, max: 100) |
| `offset` | integer | no | Offset for pagination (default: 0) |
| `call_direction` | string | no | Filter by direction: `"inbound"` or `"outbound"` |
| `call_state` | string | no | Filter by state: `"ringing"`, `"in-progress"`, `"ended"`, etc. |
| `from_number` | string | no | Filter by caller phone number |
| `to_number` | string | no | Filter by callee phone number |
| `start_time` | string | no | Filter calls after this datetime (ISO 8601) |
| `end_time` | string | no | Filter calls before this datetime (ISO 8601) |

### Example

```lua
local result = app.integrations.plivo.list_calls({
  limit = 10,
  call_direction = "inbound"
})

for _, call in ipairs(result.objects) do
  print(call.call_uuid .. ": " .. call.from .. " -> " .. call.to .. " [" .. call.call_status .. "]")
end
```

---

## get_call

Retrieve detailed information about a specific call.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `call_id` | string | yes | The unique call UUID |

### Example

```lua
local result = app.integrations.plivo.get_call({
  call_id = "abc123-def456-789"
})

print("From: " .. result.from .. " -> To: " .. result.to)
print("Duration: " .. tostring(result.duration) .. "s")
print("Status: " .. result.call_status)
```

---

## list_applications

List Plivo voice applications on the account.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of results (default: 20, max: 100) |
| `offset` | integer | no | Offset for pagination (default: 0) |

### Example

```lua
local result = app.integrations.plivo.list_applications({})

for _, app in ipairs(result.objects) do
  print(app.app_id .. ": " .. app.app_name)
  print("  Answer URL: " .. app.answer_url)
end
```

---

## Multi-Account Usage

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

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

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

-- Named accounts
app.integrations.plivo.us.function_name({...})
app.integrations.plivo.uk.function_name({...})
```

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

Metadata-Derived Lua Example

local result = app.integrations.plivo.plivo_list_messages({
  limit = 1,
  offset = 1,
  message_direction = "example_message_direction",
  message_state = "example_message_state",
  src = "example_src",
  dst = "example_dst",
  start_time = "example_start_time",
  end_time = "example_end_time"
})
print(result)

Functions

plivo_list_messages

List SMS messages from Plivo with optional filters. Supports filtering by direction (inbound/outbound), message state, date range, sender, and recipient. Returns paginated message records.

Operation
Read read
Full name
plivo.plivo_list_messages
ParameterTypeRequiredDescription
limit integer no Maximum number of results to return (default: 20, max: 100).
offset integer no Offset for pagination (default: 0).
message_direction string no Filter by direction: "inbound" or "outbound".
message_state string no Filter by state: "queued", "sent", "delivered", "undelivered", or "failed".
src string no Filter by source phone number (sender).
dst string no Filter by destination phone number (recipient).
start_time string no Filter messages after this datetime (ISO 8601, e.g., "2026-01-01T00:00:00Z").
end_time string no Filter messages before this datetime (ISO 8601, e.g., "2026-01-31T23:59:59Z").

plivo_send_sms

Send an SMS message via Plivo. Specify a source phone number (must be a Plivo number), one or more destination numbers, and the message text. Returns the message UUID and details.

Operation
Write write
Full name
plivo.plivo_send_sms
ParameterTypeRequiredDescription
src string yes The source phone number (must be a Plivo-hosted number, e.g., "+14155552671").
dst string yes Destination phone number(s). Use a single number or multiple numbers separated by "<" (e.g., "+14155552671" or "+14155552671<+14155552672").
text string yes The SMS message text content.
type string no Message type: "sms" (default) or "mms".
url string no Webhook URL to receive delivery status callbacks.
log boolean no Whether to log the message in Plivo (default: true).

plivo_list_numbers

List phone numbers on your Plivo account. Supports filtering by number type, service, and pagination.

Operation
Read read
Full name
plivo.plivo_list_numbers
ParameterTypeRequiredDescription
limit integer no Maximum number of results to return (default: 20, max: 100).
offset integer no Offset for pagination (default: 0).
number_type string no Filter by number type: "local", "tollfree", or "national".
service string no Filter by service: "voice", "sms", or "voice,sms".

plivo_get_number

Retrieve details of a specific phone number on your Plivo account by its number (e.g., "+14155552671"). Returns alias, application, service type, and other number properties.

Operation
Read read
Full name
plivo.plivo_get_number
ParameterTypeRequiredDescription
number string yes The phone number to retrieve (e.g., "+14155552671").

plivo_list_calls

List calls from Plivo with optional filters. Supports filtering by direction (inbound/outbound), call state, date range, and phone numbers. Returns paginated call records.

Operation
Read read
Full name
plivo.plivo_list_calls
ParameterTypeRequiredDescription
limit integer no Maximum number of results to return (default: 20, max: 100).
offset integer no Offset for pagination (default: 0).
call_direction string no Filter by direction: "inbound" or "outbound".
call_state string no Filter by state: "ringing", "in-progress", "ended", etc.
from_number string no Filter by caller phone number.
to_number string no Filter by callee phone number.
start_time string no Filter calls after this datetime (ISO 8601).
end_time string no Filter calls before this datetime (ISO 8601).

plivo_get_call

Retrieve detailed information about a specific Plivo call by its call UUID. Returns call details including duration, direction, status, and recording information.

Operation
Read read
Full name
plivo.plivo_get_call
ParameterTypeRequiredDescription
call_id string yes The unique call UUID to retrieve.

plivo_list_applications

List Plivo voice applications on the account. Returns application IDs, names, answer/hangup URLs, and associated number counts.

Operation
Read read
Full name
plivo.plivo_list_applications
ParameterTypeRequiredDescription
limit integer no Maximum number of results to return (default: 20, max: 100).
offset integer no Offset for pagination (default: 0).