or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

authentication.mddirectory-services.mdemail-calendar.mdindex.mdonedrive-files.mdsharepoint-sites.mdteams.md

teams.mddocs/

0

# Teams Integration

1

2

Complete Microsoft Teams functionality including teams, channels, chats, messages, and collaborative features through Microsoft Graph API. Provides comprehensive communication and collaboration capabilities for Microsoft Teams environments.

3

4

## Capabilities

5

6

### Team Management

7

8

Complete team lifecycle management including creation, configuration, membership, and settings with support for team templates and governance policies.

9

10

```python { .api }

11

class Team:

12

"""Microsoft Teams team with comprehensive management capabilities."""

13

14

# Core Properties

15

id: str

16

display_name: str

17

description: str

18

internal_id: str

19

classification: str

20

specialization: str

21

visibility: str # "private" or "public"

22

web_url: str

23

is_archived: bool

24

25

def get(self) -> 'Team':

26

"""

27

Retrieve team information and settings.

28

29

Returns:

30

Team: Updated team object

31

"""

32

33

def update(self) -> 'Team':

34

"""

35

Update team properties and settings.

36

37

Returns:

38

Team: Updated team object

39

"""

40

41

def delete(self) -> None:

42

"""Delete team and associated resources."""

43

44

def archive(self, should_set_spa_as_default_tab: bool = False) -> None:

45

"""

46

Archive team to read-only state.

47

48

Args:

49

should_set_spa_as_default_tab (bool): Set SharePoint as default tab

50

"""

51

52

def unarchive(self) -> None:

53

"""Restore archived team to active state."""

54

55

def clone(self, display_name: str, description: str = None, mail_nickname: str = None, classification: str = None, visibility: str = None, parts_to_clone: List[str] = None) -> 'Team':

56

"""

57

Clone team with specified configuration.

58

59

Args:

60

display_name (str): New team display name

61

description (str, optional): New team description

62

mail_nickname (str, optional): New team mail nickname

63

classification (str, optional): Team classification

64

visibility (str, optional): Team visibility ("private" or "public")

65

parts_to_clone (List[str], optional): Parts to clone ("apps", "tabs", "settings", "channels", "members")

66

67

Returns:

68

Team: Cloned team object

69

"""

70

71

# Navigation Properties

72

@property

73

def channels(self) -> 'ChannelCollection':

74

"""Team channels."""

75

76

@property

77

def members(self) -> 'ConversationMemberCollection':

78

"""Team members."""

79

80

@property

81

def owners(self) -> 'UserCollection':

82

"""Team owners."""

83

84

@property

85

def installed_apps(self) -> 'TeamsAppInstallationCollection':

86

"""Apps installed in the team."""

87

88

@property

89

def operations(self) -> 'TeamsAsyncOperationCollection':

90

"""Async operations for the team."""

91

92

class TeamCollection:

93

"""Collection of Microsoft Teams with query and management capabilities."""

94

95

def get(self) -> 'TeamCollection':

96

"""Retrieve collection of teams."""

97

98

def filter(self, expression: str) -> 'TeamCollection':

99

"""

100

Filter teams by OData expression.

101

102

Args:

103

expression (str): OData filter expression

104

105

Returns:

106

TeamCollection: Filtered collection

107

"""

108

109

def get_by_id(self, team_id: str) -> Team:

110

"""

111

Get team by ID.

112

113

Args:

114

team_id (str): Team unique identifier

115

116

Returns:

117

Team: Team object

118

"""

119

120

def create(self, team_creation_info: Dict[str, Any]) -> Team:

121

"""

122

Create new team.

123

124

Args:

125

team_creation_info (Dict): Team properties and configuration

126

127

Returns:

128

Team: Created team object

129

"""

130

```

131

132

### Channel Management

133

134

Team channel operations including standard channels, private channels, and shared channels with comprehensive message and file management.

135

136

```python { .api }

137

class Channel:

138

"""Teams channel with messaging and file management capabilities."""

139

140

# Core Properties

141

id: str

142

display_name: str

143

description: str

144

email: str

145

web_url: str

146

membership_type: str # "standard", "private", "shared"

147

created_date_time: str

148

149

def get(self) -> 'Channel':

150

"""

151

Retrieve channel information.

152

153

Returns:

154

Channel: Updated channel object

155

"""

156

157

def update(self) -> 'Channel':

158

"""

159

Update channel properties.

160

161

Returns:

162

Channel: Updated channel object

163

"""

164

165

def delete(self) -> None:

166

"""Delete channel."""

167

168

def provision_email(self) -> str:

169

"""

170

Provision email address for channel.

171

172

Returns:

173

str: Channel email address

174

"""

175

176

def remove_email(self) -> None:

177

"""Remove email address from channel."""

178

179

# Navigation Properties

180

@property

181

def messages(self) -> 'ChatMessageCollection':

182

"""Channel messages."""

183

184

@property

185

def members(self) -> 'ConversationMemberCollection':

186

"""Channel members (for private channels)."""

187

188

@property

189

def tabs(self) -> 'TeamsTabCollection':

190

"""Channel tabs."""

191

192

@property

193

def files_folder(self) -> 'DriveItem':

194

"""Channel files folder."""

195

196

class ChannelCollection:

197

"""Collection of team channels with management capabilities."""

198

199

def get(self) -> 'ChannelCollection':

200

"""Retrieve collection of channels."""

201

202

def get_by_id(self, channel_id: str) -> Channel:

203

"""

204

Get channel by ID.

205

206

Args:

207

channel_id (str): Channel unique identifier

208

209

Returns:

210

Channel: Channel object

211

"""

212

213

def add(self, channel_creation_info: Dict[str, Any]) -> Channel:

214

"""

215

Create new channel.

216

217

Args:

218

channel_creation_info (Dict): Channel properties

219

220

Returns:

221

Channel: Created channel object

222

"""

223

```

224

225

### Chat and Messaging

226

227

One-on-one and group chat functionality with comprehensive message management, file attachments, and conversation history.

228

229

```python { .api }

230

class Chat:

231

"""Teams chat conversation with messaging capabilities."""

232

233

# Core Properties

234

id: str

235

topic: str

236

created_date_time: str

237

last_updated_date_time: str

238

chat_type: str # "oneOnOne", "group", "meeting"

239

web_url: str

240

tenant_id: str

241

242

def get(self) -> 'Chat':

243

"""

244

Retrieve chat information.

245

246

Returns:

247

Chat: Updated chat object

248

"""

249

250

def update(self) -> 'Chat':

251

"""

252

Update chat properties.

253

254

Returns:

255

Chat: Updated chat object

256

"""

257

258

def send_activity_notification(self, topic: Dict[str, str], activity_type: str, chain_id: int = None, preview_text: str = None, template_parameters: List[Dict[str, str]] = None) -> None:

259

"""

260

Send activity notification to chat members.

261

262

Args:

263

topic (Dict): Notification topic information

264

activity_type (str): Type of activity

265

chain_id (int, optional): Notification chain ID

266

preview_text (str, optional): Preview text

267

template_parameters (List[Dict], optional): Template parameters

268

"""

269

270

# Navigation Properties

271

@property

272

def messages(self) -> 'ChatMessageCollection':

273

"""Chat messages."""

274

275

@property

276

def members(self) -> 'ConversationMemberCollection':

277

"""Chat members."""

278

279

@property

280

def tabs(self) -> 'TeamsTabCollection':

281

"""Chat tabs."""

282

283

@property

284

def installed_apps(self) -> 'TeamsAppInstallationCollection':

285

"""Apps installed in the chat."""

286

287

class ChatCollection:

288

"""Collection of chats with query capabilities."""

289

290

def get(self) -> 'ChatCollection':

291

"""Retrieve collection of chats."""

292

293

def filter(self, expression: str) -> 'ChatCollection':

294

"""

295

Filter chats by expression.

296

297

Args:

298

expression (str): OData filter expression

299

300

Returns:

301

ChatCollection: Filtered collection

302

"""

303

304

def get_by_id(self, chat_id: str) -> Chat:

305

"""

306

Get chat by ID.

307

308

Args:

309

chat_id (str): Chat unique identifier

310

311

Returns:

312

Chat: Chat object

313

"""

314

315

class ChatMessage:

316

"""Teams chat message with content and attachment support."""

317

318

# Core Properties

319

id: str

320

reply_to_id: str

321

e_tag: str

322

message_type: str # "message", "chatEvent", "typing"

323

created_date_time: str

324

last_modified_date_time: str

325

deleted_date_time: str

326

subject: str

327

summary: str

328

importance: str # "normal", "high", "urgent"

329

locale: str

330

web_url: str

331

332

def get(self) -> 'ChatMessage':

333

"""

334

Retrieve message information.

335

336

Returns:

337

ChatMessage: Updated message object

338

"""

339

340

def update(self) -> 'ChatMessage':

341

"""

342

Update message content.

343

344

Returns:

345

ChatMessage: Updated message object

346

"""

347

348

def delete(self) -> None:

349

"""Soft delete message."""

350

351

def undosoft_delete(self) -> None:

352

"""Undo soft delete of message."""

353

354

def set_reaction(self, reaction_type: str) -> None:

355

"""

356

Add reaction to message.

357

358

Args:

359

reaction_type (str): Reaction type ("like", "angry", "sad", "laugh", "heart", "surprised")

360

"""

361

362

def unset_reaction(self, reaction_type: str) -> None:

363

"""

364

Remove reaction from message.

365

366

Args:

367

reaction_type (str): Reaction type to remove

368

"""

369

370

# Navigation Properties

371

@property

372

def body(self) -> Dict[str, str]:

373

"""Message body content and format."""

374

375

@property

376

def from_(self) -> Dict[str, Any]:

377

"""Message sender information."""

378

379

@property

380

def attachments(self) -> List[Dict[str, Any]]:

381

"""Message attachments."""

382

383

@property

384

def mentions(self) -> List[Dict[str, Any]]:

385

"""User mentions in message."""

386

387

@property

388

def reactions(self) -> List[Dict[str, Any]]:

389

"""Message reactions."""

390

391

@property

392

def replies(self) -> 'ChatMessageCollection':

393

"""Message replies."""

394

395

@property

396

def hosted_contents(self) -> 'ChatMessageHostedContentCollection':

397

"""Hosted content in message."""

398

399

class ChatMessageCollection:

400

"""Collection of chat messages with query and posting capabilities."""

401

402

def get(self) -> 'ChatMessageCollection':

403

"""Retrieve collection of messages."""

404

405

def filter(self, expression: str) -> 'ChatMessageCollection':

406

"""

407

Filter messages by expression.

408

409

Args:

410

expression (str): OData filter expression

411

412

Returns:

413

ChatMessageCollection: Filtered collection

414

"""

415

416

def top(self, count: int) -> 'ChatMessageCollection':

417

"""

418

Limit results to top N messages.

419

420

Args:

421

count (int): Maximum number of messages

422

423

Returns:

424

ChatMessageCollection: Limited collection

425

"""

426

427

def add(self, message_info: Dict[str, Any]) -> ChatMessage:

428

"""

429

Send new message.

430

431

Args:

432

message_info (Dict): Message content and properties

433

434

Returns:

435

ChatMessage: Sent message object

436

"""

437

438

def get_by_id(self, message_id: str) -> ChatMessage:

439

"""

440

Get message by ID.

441

442

Args:

443

message_id (str): Message unique identifier

444

445

Returns:

446

ChatMessage: Message object

447

"""

448

```

449

450

### Team Membership Management

451

452

Comprehensive member and owner management with role assignments, permissions, and guest access control.

453

454

```python { .api }

455

class ConversationMember:

456

"""Team or chat member with role and permission information."""

457

458

# Core Properties

459

id: str

460

display_name: str

461

roles: List[str] # "owner", "member", "guest"

462

visible_history_start_date_time: str

463

464

def get(self) -> 'ConversationMember':

465

"""

466

Retrieve member information.

467

468

Returns:

469

ConversationMember: Updated member object

470

"""

471

472

def update(self) -> 'ConversationMember':

473

"""

474

Update member properties and roles.

475

476

Returns:

477

ConversationMember: Updated member object

478

"""

479

480

def delete(self) -> None:

481

"""Remove member from team or chat."""

482

483

class ConversationMemberCollection:

484

"""Collection of conversation members with management capabilities."""

485

486

def get(self) -> 'ConversationMemberCollection':

487

"""Retrieve collection of members."""

488

489

def add(self, member_info: Dict[str, Any]) -> ConversationMember:

490

"""

491

Add new member to conversation.

492

493

Args:

494

member_info (Dict): Member information and roles

495

496

Returns:

497

ConversationMember: Added member object

498

"""

499

500

def get_by_id(self, member_id: str) -> ConversationMember:

501

"""

502

Get member by ID.

503

504

Args:

505

member_id (str): Member unique identifier

506

507

Returns:

508

ConversationMember: Member object

509

"""

510

```

511

512

## Usage Examples

513

514

### Team Operations

515

516

```python

517

from office365.graph_client import GraphClient

518

519

client = GraphClient.with_client_secret(client_id, client_secret, tenant)

520

521

# Get all teams

522

teams = client.teams.get().execute_query()

523

for team in teams:

524

print(f"Team: {team.display_name} ({team.visibility})")

525

526

# Get specific team

527

team = client.teams.get_by_id("team-id").get().execute_query()

528

print(f"Team: {team.display_name}, Members: {len(team.members)}")

529

530

# Create new team

531

new_team_info = {

532

"displayName": "Marketing Team",

533

"description": "Marketing team collaboration space",

534

"visibility": "private"

535

}

536

new_team = client.teams.create(new_team_info).execute_query()

537

```

538

539

### Channel and Messaging

540

541

```python

542

# Get team channels

543

channels = team.channels.get().execute_query()

544

for channel in channels:

545

print(f"Channel: {channel.display_name} ({channel.membership_type})")

546

547

# Create new channel

548

channel_info = {

549

"displayName": "Project Alpha",

550

"description": "Discussion for Project Alpha",

551

"membershipType": "standard"

552

}

553

new_channel = team.channels.add(channel_info).execute_query()

554

555

# Send message to channel

556

message_info = {

557

"body": {

558

"contentType": "html",

559

"content": "<h1>Welcome to the team!</h1><p>Let's get started on our project.</p>"

560

}

561

}

562

sent_message = new_channel.messages.add(message_info).execute_query()

563

564

# Get channel messages

565

messages = new_channel.messages.top(20).get().execute_query()

566

for message in messages:

567

print(f"From: {message.from_['user']['displayName']}, Content: {message.body['content'][:50]}...")

568

```

569

570

### Chat Operations

571

572

```python

573

# Get user's chats

574

chats = client.me.chats.get().execute_query()

575

for chat in chats:

576

print(f"Chat: {chat.topic or 'No topic'} ({chat.chat_type})")

577

578

# Get chat messages

579

chat = chats[0]

580

chat_messages = chat.messages.top(10).get().execute_query()

581

for message in chat_messages:

582

if message.message_type == "message":

583

print(f"Message: {message.body['content'][:100]}...")

584

585

# Send message to chat

586

chat_message_info = {

587

"body": {

588

"contentType": "text",

589

"content": "Hello everyone! How's the project going?"

590

}

591

}

592

new_message = chat.messages.add(chat_message_info).execute_query()

593

```

594

595

### Team Member Management

596

597

```python

598

# Get team members

599

members = team.members.get().execute_query()

600

for member in members:

601

print(f"Member: {member.display_name}, Roles: {', '.join(member.roles)}")

602

603

# Add new member

604

member_info = {

605

"@odata.type": "#microsoft.graph.aadUserConversationMember",

606

"user@odata.bind": f"https://graph.microsoft.com/v1.0/users/{user_id}",

607

"roles": ["member"]

608

}

609

new_member = team.members.add(member_info).execute_query()

610

611

# Promote member to owner

612

member.roles = ["owner"]

613

member.update().execute_query()

614

```

615

616

## Types

617

618

```python { .api }

619

from typing import Dict, List, Any, Optional

620

621

class TeamSettings:

622

"""Team configuration settings."""

623

624

allow_create_update_channels: bool

625

allow_create_private_channels: bool

626

allow_create_update_remove_tabs: bool

627

allow_create_update_remove_connectors: bool

628

allow_delete_channels: bool

629

allow_add_remove_apps: bool

630

allow_guests: bool

631

allow_team_mentions: bool

632

allow_channel_mentions: bool

633

634

class GuestSettings:

635

"""Team guest access settings."""

636

637

allow_create_update_channels: bool

638

allow_delete_channels: bool

639

640

class MemberSettings:

641

"""Team member permission settings."""

642

643

allow_create_update_channels: bool

644

allow_create_private_channels: bool

645

allow_create_update_remove_tabs: bool

646

allow_create_update_remove_connectors: bool

647

allow_delete_channels: bool

648

allow_add_remove_apps: bool

649

650

class MessagingSettings:

651

"""Team messaging configuration."""

652

653

allow_user_edit_messages: bool

654

allow_user_delete_messages: bool

655

allow_owner_delete_messages: bool

656

allow_team_mentions: bool

657

allow_channel_mentions: bool

658

659

class FunSettings:

660

"""Team fun and entertainment settings."""

661

662

allow_giphy: bool

663

giphy_content_rating: str # "strict", "moderate"

664

allow_stickers_and_memes: bool

665

allow_custom_memes: bool

666

667

class ChatMessageBody:

668

"""Chat message body content."""

669

670

content_type: str # "text", "html"

671

content: str

672

673

class ChatMessageFromIdentitySet:

674

"""Message sender identity information."""

675

676

application: Dict[str, str]

677

device: Dict[str, str]

678

user: Dict[str, str]

679

680

class ChatMessageAttachment:

681

"""Chat message attachment."""

682

683

id: str

684

content_type: str

685

content_url: str

686

content: str

687

name: str

688

thumbnail_url: str

689

690

class ChatMessageMention:

691

"""User mention in chat message."""

692

693

id: int

694

mention_text: str

695

mentioned: Dict[str, Any]

696

697

class ChatMessageReaction:

698

"""Reaction to chat message."""

699

700

reaction_type: str

701

created_date_time: str

702

user: Dict[str, str]

703

```