KosmoKrator

email

Microsoft Outlook Lua API for KosmoKrator Agents

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

7 functions 5 read 2 write Manual OAuth token auth

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.

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

NameTypeRequiredDescription
topintegernoMaximum number of messages to return (default: 25, max: 999)
filterstringnoOData filter expression
orderbystringnoOData orderby expression
selectstringnoComma-separated list of properties to include
skipintegernoNumber 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 '[email protected]'"    -- 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 '[email protected]'",
  top = 5
})

get_message

Retrieve a single email message by its id.

Parameters

NameTypeRequiredDescription
message_idstringyesThe unique id of the message
selectstringnoComma-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

NameTypeRequiredDescription
toarrayyesArray of recipient email addresses
subjectstringyesEmail subject line
bodystringyesEmail body content
content_typestringno”HTML” (default) or “Text”
ccarraynoArray of CC email addresses
bccarraynoArray of BCC email addresses
reply_toarraynoArray of reply-to email addresses

Example

app.integrations["microsoft-outlook"].send_message({
  to = {"[email protected]", "[email protected]"},
  subject = "Meeting Tomorrow",
  body = "<p>Hi team,</p><p>Just a reminder about our meeting at 10am.</p>",
  content_type = "HTML",
  cc = {"[email protected]"}
})

list_calendars

List all calendars in the user’s mailbox.

Parameters

NameTypeRequiredDescription
topintegernoMaximum number of calendars to return
selectstringnoComma-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

NameTypeRequiredDescription
topintegernoMaximum number of events to return (default: 25)
filterstringnoOData filter expression
orderbystringnoOData orderby expression
selectstringnoComma-separated list of properties to include
start_date_timestringnoStart of date range (ISO 8601, e.g. “2025-01-01T00:00:00”)
end_date_timestringnoEnd 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

NameTypeRequiredDescription
subjectstringyesEvent subject / title
startstringyesStart date and time (ISO 8601, e.g. “2025-06-15T09:00:00”)
endstringyesEnd date and time (ISO 8601, e.g. “2025-06-15T10:00:00”)
time_zonestringnoIANA time zone (default: “UTC”)
bodystringnoEvent description
body_typestringno”HTML” (default) or “Text”
locationstringnoLocation display name
attendeesarraynoArray of attendee email addresses
is_all_daybooleannoWhether 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 = {"[email protected]", "[email protected]"}
})

print("Created event: " .. event.id)

get_current_user

Get the signed-in user’s profile information.

Parameters

NameTypeRequiredDescription
selectstringnoComma-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 '[email protected]'"    -- 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 '[email protected]'",
  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 = {"[email protected]", "[email protected]"},
  subject = "Meeting Tomorrow",
  body = "<p>Hi team,</p><p>Just a reminder about our meeting at 10am.</p>",
  content_type = "HTML",
  cc = {"[email protected]"}
})
```

---

## 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 = {"[email protected]", "[email protected]"}
})

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.

Metadata-Derived Lua Example

local result = app.integrations.microsoft_outlook.outlook_list_messages({
  top = 1,
  filter = "example_filter",
  orderby = "example_orderby",
  select = "example_select",
  skip = 1
})
print(result)

Functions

outlook_list_messages

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.

Operation
Read read
Full name
microsoft-outlook.outlook_list_messages
ParameterTypeRequiredDescription
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).

outlook_get_message

Retrieve a single email message by its id. Returns the full message including body, sender, recipients, subject, and attachments metadata.

Operation
Read read
Full name
microsoft-outlook.outlook_get_message
ParameterTypeRequiredDescription
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".

outlook_send_message

Send an email message via Outlook. Specify recipients, subject, and body. Supports HTML and plain-text bodies, CC, BCC, and reply-to addresses.

Operation
Write write
Full name
microsoft-outlook.outlook_send_message
ParameterTypeRequiredDescription
to array yes Array of recipient email addresses, e.g. ["[email protected]", "[email protected]"].
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.

outlook_list_calendars

List all calendars in the signed-in user's Outlook mailbox. Returns calendar names, ids, and default calendar indicator.

Operation
Read read
Full name
microsoft-outlook.outlook_list_calendars
ParameterTypeRequiredDescription
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".

outlook_list_events

List upcoming calendar events from the default Outlook calendar. Supports filtering by date range, subject, and more via OData query parameters.

Operation
Read read
Full name
microsoft-outlook.outlook_list_events
ParameterTypeRequiredDescription
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.

outlook_create_event

Create a new event on the default Outlook calendar. Specify subject, start/end time, body, and optionally attendees and location.

Operation
Write write
Full name
microsoft-outlook.outlook_create_event
ParameterTypeRequiredDescription
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. ["[email protected]", "[email protected]"].
is_all_day boolean no Whether this is an all-day event. Defaults to false.

outlook_get_current_user

Get the signed-in user's profile information including display name, email address, and job title. Useful for identifying which account is connected.

Operation
Read read
Full name
microsoft-outlook.outlook_get_current_user
ParameterTypeRequiredDescription
select string no Comma-separated list of properties to include, e.g. "displayName,mail,jobTitle".