KosmoKrator

productivity

Microsoft Teams Lua API for KosmoKrator Agents

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

Lua Namespace

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

Inline Lua call
kosmo integrations:lua --eval 'dump(app.integrations.microsoft_teams.list({}))' --json
Read Lua docs headlessly
kosmo integrations:lua --eval 'print(docs.read("microsoft-teams"))' --json
kosmo integrations:lua --eval 'print(docs.read("microsoft-teams.list"))' --json

Workflow file

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

workflow.lua
local microsoft_teams = app.integrations.microsoft_teams
local result = microsoft_teams.list({})

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

MCP-only Lua

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

Microsoft Teams — Lua API Reference

list_teams

List all Microsoft Teams teams the authenticated user has joined.

Parameters

None.

Example

local result = app.integrations["microsoft-teams"].list_teams()

for _, team in ipairs(result.teams) do
  print(team.displayName .. " (id: " .. team.id .. ")")
end

get_team

Get details for a specific team by its ID.

Parameters

NameTypeRequiredDescription
team_idstringyesThe unique identifier of the team

Example

local result = app.integrations["microsoft-teams"].get_team({
  team_id = "02bd9fd6-8f93-4758-87c3-1fb73740a320"
})

print("Team: " .. result.displayName)
print("Description: " .. (result.description or "none"))
print("Visibility: " .. (result.visibility or "unknown"))

list_channels

List all channels in a team.

Parameters

NameTypeRequiredDescription
team_idstringyesThe unique identifier of the team

Example

local result = app.integrations["microsoft-teams"].list_channels({
  team_id = "02bd9fd6-8f93-4758-87c3-1fb73740a320"
})

for _, channel in ipairs(result.channels) do
  print(channel.displayName .. " (" .. channel.membershipType .. ")")
end

get_channel

Get details for a specific channel.

Parameters

NameTypeRequiredDescription
team_idstringyesThe unique identifier of the team
channel_idstringyesThe unique identifier of the channel

Example

local result = app.integrations["microsoft-teams"].get_channel({
  team_id = "02bd9fd6-8f93-4758-87c3-1fb73740a320",
  channel_id = "19:4b6d30ba8c6946c6930961cc94c7b31f@thread.tacv2"
})

print("Channel: " .. result.displayName)
print("Type: " .. (result.membershipType or "standard"))

list_messages

List recent messages in a channel.

Parameters

NameTypeRequiredDescription
team_idstringyesThe unique identifier of the team
channel_idstringyesThe unique identifier of the channel
limitintegernoMaximum number of messages to return (default: 50, max: 50)

Example

local result = app.integrations["microsoft-teams"].list_messages({
  team_id = "02bd9fd6-8f93-4758-87c3-1fb73740a320",
  channel_id = "19:4b6d30ba8c6946c6930961cc94c7b31f@thread.tacv2",
  limit = 10
})

for _, msg in ipairs(result.messages) do
  local sender = msg.sender.displayName or "Unknown"
  print("[" .. msg.createdDateTime .. "] " .. sender .. ": " .. msg.content)
end

send_message

Send a message to a Teams channel.

Parameters

NameTypeRequiredDescription
team_idstringyesThe unique identifier of the team
channel_idstringyesThe unique identifier of the channel
contentstringyesThe message content to send
content_typestringnoContent type: "text" or "html" (default: "text")

Example

-- Send a plain text message
local result = app.integrations["microsoft-teams"].send_message({
  team_id = "02bd9fd6-8f93-4758-87c3-1fb73740a320",
  channel_id = "19:4b6d30ba8c6946c6930961cc94c7b31f@thread.tacv2",
  content = "Hello from the integration!"
})

print(result.message)  -- "Message sent successfully."
-- Send an HTML message
local result = app.integrations["microsoft-teams"].send_message({
  team_id = "02bd9fd6-8f93-4758-87c3-1fb73740a320",
  channel_id = "19:4b6d30ba8c6946c6930961cc94c7b31f@thread.tacv2",
  content = "<b>Important:</b> Deployment complete!",
  content_type = "html"
})

list_chats

List chats for the authenticated user (one-to-one, group, and meeting chats).

Parameters

NameTypeRequiredDescription
limitintegernoMaximum number of chats to return (default: 50, max: 50)

Example

local result = app.integrations["microsoft-teams"].list_chats({
  limit = 10
})

for _, chat in ipairs(result.chats) do
  local label = chat.topic or chat.chatType
  print(label .. " (id: " .. chat.id .. ")")
end

get_current_user

Get the profile of the currently authenticated Microsoft Teams user.

Parameters

None.

Example

local result = app.integrations["microsoft-teams"].get_current_user()

print("Name: " .. result.displayName)
print("Email: " .. (result.mail or result.userPrincipalName))
print("Job Title: " .. (result.jobTitle or "N/A"))

Multi-Account Usage

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

-- Default account (always works)
app.integrations["microsoft-teams"].function_name({...})

-- Explicit default (portable across setups)
app.integrations["microsoft-teams"].default.function_name({...})

-- Named accounts
app.integrations["microsoft-teams"].work.function_name({...})
app.integrations["microsoft-teams"].personal.function_name({...})

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

Raw agent markdown
# Microsoft Teams — Lua API Reference

## list_teams

List all Microsoft Teams teams the authenticated user has joined.

### Parameters

None.

### Example

```lua
local result = app.integrations["microsoft-teams"].list_teams()

for _, team in ipairs(result.teams) do
  print(team.displayName .. " (id: " .. team.id .. ")")
end
```

---

## get_team

Get details for a specific team by its ID.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `team_id` | string | yes | The unique identifier of the team |

### Example

```lua
local result = app.integrations["microsoft-teams"].get_team({
  team_id = "02bd9fd6-8f93-4758-87c3-1fb73740a320"
})

print("Team: " .. result.displayName)
print("Description: " .. (result.description or "none"))
print("Visibility: " .. (result.visibility or "unknown"))
```

---

## list_channels

List all channels in a team.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `team_id` | string | yes | The unique identifier of the team |

### Example

```lua
local result = app.integrations["microsoft-teams"].list_channels({
  team_id = "02bd9fd6-8f93-4758-87c3-1fb73740a320"
})

for _, channel in ipairs(result.channels) do
  print(channel.displayName .. " (" .. channel.membershipType .. ")")
end
```

---

## get_channel

Get details for a specific channel.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `team_id` | string | yes | The unique identifier of the team |
| `channel_id` | string | yes | The unique identifier of the channel |

### Example

```lua
local result = app.integrations["microsoft-teams"].get_channel({
  team_id = "02bd9fd6-8f93-4758-87c3-1fb73740a320",
  channel_id = "19:4b6d30ba8c6946c6930961cc94c7b31f@thread.tacv2"
})

print("Channel: " .. result.displayName)
print("Type: " .. (result.membershipType or "standard"))
```

---

## list_messages

List recent messages in a channel.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `team_id` | string | yes | The unique identifier of the team |
| `channel_id` | string | yes | The unique identifier of the channel |
| `limit` | integer | no | Maximum number of messages to return (default: 50, max: 50) |

### Example

```lua
local result = app.integrations["microsoft-teams"].list_messages({
  team_id = "02bd9fd6-8f93-4758-87c3-1fb73740a320",
  channel_id = "19:4b6d30ba8c6946c6930961cc94c7b31f@thread.tacv2",
  limit = 10
})

for _, msg in ipairs(result.messages) do
  local sender = msg.sender.displayName or "Unknown"
  print("[" .. msg.createdDateTime .. "] " .. sender .. ": " .. msg.content)
end
```

---

## send_message

Send a message to a Teams channel.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `team_id` | string | yes | The unique identifier of the team |
| `channel_id` | string | yes | The unique identifier of the channel |
| `content` | string | yes | The message content to send |
| `content_type` | string | no | Content type: `"text"` or `"html"` (default: `"text"`) |

### Example

```lua
-- Send a plain text message
local result = app.integrations["microsoft-teams"].send_message({
  team_id = "02bd9fd6-8f93-4758-87c3-1fb73740a320",
  channel_id = "19:4b6d30ba8c6946c6930961cc94c7b31f@thread.tacv2",
  content = "Hello from the integration!"
})

print(result.message)  -- "Message sent successfully."
```

```lua
-- Send an HTML message
local result = app.integrations["microsoft-teams"].send_message({
  team_id = "02bd9fd6-8f93-4758-87c3-1fb73740a320",
  channel_id = "19:4b6d30ba8c6946c6930961cc94c7b31f@thread.tacv2",
  content = "<b>Important:</b> Deployment complete!",
  content_type = "html"
})
```

---

## list_chats

List chats for the authenticated user (one-to-one, group, and meeting chats).

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of chats to return (default: 50, max: 50) |

### Example

```lua
local result = app.integrations["microsoft-teams"].list_chats({
  limit = 10
})

for _, chat in ipairs(result.chats) do
  local label = chat.topic or chat.chatType
  print(label .. " (id: " .. chat.id .. ")")
end
```

---

## get_current_user

Get the profile of the currently authenticated Microsoft Teams user.

### Parameters

None.

### Example

```lua
local result = app.integrations["microsoft-teams"].get_current_user()

print("Name: " .. result.displayName)
print("Email: " .. (result.mail or result.userPrincipalName))
print("Job Title: " .. (result.jobTitle or "N/A"))
```

---

## Multi-Account Usage

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

```lua
-- Default account (always works)
app.integrations["microsoft-teams"].function_name({...})

-- Explicit default (portable across setups)
app.integrations["microsoft-teams"].default.function_name({...})

-- Named accounts
app.integrations["microsoft-teams"].work.function_name({...})
app.integrations["microsoft-teams"].personal.function_name({...})
```

All functions are identical across accounts — only the credentials differ.
Metadata-derived Lua example
local result = app.integrations.microsoft_teams.list({})
print(result)

Functions

list Read

List all Microsoft Teams teams the authenticated user has joined. Returns team IDs, names, and descriptions.

Lua path
app.integrations.microsoft_teams.list
Full name
microsoft-teams.microsoft_teams_list_teams
ParameterTypeRequiredDescription
No parameters.
get Read

Get details for a specific Microsoft Teams team by its ID. Returns the team name, description, and other properties.

Lua path
app.integrations.microsoft_teams.get
Full name
microsoft-teams.microsoft_teams_get_team
ParameterTypeRequiredDescription
team_id string yes The unique identifier of the team.
list_channels Read

List all channels in a Microsoft Teams team. Returns channel IDs, names, and descriptions.

Lua path
app.integrations.microsoft_teams.list_channels
Full name
microsoft-teams.microsoft_teams_list_channels
ParameterTypeRequiredDescription
team_id string yes The unique identifier of the team.
get_channel Read

Get details for a specific Microsoft Teams channel by its team and channel ID.

Lua path
app.integrations.microsoft_teams.get_channel
Full name
microsoft-teams.microsoft_teams_get_channel
ParameterTypeRequiredDescription
team_id string yes The unique identifier of the team.
channel_id string yes The unique identifier of the channel.
list_messages Read

List recent messages in a Microsoft Teams channel. Returns message content, sender info, and timestamps.

Lua path
app.integrations.microsoft_teams.list_messages
Full name
microsoft-teams.microsoft_teams_list_messages
ParameterTypeRequiredDescription
team_id string yes The unique identifier of the team.
channel_id string yes The unique identifier of the channel.
limit integer no Maximum number of messages to return (default: 50, max: 50).
send_message Write

Send a message to a Microsoft Teams channel. Supports plain text and HTML content.

Lua path
app.integrations.microsoft_teams.send_message
Full name
microsoft-teams.microsoft_teams_send_message
ParameterTypeRequiredDescription
team_id string yes The unique identifier of the team.
channel_id string yes The unique identifier of the channel.
content string yes The message content to send.
content_type string no The content type: "text" or "html". Defaults to "text".
list_chats Read

List chats for the authenticated Microsoft Teams user. Returns chat IDs, topics, and types (one-to-one, group, or meeting).

Lua path
app.integrations.microsoft_teams.list_chats
Full name
microsoft-teams.microsoft_teams_list_chats
ParameterTypeRequiredDescription
limit integer no Maximum number of chats to return (default: 50, max: 50).
get_current_user Read

Get the profile of the currently authenticated Microsoft Teams user. Returns display name, email, and job title.

Lua path
app.integrations.microsoft_teams.get_current_user
Full name
microsoft-teams.microsoft_teams_get_current_user
ParameterTypeRequiredDescription
No parameters.