@chat-adapter/teams 4.2.0 → 4.3.0
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 +135 -16
- package/dist/index.d.ts +7 -9
- package/dist/index.js +302 -207
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -20,6 +20,8 @@ const chat = new Chat({
|
|
|
20
20
|
teams: createTeamsAdapter({
|
|
21
21
|
appId: process.env.TEAMS_APP_ID!,
|
|
22
22
|
appPassword: process.env.TEAMS_APP_PASSWORD!,
|
|
23
|
+
appType: "SingleTenant",
|
|
24
|
+
appTenantId: process.env.TEAMS_APP_TENANT_ID!,
|
|
23
25
|
}),
|
|
24
26
|
},
|
|
25
27
|
});
|
|
@@ -36,29 +38,129 @@ chat.onNewMention(async (thread, message) => {
|
|
|
36
38
|
|--------|----------|-------------|
|
|
37
39
|
| `appId` | Yes | Azure Bot App ID |
|
|
38
40
|
| `appPassword` | Yes | Azure Bot App Password |
|
|
39
|
-
| `
|
|
41
|
+
| `appType` | No | `"MultiTenant"` or `"SingleTenant"` (default: `"MultiTenant"`) |
|
|
42
|
+
| `appTenantId` | For SingleTenant | Azure AD Tenant ID |
|
|
40
43
|
|
|
41
|
-
##
|
|
44
|
+
## Environment Variables
|
|
42
45
|
|
|
43
|
-
|
|
46
|
+
```bash
|
|
47
|
+
TEAMS_APP_ID=...
|
|
48
|
+
TEAMS_APP_PASSWORD=...
|
|
49
|
+
TEAMS_APP_TENANT_ID=... # Required for SingleTenant
|
|
50
|
+
```
|
|
44
51
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
## Azure Bot Setup
|
|
53
|
+
|
|
54
|
+
### 1. Create Azure Bot Resource
|
|
55
|
+
|
|
56
|
+
1. Go to [portal.azure.com](https://portal.azure.com)
|
|
57
|
+
2. Click **Create a resource**
|
|
58
|
+
3. Search for **Azure Bot** and select it
|
|
59
|
+
4. Click **Create**
|
|
60
|
+
5. Fill in:
|
|
61
|
+
- **Bot handle**: Unique identifier for your bot
|
|
62
|
+
- **Subscription**: Your Azure subscription
|
|
63
|
+
- **Resource group**: Create new or use existing
|
|
64
|
+
- **Pricing tier**: F0 (free) for testing
|
|
65
|
+
- **Type of App**: **Single Tenant** (recommended for enterprise)
|
|
66
|
+
- **Creation type**: **Create new Microsoft App ID**
|
|
67
|
+
6. Click **Review + create** → **Create**
|
|
68
|
+
|
|
69
|
+
### 2. Get App Credentials
|
|
70
|
+
|
|
71
|
+
1. Go to your newly created Bot resource
|
|
72
|
+
2. Go to **Configuration**
|
|
73
|
+
3. Copy **Microsoft App ID** → `TEAMS_APP_ID`
|
|
74
|
+
4. Click **Manage Password** (next to Microsoft App ID)
|
|
75
|
+
5. In the App Registration page, go to **Certificates & secrets**
|
|
76
|
+
6. Click **New client secret**
|
|
77
|
+
7. Add description, select expiry, click **Add**
|
|
78
|
+
8. Copy the **Value** immediately (shown only once) → `TEAMS_APP_PASSWORD`
|
|
79
|
+
9. Go back to **Overview** and copy **Directory (tenant) ID** → `TEAMS_APP_TENANT_ID`
|
|
80
|
+
|
|
81
|
+
### 3. Configure Messaging Endpoint
|
|
82
|
+
|
|
83
|
+
1. In your Azure Bot resource, go to **Configuration**
|
|
84
|
+
2. Set **Messaging endpoint** to: `https://your-domain.com/api/webhooks/teams`
|
|
85
|
+
3. Click **Apply**
|
|
86
|
+
|
|
87
|
+
### 4. Enable Teams Channel
|
|
88
|
+
|
|
89
|
+
1. In your Azure Bot resource, go to **Channels**
|
|
90
|
+
2. Click **Microsoft Teams**
|
|
91
|
+
3. Accept the terms of service
|
|
92
|
+
4. Click **Apply**
|
|
93
|
+
|
|
94
|
+
### 5. Create Teams App Package
|
|
95
|
+
|
|
96
|
+
Create a `manifest.json` file:
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.16/MicrosoftTeams.schema.json",
|
|
101
|
+
"manifestVersion": "1.16",
|
|
102
|
+
"version": "1.0.0",
|
|
103
|
+
"id": "YOUR_APP_ID_HERE",
|
|
104
|
+
"packageName": "com.yourcompany.chatbot",
|
|
105
|
+
"developer": {
|
|
106
|
+
"name": "Your Company",
|
|
107
|
+
"websiteUrl": "https://your-domain.com",
|
|
108
|
+
"privacyUrl": "https://your-domain.com/privacy",
|
|
109
|
+
"termsOfUseUrl": "https://your-domain.com/terms"
|
|
110
|
+
},
|
|
111
|
+
"name": {
|
|
112
|
+
"short": "Chat Bot",
|
|
113
|
+
"full": "Chat SDK Demo Bot"
|
|
114
|
+
},
|
|
115
|
+
"description": {
|
|
116
|
+
"short": "A chat bot powered by Chat SDK",
|
|
117
|
+
"full": "A chat bot powered by Chat SDK that can respond to messages and commands."
|
|
118
|
+
},
|
|
119
|
+
"icons": {
|
|
120
|
+
"outline": "outline.png",
|
|
121
|
+
"color": "color.png"
|
|
122
|
+
},
|
|
123
|
+
"accentColor": "#FFFFFF",
|
|
124
|
+
"bots": [
|
|
125
|
+
{
|
|
126
|
+
"botId": "YOUR_APP_ID_HERE",
|
|
127
|
+
"scopes": ["personal", "team", "groupchat"],
|
|
128
|
+
"supportsFiles": false,
|
|
129
|
+
"isNotificationOnly": false,
|
|
130
|
+
"commandLists": [
|
|
131
|
+
{
|
|
132
|
+
"scopes": ["personal", "team", "groupchat"],
|
|
133
|
+
"commands": [
|
|
134
|
+
{
|
|
135
|
+
"title": "help",
|
|
136
|
+
"description": "Get help using this bot"
|
|
137
|
+
}
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
],
|
|
143
|
+
"permissions": ["identity", "messageTeamMembers"],
|
|
144
|
+
"validDomains": ["your-domain.com"]
|
|
145
|
+
}
|
|
146
|
+
```
|
|
48
147
|
|
|
49
|
-
|
|
148
|
+
Create icon files (32x32 `outline.png` and 192x192 `color.png`), then zip all three files together.
|
|
50
149
|
|
|
51
|
-
|
|
52
|
-
```
|
|
53
|
-
https://your-domain.com/api/webhooks/teams
|
|
54
|
-
```
|
|
150
|
+
### 6. Upload App to Teams
|
|
55
151
|
|
|
56
|
-
|
|
152
|
+
**For testing (sideloading):**
|
|
153
|
+
1. In Teams, click **Apps** in the sidebar
|
|
154
|
+
2. Click **Manage your apps** → **Upload an app**
|
|
155
|
+
3. Click **Upload a custom app**
|
|
156
|
+
4. Select your zip file
|
|
57
157
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
158
|
+
**For organization-wide deployment:**
|
|
159
|
+
1. Go to [Teams Admin Center](https://admin.teams.microsoft.com)
|
|
160
|
+
2. Go to **Teams apps** → **Manage apps**
|
|
161
|
+
3. Click **Upload new app**
|
|
162
|
+
4. Select your zip file
|
|
163
|
+
5. Go to **Setup policies** to control who can use the app
|
|
62
164
|
|
|
63
165
|
## Features
|
|
64
166
|
|
|
@@ -77,6 +179,23 @@ https://your-domain.com/api/webhooks/teams
|
|
|
77
179
|
- **Adding reactions**: Teams Bot Framework doesn't support bots adding reactions
|
|
78
180
|
- **Message history**: No API to fetch message history
|
|
79
181
|
|
|
182
|
+
## Troubleshooting
|
|
183
|
+
|
|
184
|
+
### "Unauthorized" error
|
|
185
|
+
- Verify `TEAMS_APP_ID` and `TEAMS_APP_PASSWORD` are correct
|
|
186
|
+
- For SingleTenant apps, ensure `TEAMS_APP_TENANT_ID` is set
|
|
187
|
+
- Check that the messaging endpoint URL is correct in Azure
|
|
188
|
+
|
|
189
|
+
### Bot not appearing in Teams
|
|
190
|
+
- Verify the Teams channel is enabled in Azure Bot
|
|
191
|
+
- Check that the app manifest is correctly configured
|
|
192
|
+
- Ensure the app is installed in the workspace/team
|
|
193
|
+
|
|
194
|
+
### Messages not being received
|
|
195
|
+
- Verify the messaging endpoint URL is correct
|
|
196
|
+
- Check that your server is accessible from the internet
|
|
197
|
+
- Review Azure Bot logs for errors
|
|
198
|
+
|
|
80
199
|
## License
|
|
81
200
|
|
|
82
201
|
MIT
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CardElement, BaseFormatConverter, AdapterPostableMessage, Root, Adapter, ChatInstance, WebhookOptions, RawMessage, EmojiValue, FetchOptions, FetchResult, ThreadInfo, Message, FormattedContent } from 'chat';
|
|
1
|
+
import { CardElement, BaseFormatConverter, AdapterPostableMessage, Root, Logger, Adapter, ChatInstance, WebhookOptions, RawMessage, EmojiValue, FetchOptions, FetchResult, ThreadInfo, Message, FormattedContent } from 'chat';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Teams Adaptive Card converter for cross-platform cards.
|
|
@@ -75,6 +75,8 @@ interface TeamsAdapterConfig {
|
|
|
75
75
|
appId: string;
|
|
76
76
|
/** Microsoft App Password */
|
|
77
77
|
appPassword: string;
|
|
78
|
+
/** Logger instance for error reporting */
|
|
79
|
+
logger: Logger;
|
|
78
80
|
/** Microsoft App Type */
|
|
79
81
|
appType?: "MultiTenant" | "SingleTenant";
|
|
80
82
|
/** Microsoft App Tenant ID */
|
|
@@ -127,14 +129,6 @@ declare class TeamsAdapter implements Adapter<TeamsThreadId, unknown> {
|
|
|
127
129
|
private createAttachment;
|
|
128
130
|
private normalizeMentions;
|
|
129
131
|
postMessage(threadId: string, message: AdapterPostableMessage): Promise<RawMessage<unknown>>;
|
|
130
|
-
/**
|
|
131
|
-
* Extract card element from a AdapterPostableMessage if present.
|
|
132
|
-
*/
|
|
133
|
-
private extractCard;
|
|
134
|
-
/**
|
|
135
|
-
* Extract files from a AdapterPostableMessage if present.
|
|
136
|
-
*/
|
|
137
|
-
private extractFiles;
|
|
138
132
|
/**
|
|
139
133
|
* Convert files to Teams attachments.
|
|
140
134
|
* Uses inline data URIs for small files.
|
|
@@ -194,6 +188,10 @@ declare class TeamsAdapter implements Adapter<TeamsThreadId, unknown> {
|
|
|
194
188
|
*/
|
|
195
189
|
private isMessageFromSelf;
|
|
196
190
|
renderFormatted(content: FormattedContent): string;
|
|
191
|
+
/**
|
|
192
|
+
* Convert Teams/BotBuilder errors to standardized AdapterError types.
|
|
193
|
+
*/
|
|
194
|
+
private handleTeamsError;
|
|
197
195
|
}
|
|
198
196
|
declare function createTeamsAdapter(config: TeamsAdapterConfig): TeamsAdapter;
|
|
199
197
|
|