若要更新现有消息,请将具有现有活动 ID 的新 Activity 对象传递给 TurnContext 类的方法 UpdateActivityAsync。
// Send initial message
var response = await turnContext.SendActivityAsync(MessageFactory.Attachment(card.ToAttachment()), cancellationToken);
var activityId = response.Id; // Fetch activity id.
// MessageFactory.Text(): Specifies the type of text data in a message attachment.
var newActivity = MessageFactory.Text("The new text for the activity");
newActivity.Id = activityId;
// UpdateActivityAsync(): A method that can participate in update activity events for the current turn.
await turnContext.UpdateActivityAsync(newActivity, cancellationToken);
若要更新现有消息,请将具有现有活动 ID 的新 Activity 对象传递给 TurnContext 对象的方法 updateActivity。
// Send initial message
var message = await context.sendActivity("<Your Message>");
var activityId = message.id; // Fetch activity id.
// MessageFactory.Text(): Specifies the type of text data in a message attachment.
const newActivity = MessageFactory.text('The new text for the activity');
newActivity.id = activityId;
// A method that can participate in update activity events for the current turn.
await turnContext.updateActivity(newActivity);
若要更新现有消息,请将具有现有活动 ID 的新 Activity 对象传递给 TurnContext 类的方法 update_activity。
# Send initial message
message = await turn_context.send_activity("<Your Message>")
activityId = message.id # Fetch activity id.
# MessageFactory.Text(): Specifies the type of text data in a message attachment.
new_activity = MessageFactory.text("The new text for the activity")
new_activity.id = activity_id
# A method that can participate in update activity events for the current turn.
update_result = await context.update_activity(new_activity)
若要更新按钮选择的现有卡片,请将具有更新卡片和 ReplyToId 活动 ID 的新 Activity 对象传递给 TurnContext 类的方法 UpdateActivityAsync。
// Returns a message activity that contains an attachment.
var activity = MessageFactory.Attachment(card.ToAttachment());
activity.Id = turnContext.Activity.ReplyToId;
// A method that can participate in update activity events for the current turn.
await turnContext.UpdateActivityAsync(activity, cancellationToken);
若要更新的按钮选择的现有卡片,请将具有更新卡片和 replyToId 活动 ID 的新 Activity 对象传递给 TurnContext 对象的方法 updateActivity。
// MessageFactory.attachment(): Returns a message activity that contains an attachment.
const message = MessageFactory.attachment(card);
message.id = context.activity.replyToId;
// updateActivity(): A method that can participate in update activity events for the current turn.
await context.updateActivity(message);
若要更新按钮点击的现有卡片,请将具有更新卡片和 reply_to_id 活动 ID 的新 Activity 对象传递给 TurnContext 类的方法 update_activity。
# MessageFactory.attachment(): Returns a message activity that contains an attachment.
updated_activity = MessageFactory.attachment(CardFactory.hero_card(card))
updated_activity.id = turn_context.activity.reply_to_id
# update_activity(): A method that can participate in update activity events for the current turn.
await turn_context.update_activity(updated_activity)
若要删除消息,请将该活动的 ID 传递给 TurnContext 类的方法 DeleteActivityAsync。
foreach (var activityId in _list)
{
// When overridden in a derived class, deletes an existing activity in the conversation.
await turnContext.DeleteActivityAsync(activityId, cancellationToken);
}
若要删除消息,请将该活动的 ID 传递给 TurnContext 对象的方法 deleteActivity。
for (let i = 0; i < activityIds.length; i++) {
// deleteActivity(): deletes an existing activity in the conversation.
await turnContext.deleteActivity(activityIds[i]);
}