@microsoft/agents-hosting-extensions-teams 0.5.1-g2e246ff274 → 0.5.12-g2d752e9b13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# @microsoft/agents-hosting-extensions-teams
|
|
2
|
+
|
|
3
|
+
Microsoft Teams extension for the Microsoft 365 Agents SDK for JavaScript.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @microsoft/agents-hosting-extensions-teams
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
This package provides Teams-specific functionality for building agents in Microsoft Teams. It includes support for:
|
|
14
|
+
|
|
15
|
+
- Message handling (edit, delete, undelete)
|
|
16
|
+
- Meeting events (start, end, participant join/leave)
|
|
17
|
+
- Reactions and screen sharing events
|
|
18
|
+
- Message extensions and task modules
|
|
19
|
+
- Teams information access
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
### Basic Setup
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { AgentApplication, MemoryStorage, TurnContext, TurnState } from '@microsoft/agents-hosting'
|
|
27
|
+
import { startServer } from '@microsoft/agents-hosting-express'
|
|
28
|
+
import { TeamsAgentExtension } from '@microsoft/agents-hosting-extensions-teams'
|
|
29
|
+
|
|
30
|
+
// Create the agent application
|
|
31
|
+
const app = new AgentApplication<TurnState>({ storage: new MemoryStorage() })
|
|
32
|
+
|
|
33
|
+
// Create and register the Teams extension
|
|
34
|
+
const teamsExt = new TeamsAgentExtension(app)
|
|
35
|
+
|
|
36
|
+
app.registerExtension<TeamsAgentExtension>(teamsExt, (tae) => {
|
|
37
|
+
// Configure Teams-specific handlers here
|
|
38
|
+
console.log('Teams extension registered')
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
// Handle messages
|
|
42
|
+
app.onActivity('message', async (context: TurnContext, state: TurnState) => {
|
|
43
|
+
await context.sendActivity(`I received your message: "${context.activity.text}"`)
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
// Start the server
|
|
47
|
+
startServer(app)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Meeting Events
|
|
51
|
+
|
|
52
|
+
Handle various meeting events in Teams:
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
app.registerExtension<TeamsAgentExtension>(teamsExt, (tae) => {
|
|
56
|
+
tae.meeting
|
|
57
|
+
.onMeetingStart(async (context, state) => {
|
|
58
|
+
await context.sendActivity('Meeting started! I\'m here to assist.')
|
|
59
|
+
})
|
|
60
|
+
.onMeetingEnd(async (context, state) => {
|
|
61
|
+
await context.sendActivity('The meeting has ended. Thanks for participating!')
|
|
62
|
+
})
|
|
63
|
+
.onParticipantsJoin(async (context, state) => {
|
|
64
|
+
await context.sendActivity('Welcome to the meeting!')
|
|
65
|
+
})
|
|
66
|
+
.onScreenShareStart(async (context, state) => {
|
|
67
|
+
await context.sendActivity('Screen sharing has started.')
|
|
68
|
+
})
|
|
69
|
+
.onRecordingStarted(async (context, state) => {
|
|
70
|
+
await context.sendActivity('Recording has started.')
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Message Handling
|
|
76
|
+
|
|
77
|
+
Handle message events in Teams:
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
app.registerExtension<TeamsAgentExtension>(teamsExt, (tae) => {
|
|
81
|
+
tae.onMessageEdit(async (context, state) => {
|
|
82
|
+
await context.sendActivity('I noticed you edited your message.')
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
tae.onMessageDelete(async (context, state) => {
|
|
86
|
+
await context.sendActivity('I noticed you deleted a message.')
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
tae.onMessageUndelete(async (context, state) => {
|
|
90
|
+
await context.sendActivity('I noticed you undeleted a message.')
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Message Extensions
|
|
96
|
+
|
|
97
|
+
Work with Teams message extensions:
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
app.registerExtension<TeamsAgentExtension>(teamsExt, (tae) => {
|
|
101
|
+
tae.messageExtension
|
|
102
|
+
.onQuery(async (context, state) => {
|
|
103
|
+
// Handle message extension query
|
|
104
|
+
return {
|
|
105
|
+
composeExtension: {
|
|
106
|
+
type: 'result',
|
|
107
|
+
attachmentLayout: 'list',
|
|
108
|
+
attachments: [
|
|
109
|
+
// Your card attachments here
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
.onSelectItem(async (context, state) => {
|
|
115
|
+
// Handle item selection
|
|
116
|
+
})
|
|
117
|
+
})
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Task Modules
|
|
121
|
+
|
|
122
|
+
Handle Teams task modules:
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
app.registerExtension<TeamsAgentExtension>(teamsExt, (tae) => {
|
|
126
|
+
tae.taskModule
|
|
127
|
+
.onFetch(async (context, state) => {
|
|
128
|
+
// Return task module card
|
|
129
|
+
})
|
|
130
|
+
.onSubmit(async (context, state) => {
|
|
131
|
+
// Handle task module submission
|
|
132
|
+
})
|
|
133
|
+
})
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## License
|
|
137
|
+
|
|
138
|
+
MIT
|
|
139
|
+
|
|
@@ -53,6 +53,7 @@ export declare const messagingExtensionQueryZodSchema: z.ZodObject<{
|
|
|
53
53
|
}>>;
|
|
54
54
|
state: z.ZodOptional<z.ZodString>;
|
|
55
55
|
}, "strip", z.ZodTypeAny, {
|
|
56
|
+
state?: string | undefined;
|
|
56
57
|
commandId?: string | undefined;
|
|
57
58
|
parameters?: {
|
|
58
59
|
value?: any;
|
|
@@ -62,8 +63,8 @@ export declare const messagingExtensionQueryZodSchema: z.ZodObject<{
|
|
|
62
63
|
skip?: number | undefined;
|
|
63
64
|
count?: number | undefined;
|
|
64
65
|
} | undefined;
|
|
65
|
-
state?: string | undefined;
|
|
66
66
|
}, {
|
|
67
|
+
state?: string | undefined;
|
|
67
68
|
commandId?: string | undefined;
|
|
68
69
|
parameters?: {
|
|
69
70
|
value?: any;
|
|
@@ -73,7 +74,6 @@ export declare const messagingExtensionQueryZodSchema: z.ZodObject<{
|
|
|
73
74
|
skip?: number | undefined;
|
|
74
75
|
count?: number | undefined;
|
|
75
76
|
} | undefined;
|
|
76
|
-
state?: string | undefined;
|
|
77
77
|
}>;
|
|
78
78
|
/**
|
|
79
79
|
* Parses the given value as a messaging extension query.
|
|
@@ -68,10 +68,10 @@ class Messages {
|
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
-
await context.sendActivity({
|
|
71
|
+
await context.sendActivity(agents_activity_1.Activity.fromObject({
|
|
72
72
|
value: { body: response, status: 200 },
|
|
73
73
|
type: agents_activity_1.ActivityTypes.InvokeResponse
|
|
74
|
-
});
|
|
74
|
+
}));
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
}, true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../src/messages/messages.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,gEAA8E;AAC9E,8DAAyH;AAGzH;;;;;GAKG;AACH,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B;;OAEG;IACH,6DAAuC,CAAA;AACzC,CAAC,EALW,kBAAkB,kCAAlB,kBAAkB,QAK7B;AAED;;;;GAIG;AACH,MAAa,QAAQ;IAGnB;;;OAGG;IACH,YAAoB,GAA6B;QAC/C,IAAI,CAAC,IAAI,GAAG,GAAG,CAAA;IACjB,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CACV,OAAmG;QAEnG,IAAI,CAAC,I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I,EAAE,UAAU;gCAChB,KAAK,EAAE,MAAM;6BACd;yBACF,CAAA;oBACH,CAAC;oBAED,MAAM,OAAO,CAAC,YAAY,CAAC,0BAAQ,CAAC,UAAU,CAAC;wBAC7C,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAoB;wBACxD,IAAI,EAAE,+BAAa,CAAC,cAAc;qBACnC,CAAC,CAAC,CAAA;gBACL,CAAC;YACH,CAAC;QACH,CAAC,EACD,IAAI,CACL,CAAA;QAED,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;CACF;AA/DD,4BA+DC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@microsoft/agents-hosting-extensions-teams",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.12-g2d752e9b13",
|
|
5
5
|
"homepage": "https://github.com/microsoft/Agents-for-js",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"main": "dist/src/index.js",
|
|
20
20
|
"types": "dist/src/index.d.ts",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@microsoft/agents-hosting": "0.5.
|
|
22
|
+
"@microsoft/agents-hosting": "0.5.12-g2d752e9b13"
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"files": [
|
package/src/messages/messages.ts
CHANGED
|
@@ -76,10 +76,10 @@ export class Messages<TState extends TurnState> {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
await context.sendActivity({
|
|
79
|
+
await context.sendActivity(Activity.fromObject({
|
|
80
80
|
value: { body: response, status: 200 } as InvokeResponse,
|
|
81
81
|
type: ActivityTypes.InvokeResponse
|
|
82
|
-
}
|
|
82
|
+
}))
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
},
|