KosmoKrator

other

Microsoft Teams Lua API for KosmoKrator Agents

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

8 functions 7 read 1 write Manual OAuth token auth

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.

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:[email protected]"
})

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

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:[email protected]",
  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:[email protected]",
  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:[email protected]",
  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.microsoft_teams_list_teams({})
print(result)

Functions

microsoft_teams_list_teams

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

Operation
Read read
Full name
microsoft-teams.microsoft_teams_list_teams
ParameterTypeRequiredDescription
No parameters.

microsoft_teams_get_team

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

Operation
Read read
Full name
microsoft-teams.microsoft_teams_get_team
ParameterTypeRequiredDescription
team_id string yes The unique identifier of the team.

microsoft_teams_list_channels

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

Operation
Read read
Full name
microsoft-teams.microsoft_teams_list_channels
ParameterTypeRequiredDescription
team_id string yes The unique identifier of the team.

microsoft_teams_get_channel

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

Operation
Read read
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.

microsoft_teams_list_messages

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

Operation
Read read
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).

microsoft_teams_send_message

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

Operation
Write write
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".

microsoft_teams_list_chats

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

Operation
Read read
Full name
microsoft-teams.microsoft_teams_list_chats
ParameterTypeRequiredDescription
limit integer no Maximum number of chats to return (default: 50, max: 50).

microsoft_teams_get_current_user

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

Operation
Read read
Full name
microsoft-teams.microsoft_teams_get_current_user
ParameterTypeRequiredDescription
No parameters.