Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libraries/Microsoft.Bot.Builder/ActivityHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public class ActivityHandler : IBot
// If OnInvokeActivityAsync has already sent an InvokeResponse, do not send another one.
if (invokeResponse != null && turnContext.TurnState.Get<Activity>(BotFrameworkAdapter.InvokeResponseKey) == null)
{
await turnContext.SendActivityAsync(new Activity { Value = invokeResponse, Type = ActivityTypesEx.InvokeResponse }, cancellationToken).ConfigureAwait(false);
await turnContext.SendActivityAsync(new Activity { Value = invokeResponse, Type = ActivityTypesEx.InvokeResponse }, false, cancellationToken).ConfigureAwait(false);
}

break;
Expand Down
15 changes: 12 additions & 3 deletions libraries/Microsoft.Bot.Builder/BotAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,27 @@ public BotAdapter Use(IMiddleware middleware)
/// </summary>
/// <param name="turnContext">The context object for the turn.</param>
/// <param name="activities">The activities to send.</param>
/// <param name='isTargeted'>
/// Flag to indicate if the activities should be delivered privately to a specific recipient within a conversation.
/// </param>
/// <param name="cancellationToken">A cancellation token that can be used by other objects
/// or threads to receive notice of cancellation.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <remarks>If the activities are successfully sent, the task result contains
/// an array of <see cref="ResourceResponse"/> objects containing the IDs that
/// the receiving channel assigned to the activities.</remarks>
/// <seealso cref="ITurnContext.OnSendActivities(SendActivitiesHandler)"/>
public abstract Task<ResourceResponse[]> SendActivitiesAsync(ITurnContext turnContext, Activity[] activities, CancellationToken cancellationToken);
public abstract Task<ResourceResponse[]> SendActivitiesAsync(ITurnContext turnContext, Activity[] activities, bool isTargeted = false, CancellationToken cancellationToken = default(CancellationToken));

/// <summary>
/// When overridden in a derived class, replaces an existing activity in the
/// conversation.
/// </summary>
/// <param name="turnContext">The context object for the turn.</param>
/// <param name="activity">New replacement activity.</param>
/// <param name='isTargeted'>
/// Flag to indicate if the activities should be delivered privately to a specific recipient within a conversation.
/// </param>
/// <param name="cancellationToken">A cancellation token that can be used by other objects
/// or threads to receive notice of cancellation.</param>
/// <returns>A task that represents the work queued to execute.</returns>
Expand All @@ -109,21 +115,24 @@ public BotAdapter Use(IMiddleware middleware)
/// <para>Before calling this, set the ID of the replacement activity to the ID
/// of the activity to replace.</para></remarks>
/// <seealso cref="ITurnContext.OnUpdateActivity(UpdateActivityHandler)"/>
public abstract Task<ResourceResponse> UpdateActivityAsync(ITurnContext turnContext, Activity activity, CancellationToken cancellationToken);
public abstract Task<ResourceResponse> UpdateActivityAsync(ITurnContext turnContext, Activity activity, bool isTargeted = false, CancellationToken cancellationToken = default(CancellationToken));

/// <summary>
/// When overridden in a derived class, deletes an existing activity in the
/// conversation.
/// </summary>
/// <param name="turnContext">The context object for the turn.</param>
/// <param name="reference">Conversation reference for the activity to delete.</param>
/// <param name='isTargeted'>
/// Flag to indicate if the activities should be delivered privately to a specific recipient within a conversation.
/// </param>
/// <param name="cancellationToken">A cancellation token that can be used by other objects
/// or threads to receive notice of cancellation.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <remarks>The <see cref="ConversationReference.ActivityId"/> of the conversation
/// reference identifies the activity to delete.</remarks>
/// <seealso cref="ITurnContext.OnDeleteActivity(DeleteActivityHandler)"/>
public abstract Task DeleteActivityAsync(ITurnContext turnContext, ConversationReference reference, CancellationToken cancellationToken);
public abstract Task DeleteActivityAsync(ITurnContext turnContext, ConversationReference reference, bool isTargeted = false, CancellationToken cancellationToken = default(CancellationToken));

/// <summary>
/// Sends a proactive message to a conversation.
Expand Down
19 changes: 12 additions & 7 deletions libraries/Microsoft.Bot.Builder/BotFrameworkAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -481,13 +481,14 @@ public override async Task<InvokeResponse> ProcessActivityAsync(ClaimsIdentity c
/// </summary>
/// <param name="turnContext">The context object for the turn.</param>
/// <param name="activities">The activities to send.</param>
/// <param name="isTargeted">Flag to indicate if the activity should be delivered privately to a specific recipient within a conversation.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <remarks>If the activities are successfully sent, the task result contains
/// an array of <see cref="ResourceResponse"/> objects containing the IDs that
/// the receiving channel assigned to the activities.</remarks>
/// <seealso cref="ITurnContext.OnSendActivities(SendActivitiesHandler)"/>
public override async Task<ResourceResponse[]> SendActivitiesAsync(ITurnContext turnContext, Activity[] activities, CancellationToken cancellationToken)
public override async Task<ResourceResponse[]> SendActivitiesAsync(ITurnContext turnContext, Activity[] activities, bool isTargeted = false, CancellationToken cancellationToken = default(CancellationToken))
{
if (turnContext == null)
{
Expand Down Expand Up @@ -568,12 +569,12 @@ public override async Task<ResourceResponse[]> SendActivitiesAsync(ITurnContext
if (!string.IsNullOrWhiteSpace(activity.ReplyToId))
{
var connectorClient = turnContext.TurnState.Get<IConnectorClient>();
response = await connectorClient.Conversations.ReplyToActivityAsync(activity, cancellationToken).ConfigureAwait(false);
response = await connectorClient.Conversations.ReplyToActivityAsync(activity, isTargeted, cancellationToken).ConfigureAwait(false);
}
else
{
var connectorClient = turnContext.TurnState.Get<IConnectorClient>();
response = await connectorClient.Conversations.SendToConversationAsync(activity, cancellationToken).ConfigureAwait(false);
response = await connectorClient.Conversations.SendToConversationAsync(activity, isTargeted, cancellationToken).ConfigureAwait(false);
}
}
}
Expand Down Expand Up @@ -603,6 +604,9 @@ public override async Task<ResourceResponse[]> SendActivitiesAsync(ITurnContext
/// </summary>
/// <param name="turnContext">The context object for the turn.</param>
/// <param name="activity">New replacement activity.</param>
/// <param name='isTargeted'>
/// Flag to indicate if the activity should be delivered privately to a specific recipient within a conversation.
/// </param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <remarks>If the activity is successfully sent, the task result contains
Expand All @@ -611,26 +615,27 @@ public override async Task<ResourceResponse[]> SendActivitiesAsync(ITurnContext
/// <para>Before calling this, set the ID of the replacement activity to the ID
/// of the activity to replace.</para></remarks>
/// <seealso cref="ITurnContext.OnUpdateActivity(UpdateActivityHandler)"/>
public override async Task<ResourceResponse> UpdateActivityAsync(ITurnContext turnContext, Activity activity, CancellationToken cancellationToken)
public override async Task<ResourceResponse> UpdateActivityAsync(ITurnContext turnContext, Activity activity, bool isTargeted = false, CancellationToken cancellationToken = default(CancellationToken))
{
var connectorClient = turnContext.TurnState.Get<IConnectorClient>();
return await connectorClient.Conversations.UpdateActivityAsync(activity, cancellationToken).ConfigureAwait(false);
return await connectorClient.Conversations.UpdateActivityAsync(activity, isTargeted, cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// Deletes an existing activity in the conversation.
/// </summary>
/// <param name="turnContext">The context object for the turn.</param>
/// <param name="reference">Conversation reference for the activity to delete.</param>
/// <param name='isTargeted'> Flag to indicate if the activity should be delivered privately to a specific recipient within a conversation.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <remarks>The <see cref="ConversationReference.ActivityId"/> of the conversation
/// reference identifies the activity to delete.</remarks>
/// <seealso cref="ITurnContext.OnDeleteActivity(DeleteActivityHandler)"/>
public override async Task DeleteActivityAsync(ITurnContext turnContext, ConversationReference reference, CancellationToken cancellationToken)
public override async Task DeleteActivityAsync(ITurnContext turnContext, ConversationReference reference, bool isTargeted = false, CancellationToken cancellationToken = default(CancellationToken))
{
var connectorClient = turnContext.TurnState.Get<IConnectorClient>();
await connectorClient.Conversations.DeleteActivityAsync(reference.Conversation.Id, reference.ActivityId, cancellationToken).ConfigureAwait(false);
await connectorClient.Conversations.DeleteActivityAsync(reference.Conversation.Id, reference.ActivityId, isTargeted, cancellationToken).ConfigureAwait(false);
}

/// <summary>
Expand Down
14 changes: 7 additions & 7 deletions libraries/Microsoft.Bot.Builder/CloudAdapterBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected CloudAdapterBase(
protected ILogger Logger { get; private set; }

/// <inheritdoc/>
public override async Task<ResourceResponse[]> SendActivitiesAsync(ITurnContext turnContext, Activity[] activities, CancellationToken cancellationToken)
public override async Task<ResourceResponse[]> SendActivitiesAsync(ITurnContext turnContext, Activity[] activities, bool isTargeted = false, CancellationToken cancellationToken = default(CancellationToken))
{
_ = turnContext ?? throw new ArgumentNullException(nameof(turnContext));
_ = activities ?? throw new ArgumentNullException(nameof(activities));
Expand Down Expand Up @@ -93,12 +93,12 @@ public override async Task<ResourceResponse[]> SendActivitiesAsync(ITurnContext
if (!string.IsNullOrWhiteSpace(activity.ReplyToId))
{
var connectorClient = turnContext.TurnState.Get<IConnectorClient>();
response = await connectorClient.Conversations.ReplyToActivityAsync(activity, cancellationToken).ConfigureAwait(false);
response = await connectorClient.Conversations.ReplyToActivityAsync(activity, isTargeted, cancellationToken).ConfigureAwait(false);
}
else
{
var connectorClient = turnContext.TurnState.Get<IConnectorClient>();
response = await connectorClient.Conversations.SendToConversationAsync(activity, cancellationToken).ConfigureAwait(false);
response = await connectorClient.Conversations.SendToConversationAsync(activity, isTargeted, cancellationToken).ConfigureAwait(false);
}
}

Expand All @@ -114,27 +114,27 @@ public override async Task<ResourceResponse[]> SendActivitiesAsync(ITurnContext
}

/// <inheritdoc/>
public override async Task<ResourceResponse> UpdateActivityAsync(ITurnContext turnContext, Activity activity, CancellationToken cancellationToken)
public override async Task<ResourceResponse> UpdateActivityAsync(ITurnContext turnContext, Activity activity, bool isTargeted = false, CancellationToken cancellationToken = default(CancellationToken))
{
_ = turnContext ?? throw new ArgumentNullException(nameof(turnContext));
_ = activity ?? throw new ArgumentNullException(nameof(activity));

Logger.LogInformation($"UpdateActivityAsync ActivityId: {activity.Id}");

var connectorClient = turnContext.TurnState.Get<IConnectorClient>();
return await connectorClient.Conversations.UpdateActivityAsync(activity, cancellationToken).ConfigureAwait(false);
return await connectorClient.Conversations.UpdateActivityAsync(activity, isTargeted, cancellationToken).ConfigureAwait(false);
}

/// <inheritdoc/>
public override async Task DeleteActivityAsync(ITurnContext turnContext, ConversationReference reference, CancellationToken cancellationToken)
public override async Task DeleteActivityAsync(ITurnContext turnContext, ConversationReference reference, bool isTargeted = false, CancellationToken cancellationToken = default(CancellationToken))
{
_ = turnContext ?? throw new ArgumentNullException(nameof(turnContext));
_ = reference ?? throw new ArgumentNullException(nameof(reference));

Logger.LogInformation($"DeleteActivityAsync Conversation Id: {reference.Conversation.Id}, ActivityId: {reference.ActivityId}");

var connectorClient = turnContext.TurnState.Get<IConnectorClient>();
await connectorClient.Conversations.DeleteActivityAsync(reference.Conversation.Id, reference.ActivityId, cancellationToken).ConfigureAwait(false);
await connectorClient.Conversations.DeleteActivityAsync(reference.Conversation.Id, reference.ActivityId, isTargeted, cancellationToken).ConfigureAwait(false);
}

/// <inheritdoc/>
Expand Down
Loading
Loading