我正在尝试使用 Teams SDK 将主动 1:1 消息从机器人发送到团队,代码如下
MicrosoftAppCredentials.TrustServiceUrl(turnContext.Activity.ServiceUrl);
var connectorClient = new ConnectorClient(new Uri(turnContext.Activity.ServiceUrl), Configuration["MicrosoftAppId"], Configuration["MicrosoftAppPassword"]);
var userId = _operation.MemberTeamsId;
var tenantId = Configuration["TenantId"];
var parameters = new ConversationParameters
{
Members = new[] { new ChannelAccount(userId) },
ChannelData = new TeamsChannelData
{
Tenant = new TenantInfo(tenantId),
},
};
var conversationResource = await connectorClient.Conversations.CreateConversationAsync(parameters);
var message = Microsoft.Bot.Schema.Activity.CreateMessageActivity();
message.Text = _operation.Message;
await connectorClient.Conversations.SendToConversationAsync(conversationResource.Id, (Microsoft.Bot.Schema.Activity)message);
我对此有以下问题,
除非用户在部署后进行了先前的对话,否则机器人无法发送主动消息
机器人部署
Bill to Bot - 工程
Bot to Bill - 作品
机器人重新部署
Bot to Bill - 不起作用,因为重新部署后现在对话中没有成员
Bill to Bot - 工程
Bot to Bill - 重新部署后,Bill 进行对话时现在可以工作
Bot 多次向用户发送相同的消息
Bill to Bot - 工程
Bot to Bill - 主动工作 - 按照应有的方式发送 1 条已定义的消息
Sim to Bot - 工作
Bot to Sim - 发送 2 条相同的消息,因为现在对话中有两个成员
Will to Bot - 有效
Bot to Will - 发送 3 条相同的消息,因为现在对话中有 3 个成员
注意:我将 Teams 用户 ID 存储在 DB 中,并使用它们向用户发送直接消息
任何有关如何纠正此问题的帮助将不胜感激。谢谢。