.net core 使用Bot Framework V4在团队中发送主动1:1消息
我正在尝试使用teams SDK从bot向团队发送主动1:1消息,代码如下.net core 使用Bot Framework V4在团队中发送主动1:1消息,.net-core,botframework,microsoft-teams,proactive,.net Core,Botframework,Microsoft Teams,Proactive,我正在尝试使用teams SDK从bot向团队发送主动1:1消息,代码如下 MicrosoftAppCredentials.TrustServiceUrl(turnContext.Activity.ServiceUrl); var connectorClient = new ConnectorClient(new Uri(turnContext.Activity.ServiceUrl), Configuration["MicrosoftAppId"], Configura
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);
我对此有以下问题:
任何关于如何纠正此问题的帮助都将不胜感激。谢谢。根据评论中的答案,我想我更了解这个场景,在我看来问题在于你没有设置对话Id——尽管你告诉机器人你想与哪个用户互动,但它需要知道你是否想直接与他们互动(即1-1),或者作为某个地方的群聊或团队频道的一部分 您需要通过配置Activity实例上的Conversation属性(在您的示例中是“message”变量)来设置此设置。更多详细信息,请参见我的帖子:
希望这有帮助-如果没有,请让我知道我实际上不清楚您确切的问题是什么,但我猜是您不希望发送多条消息?或者,您希望将它们直接发送给用户,而不是发送给群聊吗?或者您希望将他们发送到群聊,但只发送一条消息?我正在尝试从Bot向用户发送1:1的个人消息。bot无法向部署后未对话的用户发送消息。如果它能够在对话后发送,它将根据已经与bot对话的用户数多次发送相同的消息,即如果部署后有10个用户与bot对话,bot将向所需用户发送10次所需消息。