productivity
Microsoft Outlook Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the Microsoft Outlook KosmoKrator integration.Lua Namespace
Agents call this integration through app.integrations.microsoft_outlook.*.
Use lua_read_doc("integrations.microsoft-outlook") 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
Microsoft Outlook workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.microsoft_outlook.list_messages({top = 1, filter = "example_filter", orderby = "example_orderby", select = "example_select", skip = 1}))' --json kosmo integrations:lua --eval 'print(docs.read("microsoft-outlook"))' --json
kosmo integrations:lua --eval 'print(docs.read("microsoft-outlook.list_messages"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local microsoft_outlook = app.integrations.microsoft_outlook
local result = microsoft_outlook.list_messages({top = 1, filter = "example_filter", orderby = "example_orderby", select = "example_select", skip = 1})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.microsoft_outlook, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.microsoft_outlook.default.* or app.integrations.microsoft_outlook.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need Microsoft Outlook, 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.
Microsoft Outlook — Lua API Reference
list_messages
List email messages in the signed-in user’s Outlook mailbox.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
top | integer | no | Maximum number of messages to return (default: 25, max: 999) |
filter | string | no | OData filter expression |
orderby | string | no | OData orderby expression |
select | string | no | Comma-separated list of properties to include |
skip | integer | no | Number of messages to skip (for pagination) |
Common Filter Examples
"isRead eq false" -- Unread messages
"receivedDateTime ge 2025-01-01T00:00:00Z" -- Since a date
"from/emailAddress/address eq 'boss@example.com'" -- From a specific sender
"contains(subject, 'invoice')" -- Subject contains keyword
Examples
-- List 10 most recent unread messages
local result = app.integrations["microsoft-outlook"].list_messages({
top = 10,
filter = "isRead eq false",
orderby = "receivedDateTime desc"
})
for _, msg in ipairs(result.messages) do
print(msg.subject .. " from " .. msg.from.emailAddress.address)
end
-- List messages from a specific sender
local result = app.integrations["microsoft-outlook"].list_messages({
filter = "from/emailAddress/address eq 'alice@example.com'",
top = 5
})
get_message
Retrieve a single email message by its id.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
message_id | string | yes | The unique id of the message |
select | string | no | Comma-separated list of properties to include |
Example
local msg = app.integrations["microsoft-outlook"].get_message({
message_id = "AAMkAGI2TG93AAA="
})
print(msg.subject)
print(msg.body.content)
send_message
Send an email message via Outlook.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
to | array | yes | Array of recipient email addresses |
subject | string | yes | Email subject line |
body | string | yes | Email body content |
content_type | string | no | ”HTML” (default) or “Text” |
cc | array | no | Array of CC email addresses |
bcc | array | no | Array of BCC email addresses |
reply_to | array | no | Array of reply-to email addresses |
Example
app.integrations["microsoft-outlook"].send_message({
to = {"alice@example.com", "bob@example.com"},
subject = "Meeting Tomorrow",
body = "<p>Hi team,</p><p>Just a reminder about our meeting at 10am.</p>",
content_type = "HTML",
cc = {"manager@example.com"}
})
list_calendars
List all calendars in the user’s mailbox.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
top | integer | no | Maximum number of calendars to return |
select | string | no | Comma-separated list of properties to include |
Example
local result = app.integrations["microsoft-outlook"].list_calendars()
for _, cal in ipairs(result.calendars) do
print(cal.name .. " (id: " .. cal.id .. ")")
end
list_events
List events on the default Outlook calendar.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
top | integer | no | Maximum number of events to return (default: 25) |
filter | string | no | OData filter expression |
orderby | string | no | OData orderby expression |
select | string | no | Comma-separated list of properties to include |
start_date_time | string | no | Start of date range (ISO 8601, e.g. “2025-01-01T00:00:00”) |
end_date_time | string | no | End of date range (ISO 8601, e.g. “2025-12-31T23:59:59”) |
Examples
-- Get the next 10 upcoming events
local result = app.integrations["microsoft-outlook"].list_events({
top = 10,
orderby = "start/dateTime"
})
for _, evt in ipairs(result.events) do
print(evt.subject .. " at " .. evt.start.dateTime)
end
-- Get events for a specific date range
local result = app.integrations["microsoft-outlook"].list_events({
start_date_time = "2025-06-01T00:00:00",
end_date_time = "2025-06-30T23:59:59",
orderby = "start/dateTime"
})
create_event
Create a new event on the default Outlook calendar.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
subject | string | yes | Event subject / title |
start | string | yes | Start date and time (ISO 8601, e.g. “2025-06-15T09:00:00”) |
end | string | yes | End date and time (ISO 8601, e.g. “2025-06-15T10:00:00”) |
time_zone | string | no | IANA time zone (default: “UTC”) |
body | string | no | Event description |
body_type | string | no | ”HTML” (default) or “Text” |
location | string | no | Location display name |
attendees | array | no | Array of attendee email addresses |
is_all_day | boolean | no | Whether this is an all-day event |
Example
local event = app.integrations["microsoft-outlook"].create_event({
subject = "Team Standup",
start = "2025-06-15T09:00:00",
end = "2025-06-15T09:30:00",
time_zone = "Europe/Amsterdam",
body = "Daily standup meeting",
location = "Conference Room A",
attendees = {"alice@example.com", "bob@example.com"}
})
print("Created event: " .. event.id)
get_current_user
Get the signed-in user’s profile information.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
select | string | no | Comma-separated list of properties to include |
Example
local user = app.integrations["microsoft-outlook"].get_current_user()
print("Name: " .. user.displayName)
print("Email: " .. (user.mail or user.userPrincipalName))
Multi-Account Usage
If you have multiple Microsoft Outlook accounts configured, use account-specific namespaces:
-- Default account (always works)
app.integrations["microsoft-outlook"].function_name({...})
-- Explicit default (portable across setups)
app.integrations["microsoft-outlook"].default.function_name({...})
-- Named accounts
app.integrations["microsoft-outlook"].work.function_name({...})
app.integrations["microsoft-outlook"].personal.function_name({...})
All functions are identical across accounts — only the credentials differ.
Raw agent markdown
# Microsoft Outlook — Lua API Reference
## list_messages
List email messages in the signed-in user's Outlook mailbox.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `top` | integer | no | Maximum number of messages to return (default: 25, max: 999) |
| `filter` | string | no | OData filter expression |
| `orderby` | string | no | OData orderby expression |
| `select` | string | no | Comma-separated list of properties to include |
| `skip` | integer | no | Number of messages to skip (for pagination) |
### Common Filter Examples
```
"isRead eq false" -- Unread messages
"receivedDateTime ge 2025-01-01T00:00:00Z" -- Since a date
"from/emailAddress/address eq 'boss@example.com'" -- From a specific sender
"contains(subject, 'invoice')" -- Subject contains keyword
```
### Examples
```lua
-- List 10 most recent unread messages
local result = app.integrations["microsoft-outlook"].list_messages({
top = 10,
filter = "isRead eq false",
orderby = "receivedDateTime desc"
})
for _, msg in ipairs(result.messages) do
print(msg.subject .. " from " .. msg.from.emailAddress.address)
end
-- List messages from a specific sender
local result = app.integrations["microsoft-outlook"].list_messages({
filter = "from/emailAddress/address eq 'alice@example.com'",
top = 5
})
```
---
## get_message
Retrieve a single email message by its id.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `message_id` | string | yes | The unique id of the message |
| `select` | string | no | Comma-separated list of properties to include |
### Example
```lua
local msg = app.integrations["microsoft-outlook"].get_message({
message_id = "AAMkAGI2TG93AAA="
})
print(msg.subject)
print(msg.body.content)
```
---
## send_message
Send an email message via Outlook.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `to` | array | yes | Array of recipient email addresses |
| `subject` | string | yes | Email subject line |
| `body` | string | yes | Email body content |
| `content_type` | string | no | "HTML" (default) or "Text" |
| `cc` | array | no | Array of CC email addresses |
| `bcc` | array | no | Array of BCC email addresses |
| `reply_to` | array | no | Array of reply-to email addresses |
### Example
```lua
app.integrations["microsoft-outlook"].send_message({
to = {"alice@example.com", "bob@example.com"},
subject = "Meeting Tomorrow",
body = "<p>Hi team,</p><p>Just a reminder about our meeting at 10am.</p>",
content_type = "HTML",
cc = {"manager@example.com"}
})
```
---
## list_calendars
List all calendars in the user's mailbox.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `top` | integer | no | Maximum number of calendars to return |
| `select` | string | no | Comma-separated list of properties to include |
### Example
```lua
local result = app.integrations["microsoft-outlook"].list_calendars()
for _, cal in ipairs(result.calendars) do
print(cal.name .. " (id: " .. cal.id .. ")")
end
```
---
## list_events
List events on the default Outlook calendar.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `top` | integer | no | Maximum number of events to return (default: 25) |
| `filter` | string | no | OData filter expression |
| `orderby` | string | no | OData orderby expression |
| `select` | string | no | Comma-separated list of properties to include |
| `start_date_time` | string | no | Start of date range (ISO 8601, e.g. "2025-01-01T00:00:00") |
| `end_date_time` | string | no | End of date range (ISO 8601, e.g. "2025-12-31T23:59:59") |
### Examples
```lua
-- Get the next 10 upcoming events
local result = app.integrations["microsoft-outlook"].list_events({
top = 10,
orderby = "start/dateTime"
})
for _, evt in ipairs(result.events) do
print(evt.subject .. " at " .. evt.start.dateTime)
end
-- Get events for a specific date range
local result = app.integrations["microsoft-outlook"].list_events({
start_date_time = "2025-06-01T00:00:00",
end_date_time = "2025-06-30T23:59:59",
orderby = "start/dateTime"
})
```
---
## create_event
Create a new event on the default Outlook calendar.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `subject` | string | yes | Event subject / title |
| `start` | string | yes | Start date and time (ISO 8601, e.g. "2025-06-15T09:00:00") |
| `end` | string | yes | End date and time (ISO 8601, e.g. "2025-06-15T10:00:00") |
| `time_zone` | string | no | IANA time zone (default: "UTC") |
| `body` | string | no | Event description |
| `body_type` | string | no | "HTML" (default) or "Text" |
| `location` | string | no | Location display name |
| `attendees` | array | no | Array of attendee email addresses |
| `is_all_day` | boolean | no | Whether this is an all-day event |
### Example
```lua
local event = app.integrations["microsoft-outlook"].create_event({
subject = "Team Standup",
start = "2025-06-15T09:00:00",
end = "2025-06-15T09:30:00",
time_zone = "Europe/Amsterdam",
body = "Daily standup meeting",
location = "Conference Room A",
attendees = {"alice@example.com", "bob@example.com"}
})
print("Created event: " .. event.id)
```
---
## get_current_user
Get the signed-in user's profile information.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `select` | string | no | Comma-separated list of properties to include |
### Example
```lua
local user = app.integrations["microsoft-outlook"].get_current_user()
print("Name: " .. user.displayName)
print("Email: " .. (user.mail or user.userPrincipalName))
```
---
## Multi-Account Usage
If you have multiple Microsoft Outlook accounts configured, use account-specific namespaces:
```lua
-- Default account (always works)
app.integrations["microsoft-outlook"].function_name({...})
-- Explicit default (portable across setups)
app.integrations["microsoft-outlook"].default.function_name({...})
-- Named accounts
app.integrations["microsoft-outlook"].work.function_name({...})
app.integrations["microsoft-outlook"].personal.function_name({...})
```
All functions are identical across accounts — only the credentials differ. local result = app.integrations.microsoft_outlook.list_messages({top = 1, filter = "example_filter", orderby = "example_orderby", select = "example_select", skip = 1})
print(result) Functions
list_messages Read
List email messages in the signed-in user's Outlook mailbox. Supports filtering by subject, sender, date range, and read status. Returns a paginated list of messages with subject, sender, date, and preview.
- Lua path
app.integrations.microsoft_outlook.list_messages- Full name
microsoft-outlook.outlook_list_messages
| Parameter | Type | Required | Description |
|---|---|---|---|
top | integer | no | Maximum number of messages to return (default: 25, max: 999). |
filter | string | no | OData filter expression, e.g. "isRead eq false" or "receivedDateTime ge 2025-01-01T00:00:00Z". |
orderby | string | no | OData orderby expression, e.g. "receivedDateTime desc". |
select | string | no | Comma-separated list of properties to include, e.g. "subject,from,receivedDateTime". |
skip | integer | no | Number of messages to skip (for pagination). |
get_message Read
Retrieve a single email message by its id. Returns the full message including body, sender, recipients, subject, and attachments metadata.
- Lua path
app.integrations.microsoft_outlook.get_message- Full name
microsoft-outlook.outlook_get_message
| Parameter | Type | Required | Description |
|---|---|---|---|
message_id | string | yes | The unique id of the message to retrieve. |
select | string | no | Comma-separated list of properties to include, e.g. "subject,body,from,toRecipients". |
send_message Write
Send an email message via Outlook. Specify recipients, subject, and body. Supports HTML and plain-text bodies, CC, BCC, and reply-to addresses.
- Lua path
app.integrations.microsoft_outlook.send_message- Full name
microsoft-outlook.outlook_send_message
| Parameter | Type | Required | Description |
|---|---|---|---|
to | array | yes | Array of recipient email addresses, e.g. ["alice@example.com", "bob@example.com"]. |
subject | string | yes | The email subject line. |
body | string | yes | The email body content. |
content_type | string | no | Body content type: "HTML" (default) or "Text". |
cc | array | no | Array of CC email addresses. |
bcc | array | no | Array of BCC email addresses. |
reply_to | array | no | Array of reply-to email addresses. |
list_calendars Read
List all calendars in the signed-in user's Outlook mailbox. Returns calendar names, ids, and default calendar indicator.
- Lua path
app.integrations.microsoft_outlook.list_calendars- Full name
microsoft-outlook.outlook_list_calendars
| Parameter | Type | Required | Description |
|---|---|---|---|
top | integer | no | Maximum number of calendars to return (default: 25). |
select | string | no | Comma-separated list of properties to include, e.g. "id,name,isDefaultCalendar". |
list_events Read
List upcoming calendar events from the default Outlook calendar. Supports filtering by date range, subject, and more via OData query parameters.
- Lua path
app.integrations.microsoft_outlook.list_events- Full name
microsoft-outlook.outlook_list_events
| Parameter | Type | Required | Description |
|---|---|---|---|
top | integer | no | Maximum number of events to return (default: 25, max: 999). |
filter | string | no | OData filter expression, e.g. "start/dateTime ge '2025-01-01T00:00:00'" or "isAllDay eq true". |
orderby | string | no | OData orderby expression, e.g. "start/dateTime". |
select | string | no | Comma-separated list of properties to include, e.g. "subject,start,end,location". |
start_date_time | string | no | Start of the date range to list events for (ISO 8601, e.g. "2025-01-01T00:00:00"). Sets $filter automatically when provided. |
end_date_time | string | no | End of the date range to list events for (ISO 8601, e.g. "2025-12-31T23:59:59"). Used with start_date_time. |
create_event Write
Create a new event on the default Outlook calendar. Specify subject, start/end time, body, and optionally attendees and location.
- Lua path
app.integrations.microsoft_outlook.create_event- Full name
microsoft-outlook.outlook_create_event
| Parameter | Type | Required | Description |
|---|---|---|---|
subject | string | yes | The event subject / title. |
start | string | yes | Start date and time in ISO 8601 format, e.g. "2025-06-15T09:00:00". |
end | string | yes | End date and time in ISO 8601 format, e.g. "2025-06-15T10:00:00". |
time_zone | string | no | IANA time zone for start/end, e.g. "Europe/Amsterdam". Defaults to "UTC". |
body | string | no | The event body / description. |
body_type | string | no | Body content type: "HTML" (default) or "Text". |
location | string | no | The display name of the event location. |
attendees | array | no | Array of attendee email addresses, e.g. ["alice@example.com", "bob@example.com"]. |
is_all_day | boolean | no | Whether this is an all-day event. Defaults to false. |
get_current_user Read
Get the signed-in user's profile information including display name, email address, and job title. Useful for identifying which account is connected.
- Lua path
app.integrations.microsoft_outlook.get_current_user- Full name
microsoft-outlook.outlook_get_current_user
| Parameter | Type | Required | Description |
|---|---|---|---|
select | string | no | Comma-separated list of properties to include, e.g. "displayName,mail,jobTitle". |