UNPKG

13.4 kBTypeScriptView Raw
1/**
2 * @module botbuilder
3 */
4/**
5 * Copyright (c) Microsoft Corporation. All rights reserved.
6 * Licensed under the MIT License.
7 */
8import { Activity, AttachmentData, ChannelAccount, ConversationParameters, ConversationResourceResponse, ConversationsResult, PagedMembersResult, ResourceResponse, Transcript } from 'botbuilder-core';
9import { AuthenticationConfiguration, ClaimsIdentity, ICredentialProvider } from 'botframework-connector';
10/**
11 * The ChannelServiceHandler implements API to forward activity to a skill and
12 * implements routing ChannelAPI calls from the Skill up through the bot/adapter.
13 */
14export declare class ChannelServiceHandler {
15 private readonly credentialProvider;
16 private readonly authConfig;
17 protected readonly channelService: string;
18 /**
19 * Initializes a new instance of the ChannelServiceHandler class, using a credential provider.
20 * @param credentialProvider The credential provider.
21 * @param authConfig The authentication configuration.
22 * @param channelService A string representing the channel provider.
23 */
24 constructor(credentialProvider: ICredentialProvider, authConfig: AuthenticationConfiguration, channelService?: string);
25 handleSendToConversation(authHeader: string, conversationId: string, activity: Activity): Promise<ResourceResponse>;
26 handleReplyToActivity(authHeader: string, conversationId: string, activityId: string, activity: Activity): Promise<ResourceResponse>;
27 handleUpdateActivity(authHeader: string, conversationId: string, activityId: string, activity: Activity): Promise<ResourceResponse>;
28 handleDeleteActivity(authHeader: string, conversationId: string, activityId: string): Promise<void>;
29 handleGetActivityMembers(authHeader: string, conversationId: string, activityId: string): Promise<ChannelAccount[]>;
30 handleCreateConversation(authHeader: string, parameters: ConversationParameters): Promise<ConversationResourceResponse>;
31 handleGetConversations(authHeader: string, conversationId: string, continuationToken?: string): Promise<ConversationsResult>;
32 handleGetConversationMembers(authHeader: string, conversationId: string): Promise<ChannelAccount[]>;
33 handleGetConversationPagedMembers(authHeader: string, conversationId: string, pageSize?: number, continuationToken?: string): Promise<PagedMembersResult>;
34 handleDeleteConversationMember(authHeader: string, conversationId: string, memberId: string): Promise<void>;
35 handleSendConversationHistory(authHeader: string, conversationId: string, transcript: Transcript): Promise<ResourceResponse>;
36 handleUploadAttachment(authHeader: string, conversationId: string, attachmentUpload: AttachmentData): Promise<ResourceResponse>;
37 /**
38 * SendToConversation() API for Skill.
39 * @remarks
40 * This method allows you to send an activity to the end of a conversation.
41 * This is slightly different from ReplyToActivity().
42 * * SendToConversation(conversationId) - will append the activity to the end
43 * of the conversation according to the timestamp or semantics of the channel.
44 * * ReplyToActivity(conversationId,ActivityId) - adds the activity as a reply
45 * to another activity, if the channel supports it. If the channel does not
46 * support nested replies, ReplyToActivity falls back to SendToConversation.
47 *
48 * Use ReplyToActivity when replying to a specific activity in the
49 * conversation.
50 *
51 * Use SendToConversation in all other cases.
52 * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
53 * @param conversationId
54 * @param activity
55 */
56 protected onSendToConversation(claimsIdentity: ClaimsIdentity, conversationId: string, activity: Activity): Promise<ResourceResponse>;
57 /**
58 * ReplyToActivity() API for Skill.
59 * @remarks
60 * This method allows you to reply to an activity.
61 *
62 * This is slightly different from SendToConversation().
63 * * SendToConversation(conversationId) - will append the activity to the end
64 * of the conversation according to the timestamp or semantics of the channel.
65 * * ReplyToActivity(conversationId,ActivityId) - adds the activity as a reply
66 * to another activity, if the channel supports it. If the channel does not
67 * support nested replies, ReplyToActivity falls back to SendToConversation.
68 *
69 * Use ReplyToActivity when replying to a specific activity in the
70 * conversation.
71 *
72 * Use SendToConversation in all other cases.
73 * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
74 * @param conversationId Conversation ID.
75 * @param activityId activityId the reply is to (OPTIONAL).
76 * @param activity Activity to send.
77 */
78 protected onReplyToActivity(claimsIdentity: ClaimsIdentity, conversationId: string, activityId: string, activity: Activity): Promise<ResourceResponse>;
79 /**
80 * UpdateActivity() API for Skill.
81 * @remarks
82 * Edit an existing activity.
83 *
84 * Some channels allow you to edit an existing activity to reflect the new
85 * state of a bot conversation.
86 *
87 * For example, you can remove buttons after someone has clicked "Approve" button.
88 * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
89 * @param conversationId Conversation ID.
90 * @param activityId activityId to update.
91 * @param activity replacement Activity.
92 */
93 protected onUpdateActivity(claimsIdentity: ClaimsIdentity, conversationId: string, activityId: string, activity: Activity): Promise<ResourceResponse>;
94 /**
95 * DeleteActivity() API for Skill.
96 * @remarks
97 * Delete an existing activity.
98 *
99 * Some channels allow you to delete an existing activity, and if successful
100 * this method will remove the specified activity.
101 *
102 *
103 * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
104 * @param conversationId Conversation ID.
105 * @param activityId activityId to delete.
106 */
107 protected onDeleteActivity(claimsIdentity: ClaimsIdentity, conversationId: string, activityId: string): Promise<void>;
108 /**
109 * GetActivityMembers() API for Skill.
110 * @remarks
111 * Enumerate the members of an activity.
112 *
113 * This REST API takes a ConversationId and a ActivityId, returning an array
114 * of ChannelAccount objects representing the members of the particular
115 * activity in the conversation.
116 * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
117 * @param conversationId Conversation ID.
118 * @param activityId Activity ID.
119 */
120 protected onGetActivityMembers(claimsIdentity: ClaimsIdentity, conversationId: string, activityId: string): Promise<ChannelAccount[]>;
121 /**
122 * CreateConversation() API for Skill.
123 * @remarks
124 * Create a new Conversation.
125 *
126 * POST to this method with a
127 * * Bot being the bot creating the conversation
128 * * IsGroup set to true if this is not a direct message (default is false)
129 * * Array containing the members to include in the conversation
130 *
131 * The return value is a ResourceResponse which contains a conversation id
132 * which is suitable for use in the message payload and REST API uris.
133 *
134 * Most channels only support the semantics of bots initiating a direct
135 * message conversation.
136 * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
137 * @param conversationId Conversation ID.
138 * @param parameters Parameters to create the conversation from.
139 */
140 protected onCreateConversation(claimsIdentity: ClaimsIdentity, parameters: ConversationParameters): Promise<ConversationResourceResponse>;
141 /**
142 * onGetConversations() API for Skill.
143 * @remarks
144 * List the Conversations in which this bot has participated.
145 *
146 * GET from this method with a skip token
147 *
148 * The return value is a ConversationsResult, which contains an array of
149 * ConversationMembers and a skip token. If the skip token is not empty, then
150 * there are further values to be returned. Call this method again with the
151 * returned token to get more values.
152 *
153 * Each ConversationMembers object contains the ID of the conversation and an
154 * array of ChannelAccounts that describe the members of the conversation.
155 * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
156 * @param conversationId Conversation ID.
157 * @param continuationToken Skip or continuation token.
158 */
159 protected onGetConversations(claimsIdentity: ClaimsIdentity, conversationId: string, continuationToken?: string): Promise<ConversationsResult>;
160 /**
161 * getConversationMembers() API for Skill.
162 * @remarks
163 * Enumerate the members of a conversation.
164 *
165 * This REST API takes a ConversationId and returns an array of ChannelAccount
166 * objects representing the members of the conversation.
167 * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
168 * @param conversationId Conversation ID.
169 */
170 protected onGetConversationMembers(claimsIdentity: ClaimsIdentity, conversationId: string): Promise<ChannelAccount[]>;
171 /**
172 * getConversationPagedMembers() API for Skill.
173 * @remarks
174 * Enumerate the members of a conversation one page at a time.
175 *
176 * This REST API takes a ConversationId. Optionally a pageSize and/or
177 * continuationToken can be provided. It returns a PagedMembersResult, which
178 * contains an array
179 * of ChannelAccounts representing the members of the conversation and a
180 * continuation token that can be used to get more values.
181 *
182 * One page of ChannelAccounts records are returned with each call. The number
183 * of records in a page may vary between channels and calls. The pageSize
184 * parameter can be used as
185 * a suggestion. If there are no additional results the response will not
186 * contain a continuation token. If there are no members in the conversation
187 * the Members will be empty or not present in the response.
188 *
189 * A response to a request that has a continuation token from a prior request
190 * may rarely return members from a previous request.
191 * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
192 * @param conversationId Conversation ID.
193 * @param pageSize Suggested page size.
194 * @param continuationToken Continuation Token.
195 */
196 protected onGetConversationPagedMembers(claimsIdentity: ClaimsIdentity, conversationId: string, pageSize?: number, continuationToken?: string): Promise<PagedMembersResult>;
197 /**
198 * DeleteConversationMember() API for Skill.
199 * @remarks
200 * Deletes a member from a conversation.
201 *
202 * This REST API takes a ConversationId and a memberId (of type string) and
203 * removes that member from the conversation. If that member was the last member
204 * of the conversation, the conversation will also be deleted.
205 * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
206 * @param conversationId Conversation ID.
207 * @param memberId ID of the member to delete from this conversation.
208 */
209 protected onDeleteConversationMember(claimsIdentity: ClaimsIdentity, conversationId: string, memberId: string): Promise<void>;
210 /**
211 * SendConversationHistory() API for Skill.
212 * @remarks
213 * This method allows you to upload the historic activities to the
214 * conversation.
215 *
216 * Sender must ensure that the historic activities have unique ids and
217 * appropriate timestamps. The ids are used by the client to deal with
218 * duplicate activities and the timestamps are used by the client to render
219 * the activities in the right order.
220 * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
221 * @param conversationId Conversation ID.
222 * @param transcript Transcript of activities.
223 */
224 protected onSendConversationHistory(claimsIdentity: ClaimsIdentity, conversationId: string, transcript: Transcript): Promise<ResourceResponse>;
225 /**
226 * UploadAttachment() API for Skill.
227 * @remarks
228 * Upload an attachment directly into a channel's blob storage.
229 *
230 * This is useful because it allows you to store data in a compliant store
231 * when dealing with enterprises.
232 *
233 * The response is a ResourceResponse which contains an AttachmentId which is
234 * suitable for using with the attachments API.
235 * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
236 * @param conversationId Conversation ID.
237 * @param attachmentUpload Attachment data.
238 */
239 protected onUploadAttachment(claimsIdentity: ClaimsIdentity, conversationId: string, attachmentUpload: AttachmentData): Promise<ResourceResponse>;
240 private authenticate;
241}
242//# sourceMappingURL=channelServiceHandler.d.ts.map
\No newline at end of file