您的所有对话消息(假设是消息而不是数据,因为对话数据在 Bot Framework 词汇表中是不同的东西,它与状态有关)都存储在 Azure 表中,因此如果您想获取这些消息,您只需要查询表。
获取表格项
你有几个选项来查询表,例如
从文档中获取按分区获取所有行的示例:
// Retrieve the storage account from the connection string.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
CloudConfigurationManager.GetSetting("StorageConnectionString"));
// Create the table client.
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
// Create the CloudTable object that represents the "people" table.
CloudTable table = tableClient.GetTableReference("people");
// Construct the query operation for all customer entities where PartitionKey="Smith".
TableQuery<CustomerEntity> query = new TableQuery<CustomerEntity>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "Smith"));
// Print the fields for each customer.
foreach (CustomerEntity entity in table.ExecuteQuery(query))
{
Console.WriteLine("{0}, {1}\t{2}\t{3}", entity.PartitionKey, entity.RowKey,
entity.Email, entity.PhoneNumber);
}
提供满足您需求的更定制化请求的文档:https://docs.microsoft.com/en-us/azure/cosmos-db/table-storage-how-to-use-dotnet
数据组织
在您的捕获中,您可以看到表格的PartitionKey 由您的channel 和看起来像对话ID 的东西组成。经TableLoggerhere的消息来源证实:
/// <summary>
/// Construct from an IActivity.
/// </summary>
/// <param name="activity"></param>
public ActivityEntity(IActivity activity)
{
PartitionKey = GeneratePartitionKey(activity.ChannelId, activity.Conversation.Id);
RowKey = GenerateRowKey(activity.Timestamp.Value);
From = activity.From.Id;
Recipient = activity.Recipient.Id;
Activity = activity;
Version = 3.0;
}
因此,您可能会对获取给定 partitionKey 的所有行感兴趣。
对于其他字段:RowKey 是时间戳,Activity 映射到您的机器人 Activity 对象,因此它是一个包含多个信息的对象。你将不得不做一些JsonConvert.DeserializeObject<Activity> 来获取有趣的信息。