8
8
CardFactory
9
9
} = require ( 'botbuilder' ) ;
10
10
11
+ /**
12
+ * TeamsStartNewThreadInChannel class extends TeamsActivityHandler
13
+ * and provides functionality to interact with Microsoft Teams,
14
+ * including listing channels, starting new threads, and retrieving team members.
15
+ */
11
16
class TeamsStartNewThreadInChannel extends TeamsActivityHandler {
12
17
constructor ( ) {
13
18
super ( ) ;
@@ -31,18 +36,24 @@ class TeamsStartNewThreadInChannel extends TeamsActivityHandler {
31
36
} ) ;
32
37
}
33
38
39
+ /**
40
+ * Starts a new thread in the current Teams channel.
41
+ * @param {TurnContext } context - The bot context.
42
+ */
34
43
async startNewThreadInChannel ( context ) {
35
44
try {
36
45
const teamsChannelId = context . activity . channelData . channel . id ;
37
46
const activity = MessageFactory . text ( "This will start a new thread in the channel." ) ;
38
47
48
+ // Send a message to the channel and get a reference to the new thread.
39
49
const [ reference ] = await TeamsInfo . sendMessageToTeamsChannel (
40
50
context ,
41
51
activity ,
42
52
teamsChannelId ,
43
53
process . env . MicrosoftAppId
44
54
) ;
45
55
56
+ // Continue the conversation in the new thread.
46
57
await context . adapter . continueConversationAsync (
47
58
process . env . MicrosoftAppId ,
48
59
reference ,
@@ -56,6 +67,10 @@ class TeamsStartNewThreadInChannel extends TeamsActivityHandler {
56
67
}
57
68
}
58
69
70
+ /**
71
+ * Lists all channels in the current team.
72
+ * @param {TurnContext } context - The bot context.
73
+ */
59
74
async listTeamChannels ( context ) {
60
75
try {
61
76
const teamId = context . activity . channelData . team . id ;
@@ -72,6 +87,7 @@ class TeamsStartNewThreadInChannel extends TeamsActivityHandler {
72
87
body : [ { type : "TextBlock" , text : "List of Channels" , weight : "Bolder" , size : "Medium" } ] ,
73
88
} ;
74
89
90
+ // Add each channel name to the card.
75
91
channels . forEach ( ( channel , index ) => {
76
92
cardContent . body . push ( {
77
93
type : "TextBlock" ,
@@ -88,6 +104,10 @@ class TeamsStartNewThreadInChannel extends TeamsActivityHandler {
88
104
}
89
105
}
90
106
107
+ /**
108
+ * Retrieves the details of the user who sent the message.
109
+ * @param {TurnContext } context - The bot context.
110
+ */
91
111
async getTeamMember ( context ) {
92
112
try {
93
113
const aadObjectId = context . activity . from . aadObjectId ;
@@ -122,6 +142,10 @@ class TeamsStartNewThreadInChannel extends TeamsActivityHandler {
122
142
}
123
143
}
124
144
145
+ /**
146
+ * Retrieves all team members in a paginated manner.
147
+ * @param {TurnContext } context - The bot context.
148
+ */
125
149
async getPagedTeamMembers ( context ) {
126
150
try {
127
151
const teamId = context . activity . channelData . team . id ;
0 commit comments