UNPKG

18.5 kBTypeScriptView Raw
1import { ClaimsIdentity } from 'botframework-connector';
2import { Activity, AttachmentData, ChannelAccount, ConversationParameters, ConversationResourceResponse, ConversationsResult, PagedMembersResult, ResourceResponse, Transcript } from 'botbuilder-core';
3/**
4 * The ChannelServiceHandlerBase implements API to forward activity to a skill and
5 * implements routing ChannelAPI calls from the Skill up through the bot/adapter.
6 */
7export declare abstract class ChannelServiceHandlerBase {
8 /**
9 * Sends an [Activity](xref:botframework-schema.Activity) to the end of a conversation.
10 *
11 * @param authHeader The authentication header.
12 * @param conversationId The conversation Id.
13 * @param activity The [Activity](xref:botframework-schema.Activity) to send.
14 * @returns A `Promise` representing the [ResourceResponse](xref:botframework-schema.ResourceResponse) for the operation.
15 */
16 handleSendToConversation(authHeader: string, conversationId: string, activity: Activity): Promise<ResourceResponse>;
17 /**
18 * Sends a reply to an [Activity](xref:botframework-schema.Activity).
19 *
20 * @param authHeader The authentication header.
21 * @param conversationId The conversation Id.
22 * @param activityId The activity Id the reply is to.
23 * @param activity The [Activity](xref:botframework-schema.Activity) to send.
24 * @returns A `Promise` representing the [ResourceResponse](xref:botframework-schema.ResourceResponse) for the operation.
25 */
26 handleReplyToActivity(authHeader: string, conversationId: string, activityId: string, activity: Activity): Promise<ResourceResponse>;
27 /**
28 * Edits a previously sent existing [Activity](xref:botframework-schema.Activity).
29 *
30 * @param authHeader The authentication header.
31 * @param conversationId The conversation Id.
32 * @param activityId The activity Id to update.
33 * @param activity The replacement [Activity](xref:botframework-schema.Activity).
34 * @returns A `Promise` representing the [ResourceResponse](xref:botframework-schema.ResourceResponse) for the operation.
35 */
36 handleUpdateActivity(authHeader: string, conversationId: string, activityId: string, activity: Activity): Promise<ResourceResponse>;
37 /**
38 * Deletes an existing [Activity](xref:botframework-schema.Activity).
39 *
40 * @param authHeader The authentication header.
41 * @param conversationId The conversation Id.
42 * @param activityId The activity Id to delete.
43 */
44 handleDeleteActivity(authHeader: string, conversationId: string, activityId: string): Promise<void>;
45 /**
46 * Enumerates the members of an [Activity](xref:botframework-schema.Activity).
47 *
48 * @param authHeader The authentication header.
49 * @param conversationId The conversation Id.
50 * @param activityId The activity Id.
51 * @returns The enumerated [ChannelAccount](xref:botframework-schema.ChannelAccount) list.
52 */
53 handleGetActivityMembers(authHeader: string, conversationId: string, activityId: string): Promise<ChannelAccount[]>;
54 /**
55 * Creates a new Conversation.
56 *
57 * @param authHeader The authentication header.
58 * @param parameters [ConversationParameters](xref:botbuilder-core.ConversationParameters) to create the conversation from.
59 * @returns A `Promise` representation for the operation.
60 */
61 handleCreateConversation(authHeader: string, parameters: ConversationParameters): Promise<ConversationResourceResponse>;
62 /**
63 * Lists the Conversations in which the bot has participated.
64 *
65 * @param authHeader The authentication header.
66 * @param conversationId The conversation Id.
67 * @param continuationToken A skip or continuation token.
68 * @returns A `Promise` representation for the operation.
69 */
70 handleGetConversations(authHeader: string, conversationId: string, continuationToken?: string): Promise<ConversationsResult>;
71 /**
72 * Enumerates the members of a conversation.
73 *
74 * @param authHeader The authentication header.
75 * @param conversationId The conversation Id.
76 * @returns The enumerated [ChannelAccount](xref:botframework-schema.ChannelAccount) list.
77 */
78 handleGetConversationMembers(authHeader: string, conversationId: string): Promise<ChannelAccount[]>;
79 /**
80 * Gets the account of a single conversation member.
81 *
82 * @param authHeader The authentication header.
83 * @param userId The user Id.
84 * @param conversationId The conversation Id.
85 * @returns The [ChannelAccount](xref:botframework-schema.ChannelAccount) for the provided user id.
86 */
87 handleGetConversationMember(authHeader: string, userId: string, conversationId: string): Promise<ChannelAccount>;
88 /**
89 * Enumerates the members of a conversation one page at a time.
90 *
91 * @param authHeader The authentication header.
92 * @param conversationId The conversation Id.
93 * @param pageSize Suggested page size.
94 * @param continuationToken A continuation token.
95 * @returns A `Promise` representing the [PagedMembersResult](xref:botframework-schema.PagedMembersResult) for the operation.
96 */
97 handleGetConversationPagedMembers(authHeader: string, conversationId: string, pageSize?: number, continuationToken?: string): Promise<PagedMembersResult>;
98 /**
99 * Deletes a member from a conversation.
100 *
101 * @param authHeader The authentication header.
102 * @param conversationId The conversation Id.
103 * @param memberId Id of the member to delete from this conversation.
104 */
105 handleDeleteConversationMember(authHeader: string, conversationId: string, memberId: string): Promise<void>;
106 /**
107 * Uploads the historic activities of the conversation.
108 *
109 * @param authHeader The authentication header.
110 * @param conversationId The conversation Id.
111 * @param transcript [Transcript](xref:botframework-schema.Transcript) of activities.
112 * @returns A `Promise` representing the [ResourceResponse](xref:botframework-schema.ResourceResponse) for the operation.
113 */
114 handleSendConversationHistory(authHeader: string, conversationId: string, transcript: Transcript): Promise<ResourceResponse>;
115 /**
116 * Stores data in a compliant store when dealing with enterprises.
117 *
118 * @param authHeader The authentication header.
119 * @param conversationId The conversation Id.
120 * @param attachmentUpload [AttachmentData](xref:botframework-schema.AttachmentData).
121 * @returns A `Promise` representing the [ResourceResponse](xref:botframework-schema.ResourceResponse) for the operation.
122 */
123 handleUploadAttachment(authHeader: string, conversationId: string, attachmentUpload: AttachmentData): Promise<ResourceResponse>;
124 /**
125 * SendToConversation() API for Skill.
126 *
127 * @remarks
128 * This method allows you to send an activity to the end of a conversation.
129 * This is slightly different from ReplyToActivity().
130 * SendToConversation(conversationId) - will append the activity to the end
131 * of the conversation according to the timestamp or semantics of the channel.
132 * ReplyToActivity(conversationId,ActivityId) - adds the activity as a reply
133 * to another activity, if the channel supports it. If the channel does not
134 * support nested replies, ReplyToActivity falls back to SendToConversation.
135 *
136 * Use ReplyToActivity when replying to a specific activity in the
137 * conversation.
138 *
139 * Use SendToConversation in all other cases.
140 * @param _claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
141 * @param _conversationId Conversation identifier
142 * @param _activity Activity to send
143 */
144 protected onSendToConversation(_claimsIdentity: ClaimsIdentity, _conversationId: string, _activity: Activity): Promise<ResourceResponse>;
145 /**
146 * ReplyToActivity() API for Skill.
147 *
148 * @remarks
149 * This method allows you to reply to an activity.
150 *
151 * This is slightly different from SendToConversation().
152 * SendToConversation(conversationId) - will append the activity to the end
153 * of the conversation according to the timestamp or semantics of the channel.
154 * ReplyToActivity(conversationId,ActivityId) - adds the activity as a reply
155 * to another activity, if the channel supports it. If the channel does not
156 * support nested replies, ReplyToActivity falls back to SendToConversation.
157 *
158 * Use ReplyToActivity when replying to a specific activity in the
159 * conversation.
160 *
161 * Use SendToConversation in all other cases.
162 * @param _claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
163 * @param _conversationId Conversation ID.
164 * @param _activityId activityId the reply is to (OPTIONAL).
165 * @param _activity Activity to send.
166 */
167 protected onReplyToActivity(_claimsIdentity: ClaimsIdentity, _conversationId: string, _activityId: string, _activity: Activity): Promise<ResourceResponse>;
168 /**
169 * UpdateActivity() API for Skill.
170 *
171 * @remarks
172 * Edit an existing activity.
173 *
174 * Some channels allow you to edit an existing activity to reflect the new
175 * state of a bot conversation.
176 *
177 * For example, you can remove buttons after someone has clicked "Approve" button.
178 * @param _claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
179 * @param _conversationId Conversation ID.
180 * @param _activityId activityId to update.
181 * @param _activity replacement Activity.
182 */
183 protected onUpdateActivity(_claimsIdentity: ClaimsIdentity, _conversationId: string, _activityId: string, _activity: Activity): Promise<ResourceResponse>;
184 /**
185 * DeleteActivity() API for Skill.
186 *
187 * @remarks
188 * Delete an existing activity.
189 *
190 * Some channels allow you to delete an existing activity, and if successful
191 * this method will remove the specified activity.
192 * @param _claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
193 * @param _conversationId Conversation ID.
194 * @param _activityId activityId to delete.
195 */
196 protected onDeleteActivity(_claimsIdentity: ClaimsIdentity, _conversationId: string, _activityId: string): Promise<void>;
197 /**
198 * GetActivityMembers() API for Skill.
199 *
200 * @remarks
201 * Enumerate the members of an activity.
202 *
203 * This REST API takes a ConversationId and a ActivityId, returning an array
204 * of ChannelAccount objects representing the members of the particular
205 * activity in the conversation.
206 * @param _claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
207 * @param _conversationId Conversation ID.
208 * @param _activityId Activity ID.
209 */
210 protected onGetActivityMembers(_claimsIdentity: ClaimsIdentity, _conversationId: string, _activityId: string): Promise<ChannelAccount[]>;
211 /**
212 * CreateConversation() API for Skill.
213 *
214 * @remarks
215 * Create a new Conversation.
216 *
217 * POST to this method with a
218 * Bot being the bot creating the conversation
219 * IsGroup set to true if this is not a direct message (default is false)
220 * Array containing the members to include in the conversation
221 *
222 * The return value is a ResourceResponse which contains a conversation id
223 * which is suitable for use in the message payload and REST API uris.
224 *
225 * Most channels only support the semantics of bots initiating a direct
226 * message conversation.
227 * @param _claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
228 * @param _parameters Parameters to create the conversation from.
229 */
230 protected onCreateConversation(_claimsIdentity: ClaimsIdentity, _parameters: ConversationParameters): Promise<ConversationResourceResponse>;
231 /**
232 * onGetConversations() API for Skill.
233 *
234 * @remarks
235 * List the Conversations in which this bot has participated.
236 *
237 * GET from this method with a skip token
238 *
239 * The return value is a ConversationsResult, which contains an array of
240 * ConversationMembers and a skip token. If the skip token is not empty, then
241 * there are further values to be returned. Call this method again with the
242 * returned token to get more values.
243 *
244 * Each ConversationMembers object contains the ID of the conversation and an
245 * array of ChannelAccounts that describe the members of the conversation.
246 * @param _claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
247 * @param _conversationId Conversation ID.
248 * @param _continuationToken Skip or continuation token.
249 */
250 protected onGetConversations(_claimsIdentity: ClaimsIdentity, _conversationId: string, _continuationToken?: string): Promise<ConversationsResult>;
251 /**
252 * getConversationMembers() API for Skill.
253 *
254 * @remarks
255 * Enumerate the members of a conversation.
256 *
257 * This REST API takes a ConversationId and returns an array of ChannelAccount
258 * objects representing the members of the conversation.
259 * @param _claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
260 * @param _conversationId Conversation ID.
261 */
262 protected onGetConversationMembers(_claimsIdentity: ClaimsIdentity, _conversationId: string): Promise<ChannelAccount[]>;
263 /**
264 * getConversationMember() API for Skill.
265 *
266 * @remarks
267 * Get the account of a single conversation member.
268 *
269 * This REST API takes a ConversationId and UserId and returns the ChannelAccount
270 * object representing the member of the conversation.
271 * @param _claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
272 * @param _userId User ID.
273 * @param _conversationId Conversation ID.
274 */
275 protected onGetConversationMember(_claimsIdentity: ClaimsIdentity, _userId: string, _conversationId: string): Promise<ChannelAccount>;
276 /**
277 * getConversationPagedMembers() API for Skill.
278 *
279 * @remarks
280 * Enumerate the members of a conversation one page at a time.
281 *
282 * This REST API takes a ConversationId. Optionally a pageSize and/or
283 * continuationToken can be provided. It returns a PagedMembersResult, which
284 * contains an array
285 * of ChannelAccounts representing the members of the conversation and a
286 * continuation token that can be used to get more values.
287 *
288 * One page of ChannelAccounts records are returned with each call. The number
289 * of records in a page may vary between channels and calls. The pageSize
290 * parameter can be used as
291 * a suggestion. If there are no additional results the response will not
292 * contain a continuation token. If there are no members in the conversation
293 * the Members will be empty or not present in the response.
294 *
295 * A response to a request that has a continuation token from a prior request
296 * may rarely return members from a previous request.
297 * @param _claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
298 * @param _conversationId Conversation ID.
299 * @param _pageSize Suggested page size.
300 * @param _continuationToken Continuation Token.
301 */
302 protected onGetConversationPagedMembers(_claimsIdentity: ClaimsIdentity, _conversationId: string, _pageSize?: number, _continuationToken?: string): Promise<PagedMembersResult>;
303 /**
304 * DeleteConversationMember() API for Skill.
305 *
306 * @remarks
307 * Deletes a member from a conversation.
308 *
309 * This REST API takes a ConversationId and a memberId (of type string) and
310 * removes that member from the conversation. If that member was the last member
311 * of the conversation, the conversation will also be deleted.
312 * @param _claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
313 * @param _conversationId Conversation ID.
314 * @param _memberId ID of the member to delete from this conversation.
315 */
316 protected onDeleteConversationMember(_claimsIdentity: ClaimsIdentity, _conversationId: string, _memberId: string): Promise<void>;
317 /**
318 * SendConversationHistory() API for Skill.
319 *
320 * @remarks
321 * This method allows you to upload the historic activities to the
322 * conversation.
323 *
324 * Sender must ensure that the historic activities have unique ids and
325 * appropriate timestamps. The ids are used by the client to deal with
326 * duplicate activities and the timestamps are used by the client to render
327 * the activities in the right order.
328 * @param _claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
329 * @param _conversationId Conversation ID.
330 * @param _transcript Transcript of activities.
331 */
332 protected onSendConversationHistory(_claimsIdentity: ClaimsIdentity, _conversationId: string, _transcript: Transcript): Promise<ResourceResponse>;
333 /**
334 * UploadAttachment() API for Skill.
335 *
336 * @remarks
337 * Upload an attachment directly into a channel's blob storage.
338 *
339 * This is useful because it allows you to store data in a compliant store
340 * when dealing with enterprises.
341 *
342 * The response is a ResourceResponse which contains an AttachmentId which is
343 * suitable for using with the attachments API.
344 * @param _claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
345 * @param _conversationId Conversation ID.
346 * @param _attachmentUpload Attachment data.
347 */
348 protected onUploadAttachment(_claimsIdentity: ClaimsIdentity, _conversationId: string, _attachmentUpload: AttachmentData): Promise<ResourceResponse>;
349 /**
350 * Helper to authenticate the header token and extract the claims.
351 *
352 * @param authHeader HTTP authorization header
353 * @returns a promise resolving to the authorization header claims
354 */
355 protected abstract authenticate(authHeader: string): Promise<ClaimsIdentity>;
356}
357//# sourceMappingURL=channelServiceHandlerBase.d.ts.map
\No newline at end of file