| name | m365-teams |
| description | Trigger this skill for Microsoft Teams collaboration — TEAMS, CHANNELS, MESSAGES, CHATS, and MEMBERS via the m365 CLI. Fire whenever a request is about: gửi/đọc tin nhắn trong channel (send/read channel messages), nhắn tin/chat 1:1 hoặc group chat với người khác, tạo/liệt kê team (create/list teams), tạo/xóa/quản lý channel (manage channels), thêm/bớt/xem thành viên team hoặc channel (members). Trigger phrases: "teams", "gửi tin nhắn teams", "nhắn qua teams", "chat teams", "channel", "kênh", "tạo team", "thành viên team", "member team", "danh sách team". Casual or unaccented phrasing still counts. This skill is about MESSAGING & team/channel structure, NOT file storage — for a team's documents / "Shared Documents" / Files tab use m365-sharepoint, and for personal OneDrive files use m365-onedrive. Non-Microsoft chat (Zalo, Slack) and Outlook email are out of scope.
|
| allowed-tools | ["Bash","Read"] |
m365-teams — Microsoft Teams Management
Prerequisites
which m365 || echo "Chưa cài m365 CLI. Chạy: npm i -g @pnp/cli-microsoft365"
m365 status || echo "Chưa đăng nhập. Chạy: m365 login"
For auth details, see ../m365-shared/references/authentication.md.
Operating Principles
- Output: always
-o json with --query to filter fields
- IDs: most commands accept both
--id and --name — prefer --name for readability, use --id when name is ambiguous
- Message content supports HTML:
--message "<b>Bold</b> text"
- Destructive operations (remove): always confirm with user first
1. Team CRUD
List Teams
m365 teams team list --joined -o json --query '[].{id:id, name:displayName, description:description}'
m365 teams team list --associated -o json --query '[].{id:id, name:displayName}'
m365 teams team list --joined --userName john@contoso.com -o json --query '[].{id:id, name:displayName}'
Get Team Details
m365 teams team get --name "Project Alpha" -o json
m365 teams team get --id "TEAM_ID" -o json
Create Team
m365 teams team add --name "New Team" --description "Description here" --ownerUserNames "owner@contoso.com" --wait -o json
m365 teams team add --name "New Team" --description "Desc" \
--ownerUserNames "owner@contoso.com" \
--memberUserNames "user1@contoso.com,user2@contoso.com" \
--wait -o json
m365 teams team add --name "New Team" --description "Desc" \
--ownerEmails "owner1@contoso.com,owner2@contoso.com" \
--wait -o json
Without --wait, returns an async operation object. With --wait, waits for provisioning and returns the group resource.
2. Channels
List Channels
m365 teams channel list --teamName "Project Alpha" -o json --query '[].{id:id, name:displayName, type:membershipType}'
m365 teams channel list --teamName "Project Alpha" --type private -o json --query '[].{id:id, name:displayName}'
Get Channel
m365 teams channel get --teamName "Project Alpha" --name "General" -o json
m365 teams channel get --teamName "Project Alpha" --primary -o json
Create Channel
m365 teams channel add --teamName "Project Alpha" --name "Design" --description "Design discussions" -o json
m365 teams channel add --teamName "Project Alpha" --name "Leadership" --type private --owner "owner@contoso.com" -o json
m365 teams channel add --teamName "Project Alpha" --name "Cross-team" --type shared --owner "owner@contoso.com" -o json
Remove Channel
m365 teams channel remove --teamId "TEAM_ID" --name "Old Channel" --force
3. Messages (Channel)
List Messages
m365 teams message list --teamId "TEAM_ID" --channelId "CHANNEL_ID" -o json \
--query '[].{id:id, from:from.user.displayName, body:body.content, created:createdDateTime}'
m365 teams message list --teamId "TEAM_ID" --channelId "CHANNEL_ID" \
--since "2024-01-01T00:00:00Z" -o json \
--query '[].{id:id, from:from.user.displayName, body:body.content}'
Send Message
m365 teams message send --teamId "TEAM_ID" --channelId "CHANNEL_ID" --message "Hello team!"
m365 teams message send --teamId "TEAM_ID" --channelId "CHANNEL_ID" \
--message "<h2>Update</h2><p>New release is ready</p>"
Get Message
m365 teams message get --teamId "TEAM_ID" --channelId "CHANNEL_ID" --id "MESSAGE_ID" -o json
Workflow: Gửi tin nhắn vào channel theo tên
TEAM_ID=$(m365 teams team get --name "Project Alpha" -o json --query 'id' | tr -d '"')
CHANNEL_ID=$(m365 teams channel get --teamId "$TEAM_ID" --name "General" -o json --query 'id' | tr -d '"')
m365 teams message send --teamId "$TEAM_ID" --channelId "$CHANNEL_ID" --message "Hello!"
4. Chat (1:1 and Group)
List Chats
m365 teams chat list -o json --query '[].{id:id, topic:topic, type:chatType}'
m365 teams chat list --type oneOnOne -o json --query '[].{id:id, topic:topic}'
m365 teams chat list --type group -o json --query '[].{id:id, topic:topic}'
List Chat Messages
m365 teams chat message list --chatId "CHAT_ID" -o json \
--query '[].{id:id, from:from.user.displayName, body:body.content, created:createdDateTime}'
Send Chat Message
m365 teams chat message send --chatId "CHAT_ID" --message "Hi!"
m365 teams chat message send --userEmails "user@contoso.com" --message "Hi!"
m365 teams chat message send --userEmails "user1@contoso.com,user2@contoso.com" --message "Hello group!"
m365 teams chat message send --chatName "Project Chat" --message "Update here"
m365 teams chat message send --chatId "CHAT_ID" --message "<b>Important</b> update" --contentType html
NOTE: Chat message send only works with delegated permissions (not application).
NOTE: Lệnh gửi thành công thường KHÔNG in stdout — dựa vào exit code (0 = đã gửi), đừng kỳ vọng JSON trả về.
5. Members
List Team Members
m365 teams user list --teamId "TEAM_ID" -o json --query '[].{id:id, name:displayName, email:userPrincipalName, role:userType}'
m365 teams user list --teamId "TEAM_ID" --role Owner -o json --query '[].{name:displayName, email:userPrincipalName}'
m365 teams user list --teamId "TEAM_ID" --role Member -o json
m365 teams user list --teamId "TEAM_ID" --role Guest -o json
List Channel Members
m365 teams channel member list --teamName "Project Alpha" --channelName "General" -o json \
--query '[].{id:id, name:displayName, email:email, role:roles}'
m365 teams channel member list --teamName "Project Alpha" --channelName "Private Channel" --role owner -o json
Add Channel Member
m365 teams channel member add --teamName "Project Alpha" --channelName "Private Channel" \
--userIds "user@contoso.com"
m365 teams channel member add --teamName "Project Alpha" --channelName "Private Channel" \
--userIds "user@contoso.com" --owner
m365 teams channel member add --teamName "Project Alpha" --channelName "Private Channel" \
--userIds "user1@contoso.com,user2@contoso.com"
NOTE: You can only add team members to a private channel. Add them to the team first if needed.
References
| File | Khi nào đọc |
|---|
references/advanced-commands.md | Khi cần Tab, Meeting, App, Settings |
../m365-shared/SKILL.md | Output format, JMESPath, error handling |
../m365-shared/references/authentication.md | Auth methods chi tiết |