UNPKG

17.4 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 * Enumerates the members of a conversation one page at a time.
81 *
82 * @param authHeader The authentication header.
83 * @param conversationId The conversation Id.
84 * @param pageSize Suggested page size.
85 * @param continuationToken A continuation token.
86 * @returns A `Promise` representing the [PagedMembersResult](xref:botframework-schema.PagedMembersResult) for the operation.
87 */
88 handleGetConversationPagedMembers(authHeader: string, conversationId: string, pageSize?: number, continuationToken?: string): Promise<PagedMembersResult>;
89 /**
90 * Deletes a member from a conversation.
91 *
92 * @param authHeader The authentication header.
93 * @param conversationId The conversation Id.
94 * @param memberId Id of the member to delete from this conversation.
95 */
96 handleDeleteConversationMember(authHeader: string, conversationId: string, memberId: string): Promise<void>;
97 /**
98 * Uploads the historic activities of the conversation.
99 *
100 * @param authHeader The authentication header.
101 * @param conversationId The conversation Id.
102 * @param transcript [Transcript](xref:botframework-schema.Transcript) of activities.
103 * @returns A `Promise` representing the [ResourceResponse](xref:botframework-schema.ResourceResponse) for the operation.
104 */
105 handleSendConversationHistory(authHeader: string, conversationId: string, transcript: Transcript): Promise<ResourceResponse>;
106 /**
107 * Stores data in a compliant store when dealing with enterprises.
108 *
109 * @param authHeader The authentication header.
110 * @param conversationId The conversation Id.
111 * @param attachmentUpload [AttachmentData](xref:botframework-schema.AttachmentData).
112 * @returns A `Promise` representing the [ResourceResponse](xref:botframework-schema.ResourceResponse) for the operation.
113 */
114 handleUploadAttachment(authHeader: string, conversationId: string, attachmentUpload: AttachmentData): Promise<ResourceResponse>;
115 /**
116 * SendToConversation() API for Skill.
117 *
118 * @remarks
119 * This method allows you to send an activity to the end of a conversation.
120 * This is slightly different from ReplyToActivity().
121 * * SendToConversation(conversationId) - will append the activity to the end
122 * of the conversation according to the timestamp or semantics of the channel.
123 * * ReplyToActivity(conversationId,ActivityId) - adds the activity as a reply
124 * to another activity, if the channel supports it. If the channel does not
125 * support nested replies, ReplyToActivity falls back to SendToConversation.
126 *
127 * Use ReplyToActivity when replying to a specific activity in the
128 * conversation.
129 *
130 * Use SendToConversation in all other cases.
131 * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
132 * @param conversationId Conversation identifier
133 * @param activity Activity to send
134 */
135 protected onSendToConversation(claimsIdentity: ClaimsIdentity, conversationId: string, activity: Activity): Promise<ResourceResponse>;
136 /**
137 * ReplyToActivity() API for Skill.
138 *
139 * @remarks
140 * This method allows you to reply to an activity.
141 *
142 * This is slightly different from SendToConversation().
143 * * SendToConversation(conversationId) - will append the activity to the end
144 * of the conversation according to the timestamp or semantics of the channel.
145 * * ReplyToActivity(conversationId,ActivityId) - adds the activity as a reply
146 * to another activity, if the channel supports it. If the channel does not
147 * support nested replies, ReplyToActivity falls back to SendToConversation.
148 *
149 * Use ReplyToActivity when replying to a specific activity in the
150 * conversation.
151 *
152 * Use SendToConversation in all other cases.
153 * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
154 * @param conversationId Conversation ID.
155 * @param activityId activityId the reply is to (OPTIONAL).
156 * @param activity Activity to send.
157 */
158 protected onReplyToActivity(claimsIdentity: ClaimsIdentity, conversationId: string, activityId: string, activity: Activity): Promise<ResourceResponse>;
159 /**
160 * UpdateActivity() API for Skill.
161 * @remarks
162 * Edit an existing activity.
163 *
164 * Some channels allow you to edit an existing activity to reflect the new
165 * state of a bot conversation.
166 *
167 * For example, you can remove buttons after someone has clicked "Approve" button.
168 * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
169 * @param conversationId Conversation ID.
170 * @param activityId activityId to update.
171 * @param activity replacement Activity.
172 */
173 protected onUpdateActivity(claimsIdentity: ClaimsIdentity, conversationId: string, activityId: string, activity: Activity): Promise<ResourceResponse>;
174 /**
175 * DeleteActivity() API for Skill.
176 *
177 * @remarks
178 * Delete an existing activity.
179 *
180 * Some channels allow you to delete an existing activity, and if successful
181 * this method will remove the specified activity.
182 *
183 *
184 * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
185 * @param conversationId Conversation ID.
186 * @param activityId activityId to delete.
187 */
188 protected onDeleteActivity(claimsIdentity: ClaimsIdentity, conversationId: string, activityId: string): Promise<void>;
189 /**
190 * GetActivityMembers() API for Skill.
191 *
192 * @remarks
193 * Enumerate the members of an activity.
194 *
195 * This REST API takes a ConversationId and a ActivityId, returning an array
196 * of ChannelAccount objects representing the members of the particular
197 * activity in the conversation.
198 * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
199 * @param conversationId Conversation ID.
200 * @param activityId Activity ID.
201 */
202 protected onGetActivityMembers(claimsIdentity: ClaimsIdentity, conversationId: string, activityId: string): Promise<ChannelAccount[]>;
203 /**
204 * CreateConversation() API for Skill.
205 *
206 * @remarks
207 * Create a new Conversation.
208 *
209 * POST to this method with a
210 * * Bot being the bot creating the conversation
211 * * IsGroup set to true if this is not a direct message (default is false)
212 * * Array containing the members to include in the conversation
213 *
214 * The return value is a ResourceResponse which contains a conversation id
215 * which is suitable for use in the message payload and REST API uris.
216 *
217 * Most channels only support the semantics of bots initiating a direct
218 * message conversation.
219 *
220 * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
221 * @param parameters Parameters to create the conversation from.
222 */
223 protected onCreateConversation(claimsIdentity: ClaimsIdentity, parameters: ConversationParameters): Promise<ConversationResourceResponse>;
224 /**
225 * onGetConversations() API for Skill.
226 *
227 * @remarks
228 * List the Conversations in which this bot has participated.
229 *
230 * GET from this method with a skip token
231 *
232 * The return value is a ConversationsResult, which contains an array of
233 * ConversationMembers and a skip token. If the skip token is not empty, then
234 * there are further values to be returned. Call this method again with the
235 * returned token to get more values.
236 *
237 * Each ConversationMembers object contains the ID of the conversation and an
238 * array of ChannelAccounts that describe the members of the conversation.
239 *
240 * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
241 * @param conversationId Conversation ID.
242 * @param continuationToken Skip or continuation token.
243 */
244 protected onGetConversations(claimsIdentity: ClaimsIdentity, conversationId: string, continuationToken?: string): Promise<ConversationsResult>;
245 /**
246 * getConversationMembers() API for Skill.
247 *
248 * @remarks
249 * Enumerate the members of a conversation.
250 *
251 * This REST API takes a ConversationId and returns an array of ChannelAccount
252 * objects representing the members of the conversation.
253 * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
254 * @param conversationId Conversation ID.
255 */
256 protected onGetConversationMembers(claimsIdentity: ClaimsIdentity, conversationId: string): Promise<ChannelAccount[]>;
257 /**
258 * getConversationPagedMembers() API for Skill.
259 *
260 * @remarks
261 * Enumerate the members of a conversation one page at a time.
262 *
263 * This REST API takes a ConversationId. Optionally a pageSize and/or
264 * continuationToken can be provided. It returns a PagedMembersResult, which
265 * contains an array
266 * of ChannelAccounts representing the members of the conversation and a
267 * continuation token that can be used to get more values.
268 *
269 * One page of ChannelAccounts records are returned with each call. The number
270 * of records in a page may vary between channels and calls. The pageSize
271 * parameter can be used as
272 * a suggestion. If there are no additional results the response will not
273 * contain a continuation token. If there are no members in the conversation
274 * the Members will be empty or not present in the response.
275 *
276 * A response to a request that has a continuation token from a prior request
277 * may rarely return members from a previous request.
278 * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
279 * @param conversationId Conversation ID.
280 * @param pageSize Suggested page size.
281 * @param continuationToken Continuation Token.
282 */
283 protected onGetConversationPagedMembers(claimsIdentity: ClaimsIdentity, conversationId: string, pageSize?: number, continuationToken?: string): Promise<PagedMembersResult>;
284 /**
285 * DeleteConversationMember() API for Skill.
286 * @remarks
287 * Deletes a member from a conversation.
288 *
289 * This REST API takes a ConversationId and a memberId (of type string) and
290 * removes that member from the conversation. If that member was the last member
291 * of the conversation, the conversation will also be deleted.
292 * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
293 * @param conversationId Conversation ID.
294 * @param memberId ID of the member to delete from this conversation.
295 */
296 protected onDeleteConversationMember(claimsIdentity: ClaimsIdentity, conversationId: string, memberId: string): Promise<void>;
297 /**
298 * SendConversationHistory() API for Skill.
299 * @remarks
300 * This method allows you to upload the historic activities to the
301 * conversation.
302 *
303 * Sender must ensure that the historic activities have unique ids and
304 * appropriate timestamps. The ids are used by the client to deal with
305 * duplicate activities and the timestamps are used by the client to render
306 * the activities in the right order.
307 * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
308 * @param conversationId Conversation ID.
309 * @param transcript Transcript of activities.
310 */
311 protected onSendConversationHistory(claimsIdentity: ClaimsIdentity, conversationId: string, transcript: Transcript): Promise<ResourceResponse>;
312 /**
313 * UploadAttachment() API for Skill.
314 * @remarks
315 * Upload an attachment directly into a channel's blob storage.
316 *
317 * This is useful because it allows you to store data in a compliant store
318 * when dealing with enterprises.
319 *
320 * The response is a ResourceResponse which contains an AttachmentId which is
321 * suitable for using with the attachments API.
322 * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
323 * @param conversationId Conversation ID.
324 * @param attachmentUpload Attachment data.
325 */
326 protected onUploadAttachment(claimsIdentity: ClaimsIdentity, conversationId: string, attachmentUpload: AttachmentData): Promise<ResourceResponse>;
327 /**
328 * Helper to authenticate the header token and extract the claims.
329 *
330 * @param authHeader HTTP authorization header
331 * @returns a promise resolving to the authorization header claims
332 */
333 protected abstract authenticate(authHeader: string): Promise<ClaimsIdentity>;
334}
335//# sourceMappingURL=channelServiceHandlerBase.d.ts.map
\No newline at end of file