Agent Messenger
Integrations

Teams

Complete reference for the agent-teams CLI.

Tip: agent-teams is a shortcut for agent-messenger teams.

Quick Start

# 1. Extract credentials from Teams desktop app (zero-config!)
agent-teams auth extract

# 2. Get team snapshot
agent-teams snapshot

# 3. Send a message
agent-teams message send <channel-id> "Hello from AI agent!"

Authentication

Seamless Token Extraction

agent-teams automatically extracts your Microsoft Teams credentials from the desktop app:

agent-teams auth extract

# Use --debug for troubleshooting
agent-teams auth extract --debug

This command:

  • Auto-detects your platform (macOS/Linux/Windows)
  • Extracts Teams access token from the desktop app
  • Validates token against Teams API
  • Discovers ALL joined teams
  • Stores credentials securely in ~/.config/agent-messenger/

⚠️ TOKEN EXPIRY WARNING

Teams tokens expire in 60-90 minutes! Unlike Slack and Discord tokens which last much longer, Microsoft Teams uses short-lived OAuth tokens.

# Check if your token is still valid
agent-teams auth status

# Re-extract when expired (just run extract again)
agent-teams auth extract

Best practices for AI agents:

  • Always check auth status before operations
  • Re-run auth extract if you get 401 errors
  • Consider automating token refresh in long-running workflows

Authentication Commands

# Check auth status (shows expiry time!)
agent-teams auth status

# Logout (clear stored credentials)
agent-teams auth logout

Supported Teams Versions

agent-teams supports both New Teams (WebView2-based, com.microsoft.teams2) and Classic Teams:

VersionmacOSWindowsLinux
New TeamsN/A
Classic Teams

Manual Token Input (Last Resort)

If automatic extraction fails, you can manually provide a token:

agent-teams auth extract --token <your-skype-token>

How to get your token manually:

  1. Open Microsoft Teams in your browser (teams.microsoft.com)
  2. Open Developer Tools (F12 or Cmd+Option+I)
  3. Go to Application > Cookies > https://teams.microsoft.com
  4. Find the cookie named skypetoken_asm
  5. Copy the Value (it's a long string starting with eyJ...)
  6. Run: agent-teams auth extract --token "eyJ..."

Note: Browser tokens also expire in 60-90 minutes. For long-running workflows, you may need to refresh periodically.

Team Management

Teams uses "teams" as the top-level organizational unit. You must select a team before using most commands.

# List all teams
agent-teams team list

# Switch to a different team
agent-teams team switch <team-id>

# Show current team
agent-teams team current

# Get team info
agent-teams team info <team-id>

Commands

Message Commands

# Send a message
agent-teams message send <channel-id> <content>
agent-teams message send abc123-def456 "Hello world"

# List messages
agent-teams message list <channel-id>
agent-teams message list abc123-def456 --limit 50

# Get a specific message
agent-teams message get <channel-id> <message-id>

# Delete a message
agent-teams message delete <channel-id> <message-id> --force

# Reply to a message (thread)
agent-teams message reply <channel-id> <message-id> "Reply content"

Channel Commands

# List channels in current team
agent-teams channel list

# Get channel info
agent-teams channel info <channel-id>

# Get channel message history
agent-teams channel history <channel-id>
agent-teams channel history abc123-def456 --limit 100

User Commands

# List team members
agent-teams user list

# Get user info
agent-teams user info <user-id>

# Get current authenticated user
agent-teams user me

Reaction Commands

# Add reaction
agent-teams reaction add <channel-id> <message-id> <emoji>
agent-teams reaction add abc123-def456 msg789 like

# Remove reaction
agent-teams reaction remove <channel-id> <message-id> <emoji>

# List reactions on a message
agent-teams reaction list <channel-id> <message-id>

File Commands

# Upload file to channel
agent-teams file upload <channel-id> <path>
agent-teams file upload abc123-def456 ./report.pdf

# List files in channel
agent-teams file list <channel-id>

# Get file info
agent-teams file info <channel-id> <file-id>

# Download file
agent-teams file download <file-id> <output-path>

Snapshot Command

Get comprehensive team state for AI agents:

# Full snapshot (channels, members, recent messages)
agent-teams snapshot

# Filtered snapshots
agent-teams snapshot --channels-only
agent-teams snapshot --users-only

# Limit messages per channel
agent-teams snapshot --limit 10

Global Options

All commands support these options:

--pretty      # Pretty-print JSON output (default is compact JSON)
--team <id>   # Use specific team (overrides current team)

Key Differences: Teams vs Discord vs Slack

ConceptSlackDiscordTeams
Server/WorkspaceWorkspaceGuildTeam
Channel ID formatAlphanumeric (C01234567)Numeric snowflakeUUID (abc123-def456-...)
Message ID formatTimestamp (1234567890.123456)Numeric snowflakeUUID
User ID formatAlphanumeric (U01234567)Numeric snowflakeUUID (Azure AD Object ID)
Token lifetimeLong-livedLong-lived60-90 minutes
APISlack Web APIDiscord APITeams Messaging API
ThreadsThread timestampsThread channelsReply chains
Rate limitsModerateModerateStrict

Troubleshooting

Token Expired (401 Unauthorized)

# Teams tokens expire in 60-90 minutes! To refresh:
# 1. Open Microsoft Teams desktop app
# 2. Send any message (this refreshes your session cookies)
# 3. Re-extract:
agent-teams auth extract

"No teams found"

Ensure you're a member of at least one team in the Teams desktop app, then:

agent-teams auth extract --debug

"Channel not found"

Teams channel IDs are UUIDs. Make sure you're using the full ID:

# Get channel list to find correct IDs
agent-teams channel list --pretty

Rate Limiting (429 Too Many Requests)

Teams API has strict rate limits. Wait and retry:

# Add delays between operations in scripts
sleep 2

Desktop App Not Detected

Ensure Teams desktop app is:

  1. Installed (not just web version)
  2. Currently running
  3. Signed in to your account
# Debug extraction
agent-teams auth extract --debug

Permission Errors

Some operations require specific Microsoft 365 permissions. Check with your IT admin if you encounter persistent 403 errors.

AI Agent Integration

See skills/agent-messenger/ directory for:

  • Complete skill documentation
  • Runnable templates

Example: AI Agent Workflow

#!/bin/bash
# Example: Daily standup automation

# 1. Check auth (re-extract if needed)
if ! agent-teams auth status | grep -q "valid"; then
  agent-teams auth extract
fi

# 2. Get team context
agent-teams snapshot --limit 5 > /tmp/teams-context.json

# 3. Send standup reminder
agent-teams message send $STANDUP_CHANNEL "🌅 Good morning! Time for standup."

Token Refresh Pattern for Long-Running Agents

# Wrapper function for token-aware operations
teams_cmd() {
  # Check token validity
  if ! agent-teams auth status 2>/dev/null | grep -q "valid"; then
    agent-teams auth extract
  fi
  agent-teams "$@"
}

# Usage
teams_cmd message send $CHANNEL "Hello!"

On this page