Conversations class
Class representing a Conversations.
Constructors
Conversations(Connector |
Create a Conversations. |
Methods
create |
Create a new Conversation. POST to this method with a
The return value is a ResourceResponse which contains a conversation id which is suitable for use in the message payload and REST API uris. Most channels only support the semantics of bots initiating a direct message conversation. An example of how to do that would be:
|
create |
|
create |
|
delete |
Delete an existing activity. Some channels allow you to delete an existing activity, and if successful this method will remove the specified activity. |
delete |
|
delete |
|
delete |
Deletes a member from a conversation. This REST API takes a ConversationId and a memberId (of type string) and removes that member from the conversation. If that member was the last member of the conversation, the conversation will also be deleted. |
delete |
|
delete |
|
get |
Enumerate the members of an activity. This REST API takes a ConversationId and a ActivityId, returning an array of ChannelAccount objects representing the members of the particular activity in the conversation. |
get |
|
get |
|
get |
|
get |
Enumerate the members of a conversation. This REST API takes a ConversationId and returns an array of ChannelAccount objects representing the members of the conversation. |
get |
|
get |
|
get |
Enumerate the members of a conversation one page at a time. This REST API takes a ConversationId. Optionally a pageSize and/or continuationToken can be provided. It returns a PagedMembersResult, which contains an array of ChannelAccounts representing the members of the conversation and a continuation token that can be used to get more values. One page of ChannelAccounts records are returned with each call. The number of records in a page may vary between channels and calls. The pageSize parameter can be used as a suggestion. If there are no additional results the response will not contain a continuation token. If there are no members in the conversation the Members will be empty or not present in the response. A response to a request that has a continuation token from a prior request may rarely return members from a previous request. |
get |
|
get |
|
get |
List the Conversations in which this bot has participated. GET from this method with a skip token The return value is a ConversationsResult, which contains an array of ConversationMembers and a skip token. If the skip token is not empty, then there are further values to be returned. Call this method again with the returned token to get more values. Each ConversationMembers object contains the ID of the conversation and an array of ChannelAccounts that describe the members of the conversation. |
get |
|
get |
|
reply |
This method allows you to reply to an activity. This is slightly different from SendToConversation().
Use ReplyToActivity when replying to a specific activity in the conversation. Use SendToConversation in all other cases. |
reply |
|
reply |
|
send |
This method allows you to upload the historic activities to the conversation. Sender must ensure that the historic activities have unique ids and appropriate timestamps. The ids are used by the client to deal with duplicate activities and the timestamps are used by the client to render the activities in the right order. |
send |
|
send |
|
send |
This method allows you to send an activity to the end of a conversation. This is slightly different from ReplyToActivity().
Use ReplyToActivity when replying to a specific activity in the conversation. Use SendToConversation in all other cases. |
send |
|
send |
|
update |
Edit an existing activity. Some channels allow you to edit an existing activity to reflect the new state of a bot conversation. For example, you can remove buttons after someone has clicked "Approve" button. |
update |
|
update |
|
upload |
Upload an attachment directly into a channel's blob storage. This is useful because it allows you to store data in a compliant store when dealing with enterprises. The response is a ResourceResponse which contains an AttachmentId which is suitable for using with the attachments API. |
upload |
|
upload |
Constructor Details
Conversations(ConnectorClientContext)
Create a Conversations.
new Conversations(client: ConnectorClientContext)
Parameters
- client
- ConnectorClientContext
Reference to the service client.
Method Details
createConversation(ConversationParameters, RequestOptionsBase)
Create a new Conversation. POST to this method with a
- Bot being the bot creating the conversation
- IsGroup set to true if this is not a direct message (default is false)
- Array containing the members to include in the conversation
The return value is a ResourceResponse which contains a conversation id which is suitable for use in the message payload and REST API uris.
Most channels only support the semantics of bots initiating a direct message conversation. An example of how to do that would be:
const resource = await connector.conversations.createConversation({
bot,
members: [{ id: 'user1' }]
});
await connector.conversations.sendToConversation(resource.Id, ... );
function createConversation(parameters: ConversationParameters, options?: RequestOptionsBase): Promise<Models.ConversationsCreateConversationResponse>
Parameters
- parameters
-
ConversationParameters
Parameters to create the conversation from
- options
-
RequestOptionsBase
Returns
Promise<Models.ConversationsCreateConversationResponse>
Promise<Models.ConversationsCreateConversationResponse>
createConversation(ConversationParameters, RequestOptionsBase, ServiceCallback<ConversationResourceResponse>)
function createConversation(parameters: ConversationParameters, options: RequestOptionsBase, callback: ServiceCallback<ConversationResourceResponse>)
Parameters
- parameters
-
ConversationParameters
Parameters to create the conversation from
- options
-
RequestOptionsBase
The optional parameters
- callback
-
ServiceCallback<ConversationResourceResponse>
The callback
createConversation(ConversationParameters, ServiceCallback<ConversationResourceResponse>)
function createConversation(parameters: ConversationParameters, callback: ServiceCallback<ConversationResourceResponse>)
Parameters
- parameters
-
ConversationParameters
Parameters to create the conversation from
- callback
-
ServiceCallback<ConversationResourceResponse>
The callback
deleteActivity(string, string, RequestOptionsBase)
Delete an existing activity. Some channels allow you to delete an existing activity, and if successful this method will remove the specified activity.
function deleteActivity(conversationId: string, activityId: string, options?: RequestOptionsBase): Promise<RestResponse>
Parameters
- conversationId
-
string
Conversation ID
- activityId
-
string
activityId to delete
- options
-
RequestOptionsBase
Returns
Promise<RestResponse>
Promise<msRest.RestResponse>
deleteActivity(string, string, RequestOptionsBase, ServiceCallback<void>)
function deleteActivity(conversationId: string, activityId: string, options: RequestOptionsBase, callback: ServiceCallback<void>)
Parameters
- conversationId
-
string
Conversation ID
- activityId
-
string
activityId to delete
- options
-
RequestOptionsBase
The optional parameters
- callback
-
ServiceCallback<void>
The callback
deleteActivity(string, string, ServiceCallback<void>)
function deleteActivity(conversationId: string, activityId: string, callback: ServiceCallback<void>)
Parameters
- conversationId
-
string
Conversation ID
- activityId
-
string
activityId to delete
- callback
-
ServiceCallback<void>
The callback
deleteConversationMember(string, string, RequestOptionsBase)
Deletes a member from a conversation. This REST API takes a ConversationId and a memberId (of type string) and removes that member from the conversation. If that member was the last member of the conversation, the conversation will also be deleted.
function deleteConversationMember(conversationId: string, memberId: string, options?: RequestOptionsBase): Promise<RestResponse>
Parameters
- conversationId
-
string
Conversation ID
- memberId
-
string
ID of the member to delete from this conversation
- options
-
RequestOptionsBase
Returns
Promise<RestResponse>
Promise<msRest.RestResponse>
deleteConversationMember(string, string, RequestOptionsBase, ServiceCallback<void>)
function deleteConversationMember(conversationId: string, memberId: string, options: RequestOptionsBase, callback: ServiceCallback<void>)
Parameters
- conversationId
-
string
Conversation ID
- memberId
-
string
ID of the member to delete from this conversation
- options
-
RequestOptionsBase
The optional parameters
- callback
-
ServiceCallback<void>
The callback
deleteConversationMember(string, string, ServiceCallback<void>)
function deleteConversationMember(conversationId: string, memberId: string, callback: ServiceCallback<void>)
Parameters
- conversationId
-
string
Conversation ID
- memberId
-
string
ID of the member to delete from this conversation
- callback
-
ServiceCallback<void>
The callback
getActivityMembers(string, string, RequestOptionsBase)
Enumerate the members of an activity. This REST API takes a ConversationId and a ActivityId, returning an array of ChannelAccount objects representing the members of the particular activity in the conversation.
function getActivityMembers(conversationId: string, activityId: string, options?: RequestOptionsBase): Promise<Models.ConversationsGetActivityMembersResponse>
Parameters
- conversationId
-
string
Conversation ID
- activityId
-
string
Activity ID
- options
-
RequestOptionsBase
Returns
Promise<Models.ConversationsGetActivityMembersResponse>
Promise<Models.ConversationsGetActivityMembersResponse>
getActivityMembers(string, string, RequestOptionsBase, ServiceCallback<ChannelAccount[]>)
function getActivityMembers(conversationId: string, activityId: string, options: RequestOptionsBase, callback: ServiceCallback<ChannelAccount[]>)
Parameters
- conversationId
-
string
Conversation ID
- activityId
-
string
Activity ID
- options
-
RequestOptionsBase
The optional parameters
- callback
-
ServiceCallback<ChannelAccount[]>
The callback
getActivityMembers(string, string, ServiceCallback<ChannelAccount[]>)
function getActivityMembers(conversationId: string, activityId: string, callback: ServiceCallback<ChannelAccount[]>)
Parameters
- conversationId
-
string
Conversation ID
- activityId
-
string
Activity ID
- callback
-
ServiceCallback<ChannelAccount[]>
The callback
getConversationMember(string, string, RequestOptionsBase | ServiceCallback<ChannelAccount[]>, ServiceCallback<ChannelAccount[]>)
function getConversationMember(conversationId: string, memberId: string, options?: RequestOptionsBase | ServiceCallback<ChannelAccount[]>, callback?: ServiceCallback<ChannelAccount[]>): Promise<Models.ConversationsGetConversationMemberResponse>
Parameters
- conversationId
-
string
Conversation ID
- memberId
-
string
MemberId for the user
- options
-
RequestOptionsBase | ServiceCallback<ChannelAccount[]>
The optional parameters
- callback
-
ServiceCallback<ChannelAccount[]>
The callback
Returns
Promise<Models.ConversationsGetConversationMemberResponse>
getConversationMembers(string, RequestOptionsBase)
Enumerate the members of a conversation. This REST API takes a ConversationId and returns an array of ChannelAccount objects representing the members of the conversation.
function getConversationMembers(conversationId: string, options?: RequestOptionsBase): Promise<Models.ConversationsGetConversationMembersResponse>
Parameters
- conversationId
-
string
Conversation ID
- options
-
RequestOptionsBase
Returns
Promise<Models.ConversationsGetConversationMembersResponse>
Promise<Models.ConversationsGetConversationMembersResponse>
getConversationMembers(string, RequestOptionsBase, ServiceCallback<ChannelAccount[]>)
function getConversationMembers(conversationId: string, options: RequestOptionsBase, callback: ServiceCallback<ChannelAccount[]>)
Parameters
- conversationId
-
string
Conversation ID
- options
-
RequestOptionsBase
The optional parameters
- callback
-
ServiceCallback<ChannelAccount[]>
The callback
getConversationMembers(string, ServiceCallback<ChannelAccount[]>)
function getConversationMembers(conversationId: string, callback: ServiceCallback<ChannelAccount[]>)
Parameters
- conversationId
-
string
Conversation ID
- callback
-
ServiceCallback<ChannelAccount[]>
The callback
getConversationPagedMembers(string, ConversationsGetConversationPagedMembersOptionalParams)
Enumerate the members of a conversation one page at a time. This REST API takes a ConversationId. Optionally a pageSize and/or continuationToken can be provided. It returns a PagedMembersResult, which contains an array of ChannelAccounts representing the members of the conversation and a continuation token that can be used to get more values.
One page of ChannelAccounts records are returned with each call. The number of records in a page may vary between channels and calls. The pageSize parameter can be used as a suggestion. If there are no additional results the response will not contain a continuation token. If there are no members in the conversation the Members will be empty or not present in the response.
A response to a request that has a continuation token from a prior request may rarely return members from a previous request.
function getConversationPagedMembers(conversationId: string, options?: ConversationsGetConversationPagedMembersOptionalParams): Promise<Models.ConversationsGetConversationPagedMembersResponse>
Parameters
- conversationId
-
string
Conversation ID
Returns
Promise<Models.ConversationsGetConversationPagedMembersResponse>
Promise<Models.ConversationsGetConversationPagedMembersResponse>
getConversationPagedMembers(string, ConversationsGetConversationPagedMembersOptionalParams, ServiceCallback<PagedMembersResult>)
function getConversationPagedMembers(conversationId: string, options: ConversationsGetConversationPagedMembersOptionalParams, callback: ServiceCallback<PagedMembersResult>)
Parameters
- conversationId
-
string
Conversation ID
The optional parameters
- callback
-
ServiceCallback<PagedMembersResult>
The callback
getConversationPagedMembers(string, ServiceCallback<PagedMembersResult>)
function getConversationPagedMembers(conversationId: string, callback: ServiceCallback<PagedMembersResult>)
Parameters
- conversationId
-
string
Conversation ID
- callback
-
ServiceCallback<PagedMembersResult>
The callback
getConversations(ConversationsGetConversationsOptionalParams)
List the Conversations in which this bot has participated. GET from this method with a skip token
The return value is a ConversationsResult, which contains an array of ConversationMembers and a skip token. If the skip token is not empty, then there are further values to be returned. Call this method again with the returned token to get more values.
Each ConversationMembers object contains the ID of the conversation and an array of ChannelAccounts that describe the members of the conversation.
function getConversations(options?: ConversationsGetConversationsOptionalParams): Promise<Models.ConversationsGetConversationsResponse>
Parameters
Returns
Promise<Models.ConversationsGetConversationsResponse>
Promise<Models.ConversationsGetConversationsResponse>
getConversations(ConversationsGetConversationsOptionalParams, ServiceCallback<ConversationsResult>)
function getConversations(options: ConversationsGetConversationsOptionalParams, callback: ServiceCallback<ConversationsResult>)
Parameters
The optional parameters
- callback
-
ServiceCallback<ConversationsResult>
The callback
getConversations(ServiceCallback<ConversationsResult>)
function getConversations(callback: ServiceCallback<ConversationsResult>)
Parameters
- callback
-
ServiceCallback<ConversationsResult>
The callback
replyToActivity(string, string, Partial<Activity>, RequestOptionsBase)
This method allows you to reply to an activity. This is slightly different from SendToConversation().
- SendToConversation(conversationId) - will append the activity to the end of the conversation according to the timestamp or semantics of the channel.
- ReplyToActivity(conversationId,ActivityId) - adds the activity as a reply to another activity, if the channel supports it. If the channel does not support nested replies, ReplyToActivity falls back to SendToConversation.
Use ReplyToActivity when replying to a specific activity in the conversation.
Use SendToConversation in all other cases.
function replyToActivity(conversationId: string, activityId: string, activity: Partial<Activity>, options?: RequestOptionsBase): Promise<Models.ConversationsReplyToActivityResponse>
Parameters
- conversationId
-
string
Conversation ID
- activityId
-
string
activityId the reply is to (OPTIONAL)
- activity
-
Partial<Activity>
Activity to send
- options
-
RequestOptionsBase
Returns
Promise<Models.ConversationsReplyToActivityResponse>
Promise<Models.ConversationsReplyToActivityResponse>
replyToActivity(string, string, Partial<Activity>, RequestOptionsBase, ServiceCallback<ResourceResponse>)
function replyToActivity(conversationId: string, activityId: string, activity: Partial<Activity>, options: RequestOptionsBase, callback: ServiceCallback<ResourceResponse>)
Parameters
- conversationId
-
string
Conversation ID
- activityId
-
string
activityId the reply is to (OPTIONAL)
- activity
-
Partial<Activity>
Activity to send
- options
-
RequestOptionsBase
The optional parameters
- callback
-
ServiceCallback<ResourceResponse>
The callback
replyToActivity(string, string, Partial<Activity>, ServiceCallback<ResourceResponse>)
function replyToActivity(conversationId: string, activityId: string, activity: Partial<Activity>, callback: ServiceCallback<ResourceResponse>)
Parameters
- conversationId
-
string
Conversation ID
- activityId
-
string
activityId the reply is to (OPTIONAL)
- activity
-
Partial<Activity>
Activity to send
- callback
-
ServiceCallback<ResourceResponse>
The callback
sendConversationHistory(string, Transcript, RequestOptionsBase)
This method allows you to upload the historic activities to the conversation. Sender must ensure that the historic activities have unique ids and appropriate timestamps. The ids are used by the client to deal with duplicate activities and the timestamps are used by the client to render the activities in the right order.
function sendConversationHistory(conversationId: string, history: Transcript, options?: RequestOptionsBase): Promise<Models.ConversationsSendConversationHistoryResponse>
Parameters
- conversationId
-
string
Conversation ID
- history
-
Transcript
Historic activities
- options
-
RequestOptionsBase
Returns
Promise<Models.ConversationsSendConversationHistoryResponse>
Promise<Models.ConversationsSendConversationHistoryResponse>
sendConversationHistory(string, Transcript, RequestOptionsBase, ServiceCallback<ResourceResponse>)
function sendConversationHistory(conversationId: string, history: Transcript, options: RequestOptionsBase, callback: ServiceCallback<ResourceResponse>)
Parameters
- conversationId
-
string
Conversation ID
- history
-
Transcript
Historic activities
- options
-
RequestOptionsBase
The optional parameters
- callback
-
ServiceCallback<ResourceResponse>
The callback
sendConversationHistory(string, Transcript, ServiceCallback<ResourceResponse>)
function sendConversationHistory(conversationId: string, history: Transcript, callback: ServiceCallback<ResourceResponse>)
Parameters
- conversationId
-
string
Conversation ID
- history
-
Transcript
Historic activities
- callback
-
ServiceCallback<ResourceResponse>
The callback
sendToConversation(string, Partial<Activity>, RequestOptionsBase)
This method allows you to send an activity to the end of a conversation. This is slightly different from ReplyToActivity().
- SendToConversation(conversationId) - will append the activity to the end of the conversation according to the timestamp or semantics of the channel.
- ReplyToActivity(conversationId,ActivityId) - adds the activity as a reply to another activity, if the channel supports it. If the channel does not support nested replies, ReplyToActivity falls back to SendToConversation.
Use ReplyToActivity when replying to a specific activity in the conversation.
Use SendToConversation in all other cases.
function sendToConversation(conversationId: string, activity: Partial<Activity>, options?: RequestOptionsBase): Promise<Models.ConversationsSendToConversationResponse>
Parameters
- conversationId
-
string
Conversation ID
- activity
-
Partial<Activity>
Activity to send
- options
-
RequestOptionsBase
Returns
Promise<Models.ConversationsSendToConversationResponse>
Promise<Models.ConversationsSendToConversationResponse>
sendToConversation(string, Partial<Activity>, RequestOptionsBase, ServiceCallback<ResourceResponse>)
function sendToConversation(conversationId: string, activity: Partial<Activity>, options: RequestOptionsBase, callback: ServiceCallback<ResourceResponse>)
Parameters
- conversationId
-
string
Conversation ID
- activity
-
Partial<Activity>
Activity to send
- options
-
RequestOptionsBase
The optional parameters
- callback
-
ServiceCallback<ResourceResponse>
The callback
sendToConversation(string, Partial<Activity>, ServiceCallback<ResourceResponse>)
function sendToConversation(conversationId: string, activity: Partial<Activity>, callback: ServiceCallback<ResourceResponse>)
Parameters
- conversationId
-
string
Conversation ID
- activity
-
Partial<Activity>
Activity to send
- callback
-
ServiceCallback<ResourceResponse>
The callback
updateActivity(string, string, Partial<Activity>, RequestOptionsBase)
Edit an existing activity. Some channels allow you to edit an existing activity to reflect the new state of a bot conversation.
For example, you can remove buttons after someone has clicked "Approve" button.
function updateActivity(conversationId: string, activityId: string, activity: Partial<Activity>, options?: RequestOptionsBase): Promise<Models.ConversationsUpdateActivityResponse>
Parameters
- conversationId
-
string
Conversation ID
- activityId
-
string
activityId to update
- activity
-
Partial<Activity>
replacement Activity
- options
-
RequestOptionsBase
Returns
Promise<Models.ConversationsUpdateActivityResponse>
Promise<Models.ConversationsUpdateActivityResponse>
updateActivity(string, string, Partial<Activity>, RequestOptionsBase, ServiceCallback<ResourceResponse>)
function updateActivity(conversationId: string, activityId: string, activity: Partial<Activity>, options: RequestOptionsBase, callback: ServiceCallback<ResourceResponse>)
Parameters
- conversationId
-
string
Conversation ID
- activityId
-
string
activityId to update
- activity
-
Partial<Activity>
replacement Activity
- options
-
RequestOptionsBase
The optional parameters
- callback
-
ServiceCallback<ResourceResponse>
The callback
updateActivity(string, string, Partial<Activity>, ServiceCallback<ResourceResponse>)
function updateActivity(conversationId: string, activityId: string, activity: Partial<Activity>, callback: ServiceCallback<ResourceResponse>)
Parameters
- conversationId
-
string
Conversation ID
- activityId
-
string
activityId to update
- activity
-
Partial<Activity>
replacement Activity
- callback
-
ServiceCallback<ResourceResponse>
The callback
uploadAttachment(string, AttachmentData, RequestOptionsBase)
Upload an attachment directly into a channel's blob storage. This is useful because it allows you to store data in a compliant store when dealing with enterprises.
The response is a ResourceResponse which contains an AttachmentId which is suitable for using with the attachments API.
function uploadAttachment(conversationId: string, attachmentUpload: AttachmentData, options?: RequestOptionsBase): Promise<Models.ConversationsUploadAttachmentResponse>
Parameters
- conversationId
-
string
Conversation ID
- attachmentUpload
-
AttachmentData
Attachment data
- options
-
RequestOptionsBase
Returns
Promise<Models.ConversationsUploadAttachmentResponse>
Promise<Models.ConversationsUploadAttachmentResponse>
uploadAttachment(string, AttachmentData, RequestOptionsBase, ServiceCallback<ResourceResponse>)
function uploadAttachment(conversationId: string, attachmentUpload: AttachmentData, options: RequestOptionsBase, callback: ServiceCallback<ResourceResponse>)
Parameters
- conversationId
-
string
Conversation ID
- attachmentUpload
-
AttachmentData
Attachment data
- options
-
RequestOptionsBase
The optional parameters
- callback
-
ServiceCallback<ResourceResponse>
The callback
uploadAttachment(string, AttachmentData, ServiceCallback<ResourceResponse>)
function uploadAttachment(conversationId: string, attachmentUpload: AttachmentData, callback: ServiceCallback<ResourceResponse>)
Parameters
- conversationId
-
string
Conversation ID
- attachmentUpload
-
AttachmentData
Attachment data
- callback
-
ServiceCallback<ResourceResponse>
The callback